You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2019/02/28 22:25:31 UTC

svn commit: r1854551 - in /felix/trunk/tools/maven-bundle-plugin/src: main/java/org/apache/felix/bundleplugin/ test/java/org/apache/felix/bundleplugin/

Author: gnodet
Date: Thu Feb 28 22:25:31 2019
New Revision: 1854551

URL: http://svn.apache.org/viewvc?rev=1854551&view=rev
Log:
[FELIX-6074] Do not analyze dependencies before the upToDate check

Modified:
    felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java
    felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
    felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/InstructionsPlugin.java
    felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
    felix/trunk/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java

Modified: felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java?rev=1854551&r1=1854550&r2=1854551&view=diff
==============================================================================
--- felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java (original)
+++ felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/AntPlugin.java Thu Feb 28 22:25:31 2019
@@ -50,7 +50,7 @@ public class AntPlugin extends BundlePlu
 
     @Override
     protected void execute( Map<String, String> originalInstructions,
-        Jar[] classpath ) throws MojoExecutionException
+        ClassPathItem[] classpath ) throws MojoExecutionException
     {
         final String artifactId = getProject().getArtifactId();
         final String baseDir = getProject().getBasedir().getPath();

Modified: felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java?rev=1854551&r1=1854550&r2=1854551&view=diff
==============================================================================
--- felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java (original)
+++ felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java Thu Feb 28 22:25:31 2019
@@ -426,7 +426,7 @@ public class BundlePlugin extends Abstra
 
 
     protected void execute(Map<String, String> originalInstructions,
-                           Jar[] classpath) throws MojoExecutionException
+                           ClassPathItem[] classpath) throws MojoExecutionException
     {
         try
         {
@@ -512,7 +512,7 @@ public class BundlePlugin extends Abstra
 
 
     protected Builder getOSGiBuilder( MavenProject currentProject, Map<String, String> originalInstructions,
-        Jar[] classpath ) throws Exception
+        ClassPathItem[] classpath ) throws Exception
     {
         Properties properties = new Properties();
         properties.putAll( getDefaultProperties( currentProject ) );
@@ -589,7 +589,11 @@ public class BundlePlugin extends Abstra
         builder.setProperties( sanitize( properties ) );
         if ( classpath != null )
         {
-            builder.setClasspath( classpath );
+            Jar[] jars = new Jar[ classpath.length ];
+            for ( int i = 0; i < classpath.length; i++ ) {
+                jars[i] = new Jar( classpath[i].id, classpath[i].file );
+            }
+            builder.setClasspath( jars );
         }
 
         return builder;
@@ -916,7 +920,7 @@ public class BundlePlugin extends Abstra
 
 
     protected Builder buildOSGiBundle(MavenProject currentProject, Map<String, String> originalInstructions,
-                                      Jar[] classpath) throws Exception
+                                      ClassPathItem[] classpath) throws Exception
     {
         Builder builder = getOSGiBuilder( currentProject, originalInstructions, classpath );
 
@@ -1574,14 +1578,14 @@ public class BundlePlugin extends Abstra
     }
 
 
-    protected Jar[] getClasspath(MavenProject currentProject) throws IOException, MojoExecutionException
+    protected ClassPathItem[] getClasspath(MavenProject currentProject) throws IOException, MojoExecutionException
     {
-        List<Jar> list = new ArrayList<Jar>( currentProject.getArtifacts().size() + 1 );
+        List<ClassPathItem> list = new ArrayList<ClassPathItem>( currentProject.getArtifacts().size() + 1 );
 
         String d = currentProject.getBuild() != null ? currentProject.getBuild().getOutputDirectory() : null;
         if ( d != null )
         {
-            list.add( new Jar( ".", d ) );
+            list.add( new ClassPathItem( ".", new File( d ) ) );
         }
 
         final Collection<Artifact> artifacts = getSelectedDependencies(currentProject.getArtifacts() );
@@ -1597,11 +1601,11 @@ public class BundlePlugin extends Abstra
                                     + currentProject.getArtifact() );
                     continue;
                 }
-                Jar jar = new Jar( artifact.getArtifactId(), file );
+                ClassPathItem jar = new ClassPathItem( artifact.getArtifactId(), file );
                 list.add( jar );
             }
         }
-        Jar[] cp = new Jar[list.size()];
+        ClassPathItem[] cp = new ClassPathItem[list.size()];
         list.toArray( cp );
 
         return cp;
@@ -2139,4 +2143,13 @@ public class BundlePlugin extends Abstra
         analyzer.setProperty(Analyzer.FIXUPMESSAGES, fixups);
     }
 
+    static class ClassPathItem {
+        final String id;
+        final File file;
+
+        public ClassPathItem(String id, File file) {
+            this.id = id;
+            this.file = file;
+        }
+    }
 }

Modified: felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/InstructionsPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/InstructionsPlugin.java?rev=1854551&r1=1854550&r2=1854551&view=diff
==============================================================================
--- felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/InstructionsPlugin.java (original)
+++ felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/InstructionsPlugin.java Thu Feb 28 22:25:31 2019
@@ -40,7 +40,7 @@ import org.apache.maven.shared.dependenc
 public class InstructionsPlugin extends BundlePlugin
 {
     @Override
-    protected void execute( Map<String, String> instructions, Jar[] classpath )
+    protected void execute( Map<String, String> instructions, ClassPathItem[] classpath )
         throws MojoExecutionException
     {
         if ( dumpInstructions == null )

Modified: felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java?rev=1854551&r1=1854550&r2=1854551&view=diff
==============================================================================
--- felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java (original)
+++ felix/trunk/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/ManifestPlugin.java Thu Feb 28 22:25:31 2019
@@ -91,7 +91,7 @@ public class ManifestPlugin extends Bund
     private BuildContext buildContext;
 
     @Override
-    protected void execute( Map<String, String> instructions, Jar[] classpath )
+    protected void execute( Map<String, String> instructions, ClassPathItem[] classpath )
         throws MojoExecutionException
     {
 
@@ -180,14 +180,14 @@ public class ManifestPlugin extends Bund
         return scanner.getIncludedFiles().length > 0;
     }
 
-    public Manifest getManifest( MavenProject project, Jar[] classpath ) throws IOException, MojoFailureException,
+    public Manifest getManifest( MavenProject project, ClassPathItem[] classpath ) throws IOException, MojoFailureException,
         MojoExecutionException, Exception
     {
         return getManifest( project, new LinkedHashMap<String, String>(), classpath, buildContext );
     }
 
 
-    public Manifest getManifest( MavenProject project, Map<String, String> instructions, Jar[] classpath,
+    public Manifest getManifest( MavenProject project, Map<String, String> instructions, ClassPathItem[] classpath,
             BuildContext buildContext ) throws IOException, MojoFailureException, MojoExecutionException, Exception
     {
         Analyzer analyzer = getAnalyzer(project, instructions, classpath);
@@ -249,14 +249,14 @@ public class ManifestPlugin extends Bund
         }
     }
 
-    protected Analyzer getAnalyzer( MavenProject project, Jar[] classpath ) throws IOException, MojoExecutionException,
+    protected Analyzer getAnalyzer( MavenProject project, ClassPathItem[] classpath ) throws IOException, MojoExecutionException,
         Exception
     {
         return getAnalyzer( project, new LinkedHashMap<>(), classpath );
     }
 
 
-    protected Analyzer getAnalyzer( MavenProject project, Map<String, String> instructions, Jar[] classpath )
+    protected Analyzer getAnalyzer( MavenProject project, Map<String, String> instructions, ClassPathItem[] classpath )
         throws IOException, MojoExecutionException, Exception
     {
         if ( rebuildBundle && supportedProjectTypes.contains( project.getArtifact().getType() ) )

Modified: felix/trunk/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java?rev=1854551&r1=1854550&r2=1854551&view=diff
==============================================================================
--- felix/trunk/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java (original)
+++ felix/trunk/tools/maven-bundle-plugin/src/test/java/org/apache/felix/bundleplugin/BundlePluginTest.java Thu Feb 28 22:25:31 2019
@@ -31,6 +31,7 @@ import java.util.Set;
 import java.util.TreeMap;
 import java.util.jar.Manifest;
 
+import org.apache.felix.bundleplugin.BundlePlugin.ClassPathItem;
 import org.apache.maven.model.Organization;
 import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.apache.maven.project.MavenProject;
@@ -346,7 +347,7 @@ public class BundlePluginTest extends Ab
         MavenProject project = getMavenProjectStub();
         project.setDependencyArtifacts(artifacts);
         Properties props = new Properties();
-        Jar[] classpath = plugin.getClasspath(project);
+        ClassPathItem[] classpath = plugin.getClasspath(project);
 
         Map instructions1 = new HashMap();
         instructions1.put( DependencyEmbedder.EMBED_DEPENDENCY, "!scope=compile" );