incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1589176 - in /sling/trunk/contrib/crankstart: ./ api/src/main/java/org/apache/sling/crankstart/api/ core/ core/src/main/java/org/apache/sling/crankstart/ core/src/main/java/org/apache/sling/crankstart/core/ core/src/main/java/org/apache/sl...
Date Tue, 22 Apr 2014 15:38:21 GMT
Author: bdelacretaz
Date: Tue Apr 22 15:38:20 2014
New Revision: 1589176

URL: http://svn.apache.org/r1589176
Log:
Get OSGi dependencies from Maven repository as well

Added:
    sling/trunk/contrib/crankstart/api/src/main/java/org/apache/sling/crankstart/api/CrankstartConstants.java
    sling/trunk/contrib/crankstart/core/
      - copied from r1589096, sling/trunk/contrib/crankstart/launcher/
    sling/trunk/contrib/crankstart/core/pom.xml
      - copied, changed from r1589114, sling/trunk/contrib/crankstart/launcher/pom.xml
    sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/
      - copied from r1589114, sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/launcher/
Removed:
    sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/CrankstartFileProcessor.java
    sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/Main.java
    sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/Main.java
    sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/launcher/CrankstartFileProcessor.java
    sling/trunk/contrib/crankstart/launcher/src/test/
Modified:
    sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartFileProcessor.java
    sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/InstallBundle.java
    sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/Log.java
    sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/SetOsgiFrameworkProperty.java
    sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/StartBundles.java
    sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/StartFramework.java
    sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/U.java
    sling/trunk/contrib/crankstart/launcher/default.crank.txt
    sling/trunk/contrib/crankstart/launcher/pom.xml
    sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/launcher/Main.java
    sling/trunk/contrib/crankstart/pom.xml

Added: sling/trunk/contrib/crankstart/api/src/main/java/org/apache/sling/crankstart/api/CrankstartConstants.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/api/src/main/java/org/apache/sling/crankstart/api/CrankstartConstants.java?rev=1589176&view=auto
==============================================================================
--- sling/trunk/contrib/crankstart/api/src/main/java/org/apache/sling/crankstart/api/CrankstartConstants.java
(added)
+++ sling/trunk/contrib/crankstart/api/src/main/java/org/apache/sling/crankstart/api/CrankstartConstants.java
Tue Apr 22 15:38:20 2014
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.crankstart.api;
+
+public class CrankstartConstants {
+    public static final String CRANKSTART_INPUT_FILENAME = "crankstart.input.filename";
+}
\ No newline at end of file

Copied: sling/trunk/contrib/crankstart/core/pom.xml (from r1589114, sling/trunk/contrib/crankstart/launcher/pom.xml)
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/pom.xml?p2=sling/trunk/contrib/crankstart/core/pom.xml&p1=sling/trunk/contrib/crankstart/launcher/pom.xml&r1=1589114&r2=1589176&rev=1589176&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/launcher/pom.xml (original)
+++ sling/trunk/contrib/crankstart/core/pom.xml Tue Apr 22 15:38:20 2014
@@ -11,15 +11,15 @@
     </parent>
 
     <groupId>org.apache.sling</groupId>
-    <artifactId>org.apache.sling.crankstart.launcher</artifactId>
+    <artifactId>org.apache.sling.crankstart.core</artifactId>
     <packaging>jar</packaging>
     <version>0.0.1-SNAPSHOT</version>
 
-    <name>Apache Sling Crankstart Launcher</name>
+    <name>Apache Sling Crankstart Core</name>
     <inceptionYear>2014</inceptionYear>
     
     <description>
-        A different way of starting Sling
+        A different way of starting Sling - core module
     </description>
 
     <properties>
@@ -28,38 +28,7 @@
  
     <build>
         <plugins>
-             <plugin>
-               <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
-                <configuration>
-                    <archive>
-                        <manifest>
-                            <mainClass>org.apache.sling.crankstart.launcher.Main</mainClass>
-                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
-                        </manifest>
-                    </archive>
-                </configuration>
-            </plugin>
-             <plugin>
-             <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>embed-dependencies</id>
-                        <goals>
-                            <goal>unpack-dependencies</goal>
-                        </goals>
-                        <configuration>
-                            <includeGroupIds>org.osgi,org.apache.felix,org.slf4j,javax.servlet,org.ops4j.pax.url,org.apache.sling</includeGroupIds>
-                            <excludeTransitive>false</excludeTransitive>
-                            <outputDirectory>${project.build.directory}/classes</outputDirectory>
-                            <overWriteReleases>false</overWriteReleases>
-                            <overWriteSnapshots>false</overWriteSnapshots>
-                        </configuration>
-                    </execution>
-                </executions>
-             </plugin>
-           <plugin>
+            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
@@ -67,20 +36,6 @@
                     <target>1.6</target>
                 </configuration>
             </plugin>
-            <plugin>
-                <artifactId>maven-clean-plugin</artifactId>
-                <version>2.2</version>
-                <configuration>
-                    <filesets>
-                        <fileset>
-                            <directory>${basedir}</directory>
-                            <includes>
-                                <include>felix-cache</include>
-                            </includes>
-                        </fileset>
-                    </filesets>
-                </configuration>
-            </plugin>
           </plugins>
     </build>   
 
@@ -107,18 +62,19 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
             <version>1.6.2</version>
+            <scope>provided</scope>
         </dependency>
          <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-simple</artifactId>
             <version>1.6.2</version>
-            <scope>test</scope>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.url</groupId>
             <artifactId>pax-url-aether</artifactId>
             <version>${pax.url.version}</version>
-            <scope>test</scope>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.url</groupId>

Modified: sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartFileProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartFileProcessor.java?rev=1589176&r1=1589114&r2=1589176&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartFileProcessor.java
(original)
+++ sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/CrankstartFileProcessor.java
Tue Apr 22 15:38:20 2014
@@ -14,34 +14,37 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.crankstart.launcher;
+package org.apache.sling.crankstart.core;
 
 import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.Callable;
 
 import org.apache.sling.crankstart.api.CrankstartCommand;
+import org.apache.sling.crankstart.api.CrankstartConstants;
 import org.apache.sling.crankstart.api.CrankstartContext;
-import org.apache.sling.crankstart.launcher.commands.InstallBundle;
-import org.apache.sling.crankstart.launcher.commands.Log;
-import org.apache.sling.crankstart.launcher.commands.SetOsgiFrameworkProperty;
-import org.apache.sling.crankstart.launcher.commands.StartBundles;
-import org.apache.sling.crankstart.launcher.commands.StartFramework;
+import org.apache.sling.crankstart.core.commands.InstallBundle;
+import org.apache.sling.crankstart.core.commands.Log;
+import org.apache.sling.crankstart.core.commands.SetOsgiFrameworkProperty;
+import org.apache.sling.crankstart.core.commands.StartBundles;
+import org.apache.sling.crankstart.core.commands.StartFramework;
 import org.osgi.framework.BundleException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /** Process a crankstart file */
-public class CrankstartFileProcessor {
+public class CrankstartFileProcessor implements Callable<Object> {
     private final CrankstartContext crankstartContext = new CrankstartContext();
     private final Logger log = LoggerFactory.getLogger(getClass());
     private List<CrankstartCommand> commands = new ArrayList<CrankstartCommand>();
     
     public CrankstartFileProcessor() {
-        System.setProperty( "java.protocol.handler.pkgs", "org.ops4j.pax.url" );
-        
         commands.add(new InstallBundle());
         commands.add(new Log());
         commands.add(new SetOsgiFrameworkProperty());
@@ -49,6 +52,16 @@ public class CrankstartFileProcessor {
         commands.add(new StartFramework());
     }
     
+    public Object call() throws FileNotFoundException, IOException, BundleException,InterruptedException
{
+        final String inputFilename = System.getProperty(CrankstartConstants.CRANKSTART_INPUT_FILENAME);
+        if(inputFilename == null) {
+            throw new IllegalStateException("Missing system property " + CrankstartConstants.CRANKSTART_INPUT_FILENAME);
+        }
+        process(new FileReader(new File(inputFilename)));
+        waitForExit();
+        return null;
+    }
+    
     public void process(Reader input) throws IOException, BundleException {
         final BufferedReader r = new BufferedReader(input);
         String line = null;

Modified: sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/InstallBundle.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/InstallBundle.java?rev=1589176&r1=1589114&r2=1589176&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/InstallBundle.java
(original)
+++ sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/InstallBundle.java
Tue Apr 22 15:38:20 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.crankstart.launcher.commands;
+package org.apache.sling.crankstart.core.commands;
 
 import java.io.InputStream;
 import java.net.URL;
@@ -38,13 +38,12 @@ public class InstallBundle implements Cr
     @Override
     public void execute(CrankstartContext crankstartContext, String commandLine) throws Exception
{
         final String bundleRef = U.removePrefix(I_BUNDLE, commandLine);
-        final URL url = new URL( "mvn:" + bundleRef);
+        final URL url = new URL(bundleRef);
         final BundleContext ctx = crankstartContext.getOsgiFramework().getBundleContext();
-        final String ref = "crankstart://" + bundleRef;
         final InputStream bundleStream = url.openStream();
         try {
-            ctx.installBundle(ref, url.openStream());
-            log.info("bundle installed: {}", ref);
+            ctx.installBundle(bundleRef, url.openStream());
+            log.info("bundle installed: {}", bundleRef);
         } finally {
             bundleStream.close();
         }

Modified: sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/Log.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/Log.java?rev=1589176&r1=1589114&r2=1589176&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/Log.java
(original)
+++ sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/Log.java
Tue Apr 22 15:38:20 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.crankstart.launcher.commands;
+package org.apache.sling.crankstart.core.commands;
 
 import org.apache.sling.crankstart.api.CrankstartCommand;
 import org.apache.sling.crankstart.api.CrankstartContext;

Modified: sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/SetOsgiFrameworkProperty.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/SetOsgiFrameworkProperty.java?rev=1589176&r1=1589114&r2=1589176&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/SetOsgiFrameworkProperty.java
(original)
+++ sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/SetOsgiFrameworkProperty.java
Tue Apr 22 15:38:20 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.crankstart.launcher.commands;
+package org.apache.sling.crankstart.core.commands;
 
 import org.apache.sling.crankstart.api.CrankstartCommand;
 import org.apache.sling.crankstart.api.CrankstartContext;

Modified: sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/StartBundles.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/StartBundles.java?rev=1589176&r1=1589114&r2=1589176&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/StartBundles.java
(original)
+++ sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/StartBundles.java
Tue Apr 22 15:38:20 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.crankstart.launcher.commands;
+package org.apache.sling.crankstart.core.commands;
 
 import org.apache.sling.crankstart.api.CrankstartCommand;
 import org.apache.sling.crankstart.api.CrankstartContext;

Modified: sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/StartFramework.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/StartFramework.java?rev=1589176&r1=1589114&r2=1589176&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/StartFramework.java
(original)
+++ sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/StartFramework.java
Tue Apr 22 15:38:20 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.crankstart.launcher.commands;
+package org.apache.sling.crankstart.core.commands;
 
 import org.apache.sling.crankstart.api.CrankstartCommand;
 import org.apache.sling.crankstart.api.CrankstartContext;
@@ -34,8 +34,9 @@ public class StartFramework implements C
 
     @Override
     public void execute(CrankstartContext crankstartContext, String commandLine) throws Exception
{
-        // TODO get framework as a Maven artifact?
-        FrameworkFactory frameworkFactory = java.util.ServiceLoader.load(FrameworkFactory.class).iterator().next();
+        // TODO this should work
+        // FrameworkFactory frameworkFactory = java.util.ServiceLoader.load(FrameworkFactory.class).iterator().next();
+        final FrameworkFactory frameworkFactory = (FrameworkFactory)getClass().getClassLoader().loadClass("org.apache.felix.framework.FrameworkFactory").newInstance();
         crankstartContext.setOsgiFramework(frameworkFactory.newFramework(crankstartContext.getOsgiFrameworkProperties()));
         crankstartContext.getOsgiFramework().start();
         log.info("OSGi framework started");

Modified: sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/U.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/U.java?rev=1589176&r1=1589114&r2=1589176&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/U.java
(original)
+++ sling/trunk/contrib/crankstart/core/src/main/java/org/apache/sling/crankstart/core/commands/U.java
Tue Apr 22 15:38:20 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.crankstart.launcher.commands;
+package org.apache.sling.crankstart.core.commands;
 
 class U {
     static String removePrefix(String prefix, String line) {

Modified: sling/trunk/contrib/crankstart/launcher/default.crank.txt
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/launcher/default.crank.txt?rev=1589176&r1=1589175&r2=1589176&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/launcher/default.crank.txt (original)
+++ sling/trunk/contrib/crankstart/launcher/default.crank.txt Tue Apr 22 15:38:20 2014
@@ -1,21 +1,32 @@
 # Minimal webconsole example for the Sling crankstart launcher
 
-# OSGi framework properties
+# Set bootstrap classpath, mvn: protocol can be used
+classpath mvn:org.apache.felix/org.apache.felix.framework/4.4.0
+classpath mvn:org.osgi/org.osgi.compendium/4.2.0
+classpath mvn:org.slf4j/slf4j-api/1.6.2
+classpath mvn:org.slf4j/slf4j-simple/1.6.2
+classpath mvn:org.ops4j.pax.url/pax-url-aether/1.6.0
+classpath mvn:org.ops4j.pax.url/pax-url-commons/1.6.0
+
+# Except the bootstrap launcher, crankstart jars are also provided via classpath
+classpath mvn:org.apache.sling/org.apache.sling.crankstart.core/0.0.1-SNAPSHOT
+classpath mvn:org.apache.sling/org.apache.sling.crankstart.api/0.0.1-SNAPSHOT
+
+# Set OSGi framework properties
 osgi.property org.osgi.service.http.port 1234
 
 # Once OSGi properties are set, start the framework
 start.framework
 
 # Install a minimal set of bundles for now, just to 
-# demonstrate that we can start the webconsole
-# Crankstart gets bundles from a Maven repository, which
-# is not configurable for now.
-bundle org.apache.felix/org.apache.felix.configadmin/1.2.8
-bundle org.apache.felix/org.apache.felix.http.jetty/2.2.0
-bundle org.apache.felix/org.apache.felix.metatype/1.0.4
-bundle org.apache.felix/org.apache.felix.scr/1.6.0
-bundle org.apache.felix/org.apache.felix.webconsole/3.1.6
-bundle org.apache.sling/org.apache.sling.commons.log/2.1.2
+# demonstrate that we can start the webconsole.
+# mvn: protocol can be used.
+bundle mvn:org.apache.felix/org.apache.felix.configadmin/1.2.8
+bundle mvn:org.apache.felix/org.apache.felix.http.jetty/2.2.0
+bundle mvn:org.apache.felix/org.apache.felix.metatype/1.0.4
+bundle mvn:org.apache.felix/org.apache.felix.scr/1.6.0
+bundle mvn:org.apache.felix/org.apache.felix.webconsole/3.1.6
+bundle mvn:org.apache.sling/org.apache.sling.commons.log/2.1.2
 
 # Start all bundles and log a friendly message
 start.all.bundles

Modified: sling/trunk/contrib/crankstart/launcher/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/launcher/pom.xml?rev=1589176&r1=1589175&r2=1589176&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/launcher/pom.xml (original)
+++ sling/trunk/contrib/crankstart/launcher/pom.xml Tue Apr 22 15:38:20 2014
@@ -50,7 +50,7 @@
                             <goal>unpack-dependencies</goal>
                         </goals>
                         <configuration>
-                            <includeGroupIds>org.osgi,org.apache.felix,org.slf4j,javax.servlet,org.ops4j.pax.url,org.apache.sling</includeGroupIds>
+                            <includeGroupIds>org.slf4j,org.ops4j.pax.url</includeGroupIds>
                             <excludeTransitive>false</excludeTransitive>
                             <outputDirectory>${project.build.directory}/classes</outputDirectory>
                             <overWriteReleases>false</overWriteReleases>
@@ -85,21 +85,15 @@
     </build>   
 
     <dependencies>
-       <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.compendium</artifactId>
-            <version>4.2.0</version>
-            <scope>provided</scope>
-        </dependency>
         <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.framework</artifactId>
-            <version>4.0.0</version>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.crankstart.api</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.crankstart.api</artifactId>
+            <artifactId>org.apache.sling.crankstart.core</artifactId>
             <version>0.0.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
@@ -107,12 +101,13 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
             <version>1.6.2</version>
+            <scope>provided</scope>
         </dependency>
          <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-simple</artifactId>
             <version>1.6.2</version>
-            <scope>test</scope>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.url</groupId>
@@ -126,11 +121,5 @@
             <version>${pax.url.version}</version>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.11</version>
-            <scope>test</scope>
-        </dependency>
       </dependencies>
 </project>

Modified: sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/launcher/Main.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/launcher/Main.java?rev=1589176&r1=1589175&r2=1589176&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/launcher/Main.java
(original)
+++ sling/trunk/contrib/crankstart/launcher/src/main/java/org/apache/sling/crankstart/launcher/Main.java
Tue Apr 22 15:38:20 2014
@@ -16,12 +16,23 @@
  */
 package org.apache.sling.crankstart.launcher;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
+import java.io.IOException;
 import java.io.Reader;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+import org.apache.sling.crankstart.api.CrankstartConstants;
 
 /** Execute a crankstart file */
 public class Main {
+    public static final String CLASSPATH_PREFIX = "classpath ";
+    
     public static void main(String [] args) throws Exception {
         String crankFile = "default.crank.txt";
         if(args.length < 1) {
@@ -30,11 +41,32 @@ public class Main {
         } else {
             crankFile = args[0];
         }
-        final Reader r = new FileReader(new File(crankFile));
+        System.setProperty(CrankstartConstants.CRANKSTART_INPUT_FILENAME, crankFile);
+        System.setProperty( "java.protocol.handler.pkgs", "org.ops4j.pax.url" );
+        final URL [] launcherClasspath = getClasspath(crankFile);
+        
+        final URLClassLoader launcherClassloader = new URLClassLoader(launcherClasspath,
null);
+        final String callableClass = "org.apache.sling.crankstart.core.CrankstartFileProcessor";
+        
+        @SuppressWarnings("unchecked")
+        final Callable<Object> c = (Callable<Object>)launcherClassloader.loadClass(callableClass).newInstance();
+        c.call();
+    }
+    
+    private static URL[] getClasspath(String filename) throws IOException {
+        final List<URL> urls = new ArrayList<URL>();
+        final Reader input = new FileReader(new File(filename));
+        final BufferedReader r = new BufferedReader(input);
         try {
-            final CrankstartFileProcessor p = new CrankstartFileProcessor();
-            p.process(r);
-            p.waitForExit();
+            String line = null;
+            while((line = r.readLine()) != null) {
+                if(line.length() == 0 || line.startsWith("#")) {
+                    // ignore comments and blank lines
+                } else if(line.startsWith(CLASSPATH_PREFIX)){
+                    urls.add(new URL(line.substring(CLASSPATH_PREFIX.length()).trim()));
+                }
+            }
+            return urls.toArray(new URL[] {});
         } finally {
             r.close();
         }

Modified: sling/trunk/contrib/crankstart/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/crankstart/pom.xml?rev=1589176&r1=1589175&r2=1589176&view=diff
==============================================================================
--- sling/trunk/contrib/crankstart/pom.xml (original)
+++ sling/trunk/contrib/crankstart/pom.xml Tue Apr 22 15:38:20 2014
@@ -22,8 +22,28 @@
         A different way of starting Sling - reactor pom
     </description>
 
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-clean-plugin</artifactId>
+                <version>2.2</version>
+                <configuration>
+                    <filesets>
+                        <fileset>
+                            <directory>${basedir}</directory>
+                            <includes>
+                                <include>felix-cache</include>
+                            </includes>
+                        </fileset>
+                    </filesets>
+                </configuration>
+            </plugin>
+          </plugins>
+    </build>
+
     <modules>
       <module>api</module>
+      <module>core</module>
       <module>launcher</module>
     </modules>
 </project>



Mime
View raw message