Author: baerrach
Date: Tue Sep 16 16:07:04 2008
New Revision: 696092

URL: http://svn.apache.org/viewvc?rev=696092&view=rev
Log:
[MECLIPSE-488] - Fixed eclipse:install issue if jar does not contain a Manifest.
Submitted by: Baptiste MATHUS

Added:
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/m2repo/eclipseinstall/jira/
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/m2repo/eclipseinstall/jira/meclipse/
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/m2repo/eclipseinstall/jira/meclipse/488/
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/m2repo/eclipseinstall/jira/meclipse/488/meclipse-488.jar
   (with props)
Modified:
    
maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/InstallPluginsMojo.java
    
maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/InstallPluginsMojoTest.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?rev=696092&r1=696091&r2=696092&view=diff
==============================================================================
--- 
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
 Tue Sep 16 16:07:04 2008
@@ -231,7 +231,8 @@
      * </p>
      * <ol>
      * <li>Determine whether the plugin should be extracted into a directory 
or not</li>
-     * <li>If the plugin's target location exists, or overwrite is set to 
true: <ol type="a">
+     * <li>If the plugin's target location exists, or overwrite is set to true:
+     * <ol type="a">
      * <li>if extract, ensure the plugin target location exists (mkdirs), and 
extract there.</li>
      * <li>copy the plugin file from the local repository to the target 
location</li>
      * </ol>
@@ -276,6 +277,13 @@
             // 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();
+            if ( manifest == null )
+            {
+                getLog().debug(
+                                "Ignoring " + artifact.getArtifactId()
+                                    + " as it is does not have a Manifest (and 
so is not an OSGi bundle)" );
+                return;
+            }
             attributes = manifest.getMainAttributes();
         }
         catch ( IOException e )
@@ -408,8 +416,8 @@
 
     /**
      * <p>
-     * Format the artifact information into an Eclipse-friendly plug-in name.
-     * Delegates to maven2OsgiConverter to obtain bundle symbolic name and 
version.
+     * Format the artifact information into an Eclipse-friendly plug-in name. 
Delegates to maven2OsgiConverter to obtain
+     * bundle symbolic name and version.
      * </p>
      */
     private String formatEclipsePluginName( Artifact artifact )

Modified: 
maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/InstallPluginsMojoTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/InstallPluginsMojoTest.java?rev=696092&r1=696091&r2=696092&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/InstallPluginsMojoTest.java
 (original)
+++ 
maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/InstallPluginsMojoTest.java
 Tue Sep 16 16:07:04 2008
@@ -55,9 +55,7 @@
 {
     private static final String TEST_M2_REPO = "m2repo/eclipseinstall/";
 
-    private static final Artifact ARTIFACT_ORG_ECLIPSE_CORE_RUNTIME =
-        new DefaultArtifact( "org.eclipse.core", "runtime", 
VersionRange.createFromVersion( "3.2.0-v20060603" ),
-                             "scope-unused", "eclipse-plugin", 
"classifier-unused", null );
+    private static Artifact ARTIFACT_ORG_ECLIPSE_CORE_RUNTIME;
 
     private TestFileManager fileManager;
 
@@ -88,6 +86,33 @@
         return new File( pluginsDir, formatEclipsePluginName( artifact ) + 
".jar" );
     }
 
+    public void testJira488()
+        throws MojoExecutionException, MojoFailureException
+    {
+        Artifact jira488_missingManifest =
+            createArtifact("jira", "meclipse", "488");
+
+        File pluginsDir = performTestInstall( null, false, 
jira488_missingManifest, "eclipse-plugin" );
+
+        File installedFile = locateInstalledFile( pluginsDir, 
ARTIFACT_ORG_ECLIPSE_CORE_RUNTIME );
+
+        File installedDir = locateInstalledDir( pluginsDir, 
ARTIFACT_ORG_ECLIPSE_CORE_RUNTIME );
+
+        assertFalse( installedFile + " should not exist as Jar has not 
Manifest.", installedFile.exists() );
+        assertFalse( installedDir + " should not exist.", 
installedDir.exists() );
+
+        mm.verifyAll();
+    }
+
+    private Artifact createArtifact(String groupId, String artifactId, String 
version)
+    {
+        Artifact artifact = new DefaultArtifact( groupId, artifactId, 
VersionRange.createFromVersion( version ), "scope-unused",
+                             "eclipse-plugin", "classifier-unused", null );
+        artifact.setFile( locateArtifact( artifact ) );
+
+        return artifact;
+    }
+
     public void testShouldInstallAsJarWhenPropertyNotSpecified()
         throws MojoExecutionException, MojoFailureException
     {
@@ -211,7 +236,8 @@
     {
         fileManager = new TestFileManager( "InstallPluginsMojo.test.", "" );
 
-        ARTIFACT_ORG_ECLIPSE_CORE_RUNTIME.setFile( locateArtifact( 
ARTIFACT_ORG_ECLIPSE_CORE_RUNTIME ) );
+        ARTIFACT_ORG_ECLIPSE_CORE_RUNTIME = createArtifact( 
"org.eclipse.core", "runtime", "3.2.0-v20060603" );
+
     }
 
     private File locateArtifact( Artifact artifact )
@@ -318,7 +344,8 @@
                 manager.getUnArchiver( (File) null );
                 control.setMatcher( MockControl.ALWAYS_MATCHER );
                 ZipUnArchiver zipUnArchiver = new ZipUnArchiver();
-                zipUnArchiver.enableLogging( new 
ConsoleLogger(org.codehaus.plexus.logging.Logger.LEVEL_INFO, "console") );
+                zipUnArchiver.enableLogging( new ConsoleLogger( 
org.codehaus.plexus.logging.Logger.LEVEL_INFO,
+                                                                "console" ) );
                 control.setReturnValue( zipUnArchiver, MockControl.ONE_OR_MORE 
);
             }
             catch ( NoSuchArchiverException e )

Added: 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/m2repo/eclipseinstall/jira/meclipse/488/meclipse-488.jar
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/m2repo/eclipseinstall/jira/meclipse/488/meclipse-488.jar?rev=696092&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
maven/plugins/trunk/maven-eclipse-plugin/src/test/resources/m2repo/eclipseinstall/jira/meclipse/488/meclipse-488.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream


Reply via email to