Login | Register
My pages Projects Community openCollabNet

Discussions > commits > svn commit: r103 - trunk/pomstrap/src/main/java/org/tigris/pomstrap

pomstrap
Discussion topic

Back to topic list

svn commit: r103 - trunk/pomstrap/src/main/java/org/tigris/pomstrap

Reply

Author alag
Full name Alexis Agahi
Date 2008-06-10 02:42:55 PDT
Message Author: alag
Date: 2008-06-10 02:42:55-0700
New Revision: 103

Modified:
   trunk/pomstrap/src/m​ain/java/org/tigris/​pomstrap/Dependency.​java
   trunk/pomstrap/src/m​ain/java/org/tigris/​pomstrap/MavenReposi​toryUtils.java

Log:
Added support for classifier in pom.xml file

Modified: trunk/pomstrap/src/m​ain/java/org/tigris/​pomstrap/Dependency.​java
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/trunk/poms​trap/src/main/java/o​rg/tigris/pomstrap/D​ependency.java?view=​diff&rev=103​&p1=trunk/pomstrap/s​rc/main/java/org/tig​ris/pomstrap/Depende​ncy.java&p2=trun​k/pomstrap/src/main/​java/org/tigris/poms​trap/Dependency.java​&r1=102&r2=1​03
====================​====================​====================​==================
--- trunk/pomstrap/src/m​ain/java/org/tigris/​pomstrap/Dependency.​java (original)
+++ trunk/pomstrap/src/m​ain/java/org/tigris/​pomstrap/Dependency.​java 2008-06-10 02:42:55-0700
@@ -44,6 +44,7 @@
     private String groupId;
     private String artifactId;
     private String version;
+ private String classifier;
     private String scope;
     private boolean optional;
     
@@ -56,23 +57,37 @@
     private String projectVersion;
     private List childs;
     
+ /**
+ * Simple constructor
+ *
+ * @param groupId Maven2 groupId
+ * @param artifactId Maven2 artifactId
+ * @param version Maven2 version
+ * @param scope Maven2 scope
+ */
+ public Dependency( String groupId, String artifactId, String version, String scope )
+ {
+ this( groupId, artifactId, version, scope, null, false );
+ }
     /**
      * Simple constructor
      *
      * @param groupId Maven2 groupId
      * @param artifactId Maven2 artifactId
      * @param version Maven2 version
+ * @param classifier Maven2 classifier
      * @param scope Maven2 scope
      */
- public Dependency( String groupId, String artifactId, String version, String scope )
+ public Dependency( String groupId, String artifactId, String version, String classifier, String scope )
     {
- this( groupId, artifactId, version, scope, false );
+ this( groupId, artifactId, version, scope, classifier, false );
     }
- public Dependency( String groupId, String artifactId, String version, String scope, boolean optional )
+ public Dependency( String groupId, String artifactId, String version, String classifier, String scope, boolean optional )
     {
         this.groupId = groupId;
         this.artifactId = artifactId;
         this.version = version;
+ this.classifier = classifier;
         this.scope = scope;
         this.optional = optional;
     }
@@ -87,14 +102,18 @@
     throws Exception
     {
         StringTokenizer tokenizer = new StringTokenizer( dependency, ":" );
- if( tokenizer.countTokens() != 3 )
+ if( tokenizer.countTokens() < 3 && tokenizer.countTokens() > 4 )
         {
- throw new Exception( "Invalid dependency (groupId:artefactId:version expected): " + dependency );
+ throw new Exception( "Invalid dependency (groupId:artefactId:​version[:classifier]​ expected): " + dependency );
         }
         
         this.groupId = tokenizer.nextToken();
         this.artifactId = tokenizer.nextToken();
         this.version = tokenizer.nextToken();
+ if( tokenizer.hasMoreTokens() )
+ {
+ this.classifier = tokenizer.nextToken();
+ }
         this.optional = false;
     }
     
@@ -236,7 +255,7 @@
       
         try
         {
- is = MavenRepositoryUtils​.getResourceURL( repository, getGroupId(), getArtifactId(), getVersion(), "pom" ).openStream();
+ is = MavenRepositoryUtils​.getResourceURL( repository, getGroupId(), getArtifactId(), getVersion(), null, "pom" ).openStream();
             
         }
         catch ( Exception e )
@@ -290,7 +309,15 @@
             e = (Element)(findElements( element, "version" ).iterator().next());
             String version = autoReplaceByProperty( document, e.getFirstChild().ge​tNodeValue().trim() );
             
- parentDependency = new Dependency( groupId, artifactId, version, null );
+ List classifierList = findElements( element, "classifier" );
+ String classifier = null;
+ if( !classifierList.isEmpty() )
+ {
+ e = (Element)(classifier​List.iterator().next​());
+ classifier = autoReplaceByProperty( document, e.getFirstChild().ge​tNodeValue().trim() );
+ }
+
+ parentDependency = new Dependency( groupId, artifactId, version, classifier, null );
             parentDependency.setRepository( repository );
         }
         
@@ -346,7 +373,7 @@
                         }
                     }
     
- String pomURLStr = MavenRepositoryUtils​.getResourceURL( repository, getGroupId(), getArtifactId(), getVersion(), "pom" ).toString();
+ String pomURLStr = MavenRepositoryUtils​.getResourceURL( repository, getGroupId(), getArtifactId(), getVersion(), null, "pom" ).toString();
                     System.err.println( "WARNING: no version for " + groupId + ':'+ artifactId + " in POM ("+pomURLStr+") ");
                     continue;
                 }
@@ -356,7 +383,16 @@
                     version = autoReplaceByProperty( document, e.getFirstChild().ge​tNodeValue().trim() );
                 }
                 
- Dependency dep = new Dependency( groupId, artifactId, version, scope, optional );
+ List classifierList = findElements( element, "classifier" );
+ String classifier = null;
+ if( !classifierList.isEmpty() )
+ {
+ e = (Element)(classifier​List.iterator().next​());
+ classifier = autoReplaceByProperty( document, e.getFirstChild().ge​tNodeValue().trim() );
+ }
+
+
+ Dependency dep = new Dependency( groupId, artifactId, version, classifier, scope, optional );
                 dep.setRepository( repository );
                 dependencyList.add( dep );
             }
@@ -398,7 +434,14 @@
     throws MalformedURLException
     {
         URL url = MavenRepositoryUtils​.getFolderURL( repository, getGroupId(), getArtifactId(), getVersion() );
- url = new URL( url.toString() + '/' + getArtifactId()+'-'+​getVersion()+".jar" );
+ if( getClassifier() == null )
+ {
+ url = new URL( url.toString() + '/' + getArtifactId()+'-'+​getVersion()+".jar" );
+ }
+ else
+ {
+ url = new URL( url.toString() + '/' + getArtifactId()+'-'+​getVersion()+'-'+get​Classifier()+".jar" );
+ }
         return new URL[]{url};
     }
     
@@ -463,7 +506,15 @@
         return scope;
     }
 
- public void setScope(String scope) {
+ public String getClassifier()
+ {
+ return classifier;
+ }
+ public void setClassifier( String classifier )
+ {
+ this.classifier = classifier;
+ }
+ public void setScope(String scope) {
         this.scope = scope;
     }
     
@@ -478,6 +529,10 @@
     public String toString()
     {
         String s = groupId+':'+artifact​Id+':'+version;
+ if( classifier != null )
+ {
+ s += ':' + classifier;
+ }
         if( scope != null )
         {
             s += '('+scope+')';

Modified: trunk/pomstrap/src/m​ain/java/org/tigris/​pomstrap/MavenReposi​toryUtils.java
Url: http://pomstrap.tigr​is.org/source/browse​/pomstrap/trunk/poms​trap/src/main/java/o​rg/tigris/pomstrap/M​avenRepositoryUtils.​java?view=diff&r​ev=103&p1=trunk/​pomstrap/src/main/ja​va/org/tigris/pomstr​ap/MavenRepositoryUt​ils.java&p2=trun​k/pomstrap/src/main/​java/org/tigris/poms​trap/MavenRepository​Utils.java&r1=10​2&r2=103
====================​====================​====================​==================
--- trunk/pomstrap/src/m​ain/java/org/tigris/​pomstrap/MavenReposi​toryUtils.java (original)
+++ trunk/pomstrap/src/m​ain/java/org/tigris/​pomstrap/MavenReposi​toryUtils.java 2008-06-10 02:42:55-0700
@@ -43,21 +43,28 @@
     
     /**
      * Find the appropriate folder URL of this dependency
- * @return the URL of the repository folder of this dependency (by defaut $user.home/.m2/repo​sitory/groupId/artif​actId/version/artifa​ctId-version.extensi​onType
+ * @return the URL of the repository folder of this dependency (by defaut $user.home/.m2/repo​sitory/groupId/artif​actId/version/artifa​ctId-version[-classi​fier].extensionType
      * @throws MalformedURLException
      */
- public static URL getResourceURL( String repository, String groupId, String artifactId, String version, String extensionType )
+ public static URL getResourceURL( String repository, String groupId, String artifactId, String version, String classifier, String extensionType )
     throws MalformedURLException
     {
- URL url = getFolderURL( repository, groupId, artifactId, version );
- url = new URL( url.toString() + '/' + artifactId+'-'+version+"."+ extensionType );
+ URL url = getFolderURL( repository, groupId, artifactId, version );
+ if( classifier == null )
+ {
+ url = new URL( url.toString() + '/' + artifactId+'-'+version+"."+ extensionType );
+ }
+ else
+ {
+ url = new URL( url.toString() + '/' + artifactId+'-'+versi​on+'-'+classifier+'.​'+ extensionType );
+ }
         return url;
     }
 
     
     
     /**
- * Get url of maven resource based on resource string such as : /m2:groupId:artifact​Id:version:extension​Type
+ * Get url of maven resource based on resource string such as : /m2:groupId:artifact​Id:version[:classifi​er]:extensionType
      * @return the POM URL
      * @throws MalformedURLException
      */
@@ -69,8 +76,13 @@
         String groupId = parts[1];
         String artifactId = parts[2];
         String version = parts[3];
- String extensionType = parts[4];
- URL url = getResourceURL( repository, groupId, artifactId, version, extensionType );
+ String classifier = null;
+ if( parts.length > 5 )
+ {
+ classifier = parts[4];
+ }
+ String extensionType = parts[parts.length-1];
+ URL url = getResourceURL( repository, groupId, artifactId, version, classifier, extensionType );
         return url;
     }

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r103 - trunk/pomstrap/src/main/java/org/tigris/pomstrap alag Alexis Agahi 2008-06-10 02:42:55 PDT
Messages per page: