sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1142589 - in /sling/trunk/maven/maven-launchpad-plugin/src/main: java/org/apache/sling/maven/projectsupport/ java/org/apache/sling/maven/projectsupport/bundlelist/ mdo/
Date Mon, 04 Jul 2011 08:54:15 GMT
Author: cziegeler
Date: Mon Jul  4 08:54:14 2011
New Revision: 1142589

URL: http://svn.apache.org/viewvc?rev=1142589&view=rev
Log:
SLING-2124 : Improve support for OSGi installer by distinguishing between bootstrap and app
bundles

Modified:
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadFrameworkMojo.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateBundleJarMojo.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseStartLevel.java
    sling/trunk/maven/maven-launchpad-plugin/src/main/mdo/bundle-list.xml

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadFrameworkMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadFrameworkMojo.java?rev=1142589&r1=1142588&r2=1142589&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadFrameworkMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadFrameworkMojo.java
Mon Jul  4 08:54:14 2011
@@ -45,12 +45,29 @@ public abstract class AbstractLaunchpadF
      *
      * @parameter default-value="bundles"
      */
-    protected String bundlesDirectory;
+    private String bundlesDirectory;
+
+    /**
+     * The directory which contains the bootstraop bundle directories.
+     *
+     * @parameter
+     */
+    private String bootDirectory;
+
+    protected String getPathForArtifact(final int startLevel, final String artifactName)
{
+        if ( startLevel == -1 && bootDirectory != null ) {
+            return String.format("%s/%s/%s", baseDestination, bootDirectory,
+                    artifactName);
+        }
+        return String.format("%s/%s/%s/%s", baseDestination, bundlesDirectory,
+                (startLevel == -1 ? 1 : startLevel),
+                artifactName);
+    }
 
     protected void copyBundles(BundleList bundles, File outputDirectory) throws MojoExecutionException
{
         for (StartLevel startLevel : bundles.getStartLevels()) {
             for (Bundle bundle : startLevel.getBundles()) {
-                copy(new ArtifactDefinition(bundle, startLevel.getLevel()), outputDirectory);
+                copy(new ArtifactDefinition(bundle, startLevel.getStartLevel()), outputDirectory);
             }
         }
     }
@@ -61,8 +78,7 @@ public abstract class AbstractLaunchpadF
     }
 
     protected void copy(File file, int startLevel, File outputDirectory) throws MojoExecutionException
{
-        File destination = new File(outputDirectory, String.format("%s/%s/%s/%s", baseDestination,
bundlesDirectory,
-                startLevel, file.getName()));
+        File destination = new File(outputDirectory, getPathForArtifact(startLevel, file.getName().replace('/',
File.separatorChar)));
         if (shouldCopy(file, destination)) {
             getLog().info(String.format("Copying bundle from %s to %s", file.getPath(), destination.getPath()));
             try {

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java?rev=1142589&r1=1142588&r2=1142589&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/AbstractLaunchpadStartingMojo.java
Mon Jul  4 08:54:14 2011
@@ -155,7 +155,7 @@ public abstract class AbstractLaunchpadS
                     int i = Integer.parseInt(startLevel);
                     List<String> bundles = new ArrayList<String>();
                     for (StartLevel level : getBundleList().getStartLevels()) {
-                        if (level.getLevel() == i) {
+                        if (level.getStartLevel() == i) {
                             for (Bundle bundle : level.getBundles()) {
                                 ArtifactDefinition d = new ArtifactDefinition(bundle, i);
                                 try {

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateBundleJarMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateBundleJarMojo.java?rev=1142589&r1=1142588&r2=1142589&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateBundleJarMojo.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/CreateBundleJarMojo.java
Mon Jul  4 08:54:14 2011
@@ -80,10 +80,8 @@ public class CreateBundleJarMojo extends
 		for (StartLevel level : bundles.getStartLevels()) {
 			for (Bundle bundle : level.getBundles()) {
 				Artifact artifact = getArtifact(new ArtifactDefinition(bundle,
-						level.getLevel()));
-				String destFileName = baseDestination + "/" + bundlesDirectory
-						+ "/" + level.getLevel() + "/"
-						+ artifact.getFile().getName();
+						level.getStartLevel()));
+				final String destFileName = getPathForArtifact(level.getStartLevel(), artifact.getFile().getName());
 				try {
 					jarArchiver.addFile(artifact.getFile(), destFileName);
 				} catch (ArchiverException e) {

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java?rev=1142589&r1=1142588&r2=1142589&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseBundleList.java
Mon Jul  4 08:54:14 2011
@@ -84,7 +84,7 @@ public abstract class BaseBundleList {
             if ( mergeStartLevel == null || newBnd.getStartLevel() > 0) {
                 startLevel = getOrCreateStartLevel(newBnd.getStartLevel());
             } else {
-                startLevel = getOrCreateStartLevel(mergeStartLevel.getLevel());
+                startLevel = getOrCreateStartLevel(mergeStartLevel.getStartLevel());
             }
             startLevel.getBundles().add(newBnd);
         }
@@ -93,14 +93,14 @@ public abstract class BaseBundleList {
 
     private StartLevel getOrCreateStartLevel(int startLevel) {
         for (StartLevel sl : getStartLevels()) {
-            if (sl.getLevel() == startLevel) {
+            if (sl.getStartLevel() == startLevel) {
                 return sl;
             }
         }
 
         StartLevel sl = new StartLevel();
         getStartLevels().add(sl);
-        sl.setLevel(startLevel);
+        sl.setRawLevel(startLevel);
         return sl;
     }
 

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseStartLevel.java
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseStartLevel.java?rev=1142589&r1=1142588&r2=1142589&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseStartLevel.java
(original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/java/org/apache/sling/maven/projectsupport/bundlelist/BaseStartLevel.java
Mon Jul  4 08:54:14 2011
@@ -23,8 +23,12 @@ import org.apache.sling.maven.projectsup
 
 public abstract class BaseStartLevel {
 
+    private static final String BOOT_MARKER = "boot";
+
     public abstract List<Bundle> getBundles();
 
+    private int startLevel;
+
     public boolean removeBundle(Bundle bundle, boolean compareVersions) {
         for (ListIterator<Bundle> it = getBundles().listIterator(); it.hasNext();)
{
             if (isSameArtifact(bundle, it.next(), compareVersions)) {
@@ -57,4 +61,31 @@ public abstract class BaseStartLevel {
                 && bundle1.getGroupId().equals(bundle2.getGroupId()) && bundle1.getType().equals(bundle2.getType());
     }
 
+    /**
+     * Set the level field.
+     *
+     * @param level
+     */
+    public void setLevel( final String level ) {
+        if ( BOOT_MARKER.equalsIgnoreCase(level) ) {
+            this.startLevel = -1;
+        } else {
+            this.startLevel = Integer.valueOf(level);
+            if ( this.startLevel < 0 ) {
+                throw new IllegalArgumentException("Start level must either be '" + BOOT_MARKER
+ "' or non-negative: " + level);
+            }
+        }
+    }
+
+    public void setRawLevel( final int level ) {
+        this.startLevel = level;
+    }
+
+    public String getLevel() {
+        return String.valueOf(this.startLevel);
+    }
+
+    public int getStartLevel() {
+        return this.startLevel;
+    }
 }

Modified: sling/trunk/maven/maven-launchpad-plugin/src/main/mdo/bundle-list.xml
URL: http://svn.apache.org/viewvc/sling/trunk/maven/maven-launchpad-plugin/src/main/mdo/bundle-list.xml?rev=1142589&r1=1142588&r2=1142589&view=diff
==============================================================================
--- sling/trunk/maven/maven-launchpad-plugin/src/main/mdo/bundle-list.xml (original)
+++ sling/trunk/maven/maven-launchpad-plugin/src/main/mdo/bundle-list.xml Mon Jul  4 08:54:14
2011
@@ -52,10 +52,10 @@
             <version>1.0.0</version>
             <superClass>org.apache.sling.maven.projectsupport.bundlelist.BaseStartLevel</superClass>
             <fields>
-            	<field xml.attribute="true">
+            	<field xml.attribute="true" java.setter="false" java.getter="false">
             		<name>level</name>
             		<version>1.0.0</version>
-            		<type>int</type>
+            		<type>String</type>
             	</field>
                 <field>
                     <name>bundles</name>



Mime
View raw message