sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r902985 - /sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
Date Mon, 25 Jan 2010 21:39:32 GMT
Author: justin
Date: Mon Jan 25 21:39:32 2010
New Revision: 902985

URL: http://svn.apache.org/viewvc?rev=902985&view=rev
Log:
SLING-1322 - adding check to avoid loading launchpad artifact if it's the same as the current
project's

Modified:
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java?rev=902985&r1=902984&r2=902985&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractBundleListMojo.java
Mon Jan 25 21:39:32 2010
@@ -53,28 +53,28 @@
     /**
      * The name of the directory within the output directory into which the base
      * JAR should be installed.
-     * 
+     *
      * @parameter default-value="resources"
      */
     protected String baseDestination;
 
     /**
      * The directory which contains the start-level bundle directories.
-     * 
+     *
      * @parameter default-value="bundles"
      */
     protected String bundlesDirectory;
 
     /**
      * The definition of the defaultBundleList artifact.
-     * 
+     *
      * @parameter
      */
     private ArtifactDefinition defaultBundleList;
 
     /**
      * The definition of the defaultBundles package.
-     * 
+     *
      * @parameter
      */
     private ArtifactDefinition defaultBundles;
@@ -86,7 +86,7 @@
 
     /**
      * To look up Archiver/UnArchiver implementations
-     * 
+     *
      * @component
      */
     private ArchiverManager archiverManager;
@@ -98,7 +98,7 @@
 
     /**
      * The Maven project.
-     * 
+     *
      * @parameter expression="${project}"
      * @required
      * @readonly
@@ -107,14 +107,14 @@
 
     /**
      * Used to look up Artifacts in the remote repository.
-     * 
+     *
      * @component
      */
     private ArtifactFactory factory;
 
     /**
      * Location of the local repository.
-     * 
+     *
      * @parameter expression="${localRepository}"
      * @readonly
      * @required
@@ -133,7 +133,7 @@
 
     /**
      * List of Remote Repositories used by the resolver.
-     * 
+     *
      * @parameter expression="${project.remoteArtifactRepositories}"
      * @readonly
      * @required
@@ -142,7 +142,7 @@
 
     /**
      * Used to look up Artifacts in the remote repository.
-     * 
+     *
      * @component
      */
     private ArtifactResolver resolver;
@@ -252,7 +252,7 @@
         return readBundleList(bundleListFile);
     }
 
-    
+
     protected void outputBundleList(File outputDirectory)
             throws MojoExecutionException {
         try {
@@ -273,30 +273,39 @@
                                             bundleListFile), e);
         }
 
-        try {
-            Artifact artifact = getArtifact(defaultBundleList.getGroupId(),
-                    defaultBundleList.getArtifactId(), defaultBundleList
-                            .getVersion(), defaultBundleList.getType(),
-                    defaultBundleList.getClassifier());
-            getLog().info(
-                    "Using bundle list file from "
-                            + artifact.getFile().getAbsolutePath());
-            BundleList bundles = readBundleList(artifact.getFile());
-            copyBundles(bundles, outputDirectory);
-            return;
-        } catch (Exception e) {
-            getLog()
-                    .warn(
-                            "Unable to load bundle list from artifact. Falling back to bundle
jar",
-                            e);
+        if (!isCurrentArtifact(defaultBundleList)) {
+            try {
+                Artifact artifact = getArtifact(defaultBundleList.getGroupId(),
+                        defaultBundleList.getArtifactId(), defaultBundleList
+                                .getVersion(), defaultBundleList.getType(),
+                        defaultBundleList.getClassifier());
+                getLog().info(
+                        "Using bundle list file from "
+                                + artifact.getFile().getAbsolutePath());
+                BundleList bundles = readBundleList(artifact.getFile());
+                copyBundles(bundles, outputDirectory);
+                return;
+            } catch (Exception e) {
+                getLog()
+                        .warn(
+                                "Unable to load bundle list from artifact. Falling back to
bundle jar",
+                                e);
+            }
         }
 
-        Artifact defaultBundlesArtifact = getArtifact(defaultBundles
-                .getGroupId(), defaultBundles.getArtifactId(), defaultBundles
-                .getVersion(), defaultBundles.getType(), defaultBundles
-                .getClassifier());
-        unpack(defaultBundlesArtifact.getFile(), outputDirectory, null,
-                "META-INF/**");
+        if (!isCurrentArtifact(defaultBundleList)) {
+            Artifact defaultBundlesArtifact = getArtifact(defaultBundles
+                    .getGroupId(), defaultBundles.getArtifactId(),
+                    defaultBundles.getVersion(), defaultBundles.getType(),
+                    defaultBundles.getClassifier());
+            unpack(defaultBundlesArtifact.getFile(), outputDirectory, null,
+                    "META-INF/**");
+        }
+    }
+
+    private boolean isCurrentArtifact(ArtifactDefinition def) {
+        return (def.getGroupId().equals(project.getGroupId()) && def
+                .getArtifactId().equals(project.getArtifactId()));
     }
 
     private void copyBundles(BundleList bundles, File outputDirectory)



Mime
View raw message