You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by fg...@apache.org on 2006/11/26 14:30:34 UTC

svn commit: r479358 - in /maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse: InstallPluginsMojo.java MakeArtifactsMojo.java

Author: fgiust
Date: Sun Nov 26 05:30:33 2006
New Revision: 479358

URL: http://svn.apache.org/viewvc?view=rev&rev=479358
Log:
- fix NPE in stripQualifier when version range is null
- add a new "forceQualifier" parameter

Modified:
    maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/InstallPluginsMojo.java
    maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/MakeArtifactsMojo.java

Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/InstallPluginsMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/InstallPluginsMojo.java?view=diff&rev=479358&r1=479357&r2=479358
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/InstallPluginsMojo.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/InstallPluginsMojo.java Sun Nov 26 05:30:33 2006
@@ -251,7 +251,8 @@
         Attributes attributes = null;
         try
         {
-            JarFile jar = new JarFile( artifact.getFile() );
+            // don't verify, plugins zipped by eclipse:make-artifacts could have a bad signature
+            JarFile jar = new JarFile( artifact.getFile(), false );
             Manifest manifest = jar.getManifest();
             attributes = manifest.getMainAttributes();
         }

Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/MakeArtifactsMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/MakeArtifactsMojo.java?view=diff&rev=479358&r1=479357&r2=479358
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/MakeArtifactsMojo.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/MakeArtifactsMojo.java Sun Nov 26 05:30:33 2006
@@ -143,6 +143,15 @@
     private boolean stripQualifier;
 
     /**
+     * Default token to use as a qualifier. Tipically qualifiers for plugins in the same eclipse build are different.
+     * This parameter can be used to "align" qualifiers so that all the plugins coming from the same eclipse build can
+     * be easily identified. For example, setting this to "M3" will force the pluging versions to be "*.*.*.M3"
+     * 
+     * @parameter expression="${forcedQualifier}"
+     */
+    private String forcedQualifier;
+
+    /**
      * Specifies a remote repository to which generated artifacts should be deployed to. If this property is specified,
      * artifacts are also deployed to the remote repo.
      * The format for this parameter is <code>id::layout::url</code>
@@ -259,7 +268,8 @@
         {
             try
             {
-                JarFile jar = new JarFile( file );
+                // don't verify, jars created from unzipped plugin could have a bad signature
+                JarFile jar = new JarFile( file, false );
                 manifest = jar.getManifest();
                 pluginProperties = loadPluginProperties( jar );
             }
@@ -300,7 +310,11 @@
             return;
         }
 
-        if ( stripQualifier && StringUtils.countMatches( version, "." ) > 2 )
+        if ( StringUtils.isNotEmpty( forcedQualifier ) && StringUtils.countMatches( version, "." ) > 2 )
+        {
+            version = StringUtils.substring( version, 0, version.lastIndexOf( "." ) ) + "." + forcedQualifier;
+        }
+        else if ( stripQualifier && StringUtils.countMatches( version, "." ) > 2 )
         {
             version = StringUtils.substring( version, 0, version.lastIndexOf( "." ) );
         }
@@ -538,16 +552,15 @@
                 }
             }
 
-            if ( addQualifier )
-            {
-                version = addQualifierToVersionsInRange( version );
-            }
-
             if ( version == null )
             {
                 getLog().info( "Missing version for artifact " + artifactId + ", assuming any version > 0" );
                 version = "[0.0.0.0,)";
             }
+            else if ( addQualifier )
+            {
+                version = addQualifierToVersionsInRange( version );
+            }
 
             Dependency dep = new Dependency();
             dep.setArtifactId( artifactId );
@@ -572,6 +585,12 @@
      */
     protected String addQualifierToVersionsInRange( String versionRange )
     {
+        // should not be called with a null versionRange, but a check doesn't hurt...
+        if ( versionRange == null )
+        {
+            return null;
+        }
+
         StringBuffer newVersionRange = new StringBuffer();
 
         Matcher matcher = VERSION_PATTERN.matcher( versionRange );