o MAVEN-542
http://jira.codehaus.org/secure/ViewIssue.jspa?id=11157 git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114124 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
1 parent
57f391b91b
commit
5e379137a2
1 file changed
+42
-32
@@ -58,17 +58,19 @@ package org.apache.maven.release;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.maven.MavenConstants;
|
||||
import org.apache.maven.project.Project;
|
||||
import org.apache.maven.util.HttpUtils;
|
||||
import org.dom4j.Node;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
|
||||
*
|
||||
* @version $Id: SnapshotResolver.java,v 1.12 2003/04/13 00:56:02 dion Exp $
|
||||
* @version $Id: SnapshotResolver.java,v 1.13 2003/09/29 23:52:00 jvanzyl Exp $
|
||||
*/
|
||||
public class SnapshotResolver
|
||||
extends AbstractPomTransformer
|
||||
@@ -96,6 +98,7 @@ public class SnapshotResolver
|
||||
|
||||
String groupId;
|
||||
String artifactId;
|
||||
String artifactType = "jar";
|
||||
|
||||
if ( idNode != null )
|
||||
{
|
||||
@@ -111,46 +114,53 @@ public class SnapshotResolver
|
||||
artifactId = artifactIdNode.getText();
|
||||
}
|
||||
|
||||
Node typeIdNode = node.selectSingleNode( "groupId" );
|
||||
|
||||
if ( typeIdNode != null )
|
||||
{
|
||||
artifactType = typeIdNode.getText();
|
||||
}
|
||||
|
||||
// Now we need to attempt to find the the actual timestamp
|
||||
// version for this dependency.
|
||||
|
||||
// Variables are being stored as ConstantExpressions ...
|
||||
|
||||
/*
|
||||
String url = getVariables().get( MavenConstants.REPO_REMOTE ) + "/" +
|
||||
groupId + "/jars/" + artifactId + "-snapshot-version";
|
||||
*/
|
||||
|
||||
String url = "http://www.ibiblio.org/maven/" + groupId + "/jars/" + artifactId + "-snapshot-version";
|
||||
|
||||
Project project = (Project) getVariables().get( MavenConstants.MAVEN_POM );
|
||||
File snapshotVersionFile = new File( getProject().getParentFile(), artifactId + "-snapshot-version" );
|
||||
|
||||
try
|
||||
for ( Iterator i = project.getContext().getMavenRepoRemote().iterator(); i.hasNext(); )
|
||||
{
|
||||
HttpUtils.getFile( url,
|
||||
snapshotVersionFile,
|
||||
true, // ignore errors
|
||||
false, // use timestamps
|
||||
(String) getVariables().get( MavenConstants.PROXY_HOST ), // proxy host
|
||||
(String) getVariables().get( MavenConstants.PROXY_PORT ), // proxy port
|
||||
(String) getVariables().get( MavenConstants.PROXY_USERNAME ), // proxy user name
|
||||
(String) getVariables().get( MavenConstants.PROXY_PASSWORD ) // proxy password
|
||||
);
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// Either doesn't exist, or we have a network problem. In
|
||||
// either event we can't update the version field.
|
||||
System.out.println( "Can't retrieve snapshot version file: " + e.getLocalizedMessage() );
|
||||
}
|
||||
String remoteRepo = (String) i.next();
|
||||
String url = remoteRepo + "/" + groupId + "/" + artifactType + "s/" + artifactId + "-snapshot-version";
|
||||
|
||||
if ( snapshotVersionFile.exists() )
|
||||
{
|
||||
timestampVersion = FileUtils.fileRead( snapshotVersionFile.getPath() );
|
||||
}
|
||||
else
|
||||
{
|
||||
timestampVersion = "SNAPSHOT";
|
||||
try
|
||||
{
|
||||
HttpUtils.getFile( url,
|
||||
snapshotVersionFile,
|
||||
true, // ignore errors
|
||||
false, // use timestamps
|
||||
(String) getVariables().get( MavenConstants.PROXY_HOST ), // proxy host
|
||||
(String) getVariables().get( MavenConstants.PROXY_PORT ), // proxy port
|
||||
(String) getVariables().get( MavenConstants.PROXY_USERNAME ), // proxy user name
|
||||
(String) getVariables().get( MavenConstants.PROXY_PASSWORD ) // proxy password
|
||||
);
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// Either doesn't exist, or we have a network problem. In
|
||||
// either event we can't update the version field.
|
||||
System.out.println( "Can't retrieve snapshot version file: " + e.getLocalizedMessage() );
|
||||
}
|
||||
|
||||
if ( snapshotVersionFile.exists() )
|
||||
{
|
||||
timestampVersion = FileUtils.fileRead( snapshotVersionFile.getPath() );
|
||||
}
|
||||
else
|
||||
{
|
||||
timestampVersion = "SNAPSHOT";
|
||||
}
|
||||
}
|
||||
|
||||
return timestampVersion;
|
||||
|
||||
Reference in new issue
Block a user