From b9c4056e1e50e6a8dd8e6657607d83dd99ca3767 Mon Sep 17 00:00:00 2001 From: jvanzyl Date: Mon, 10 Feb 2003 15:44:40 +0000 Subject: [PATCH] o use existing maven constants. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@112880 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/release/SnapshotResolver.java | 53 +++++++++---------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/release/src/main/org/apache/maven/release/SnapshotResolver.java b/release/src/main/org/apache/maven/release/SnapshotResolver.java index 8d41f030..b334cdb4 100644 --- a/release/src/main/org/apache/maven/release/SnapshotResolver.java +++ b/release/src/main/org/apache/maven/release/SnapshotResolver.java @@ -56,17 +56,12 @@ package org.apache.maven.release; * ==================================================================== */ -import org.dom4j.Document; -import org.dom4j.Node; -import org.dom4j.io.SAXReader; -import org.jaxen.XPath; -import org.jaxen.dom4j.Dom4jXPath; -import org.apache.maven.util.HttpUtils; import org.apache.commons.io.FileUtils; +import org.apache.maven.util.HttpUtils; +import org.apache.maven.MavenConstants; +import org.dom4j.Node; import java.io.File; -import java.util.ArrayList; -import java.util.List; /** * This is a simple POM manipulator that doesn't take into account any sort of @@ -79,16 +74,6 @@ import java.util.List; public class SnapshotResolver extends AbstractPomTransformer { - // ---------------------------------------------------------------------- - // Constants - // ---------------------------------------------------------------------- - - public static final String PROXY_HOST = ""; - public static final String PROXY_PORT = ""; - public static final String PROXY_USER_NAME = ""; - public static final String PROXY_PASSWORD = ""; - public static final String REPO_REMOTE = ""; - // ------------------------------------------------------------------------- // Accessors // ------------------------------------------------------------------------- @@ -102,17 +87,28 @@ public class SnapshotResolver throws Exception { Node idNode = node.selectSingleNode( "id" ); - Node artifactIdNode = node.selectSingleNode( "artifactId" ); - Node groupIdNode = node.selectSingleNode( "groupId" ); - Node versionNode = node.selectSingleNode( "version" ); - String groupId = null; - String artifactId = null; + String groupId; + String artifactId; + + if ( idNode != null ) + { + groupId = idNode.getText(); + artifactId = groupId; + } + else + { + Node artifactIdNode = node.selectSingleNode( "artifactId" ); + Node groupIdNode = node.selectSingleNode( "groupId" ); + + groupId = groupIdNode.getText(); + artifactId = artifactIdNode.getText(); + } // Now we need to attempt to find the the actual timestamp // version for this dependency. - String url = getProperties().getProperty( REPO_REMOTE ) + "/" + + String url = getProperties().getProperty( MavenConstants.REPO_REMOTE ) + "/" + groupId + "/jars/" + artifactId + "-snapshot-version"; File snapshotVersionFile = new File( artifactId + "-snapshot-version" ); @@ -123,10 +119,10 @@ public class SnapshotResolver snapshotVersionFile, true, // ignore errors false, // use timestamps - getProperties().getProperty( PROXY_HOST ), // proxy host - getProperties().getProperty( PROXY_PORT ), // proxy port - getProperties().getProperty( PROXY_USER_NAME ), // proxy user name - getProperties().getProperty( PROXY_PASSWORD ) // proxy password + getProperties().getProperty( MavenConstants.PROXY_HOST ), // proxy host + getProperties().getProperty( MavenConstants.PROXY_PORT ), // proxy port + getProperties().getProperty( MavenConstants.PROXY_USERNAME ), // proxy user name + getProperties().getProperty( MavenConstants.PROXY_PASSWORD ) // proxy password ); } catch ( Exception e ) @@ -138,6 +134,7 @@ public class SnapshotResolver if ( snapshotVersionFile.exists() ) { String timestampVersion = FileUtils.fileRead( snapshotVersionFile.getPath() ); + Node versionNode = node.selectSingleNode( "version" ); versionNode.setText( timestampVersion ); } }