You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2013/09/30 14:25:15 UTC

svn commit: r1527531 - in /sling/trunk/tooling/ide: artifacts/ artifacts/src/org/apache/sling/ide/artifacts/ artifacts/src/org/apache/sling/ide/artifacts/impl/ eclipse-m2e-ui/ eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/ eclipse-m2e-ui/src/org/...

Author: rombert
Date: Mon Sep 30 12:25:14 2013
New Revision: 1527531

URL: http://svn.apache.org/r1527531
Log:
SLING-3125 - Centralize and improve embedded artifact handling

Move all embedded artifacts into the .artifacts plug-in.

Modified:
    sling/trunk/tooling/ide/artifacts/build.properties
    sling/trunk/tooling/ide/artifacts/pom.xml
    sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifactLocator.java
    sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/impl/ArtifactsLocatorImpl.java
    sling/trunk/tooling/ide/eclipse-m2e-ui/build.properties
    sling/trunk/tooling/ide/eclipse-m2e-ui/pom.xml
    sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstaller.java
    sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java

Modified: sling/trunk/tooling/ide/artifacts/build.properties
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/artifacts/build.properties?rev=1527531&r1=1527530&r2=1527531&view=diff
==============================================================================
--- sling/trunk/tooling/ide/artifacts/build.properties (original)
+++ sling/trunk/tooling/ide/artifacts/build.properties Mon Sep 30 12:25:14 2013
@@ -2,5 +2,5 @@ source.. = src/
 output.. = bin/
 bin.includes = META-INF/,\
                .,\
-               target/sling-tooling-support-install/,\
-               OSGI-INF/
+               OSGI-INF/,\
+               target/artifacts/

Modified: sling/trunk/tooling/ide/artifacts/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/artifacts/pom.xml?rev=1527531&r1=1527530&r2=1527531&view=diff
==============================================================================
--- sling/trunk/tooling/ide/artifacts/pom.xml (original)
+++ sling/trunk/tooling/ide/artifacts/pom.xml Mon Sep 30 12:25:14 2013
@@ -30,9 +30,21 @@
                                     <groupId>org.apache.sling</groupId>
                                     <artifactId>org.apache.sling.tooling.support.install</artifactId>
                                     <version>0.0.1-SNAPSHOT</version>
-                                    <overWrite>false</overWrite>
-                                    <outputDirectory>${project.build.directory}/sling-tooling-support-install</outputDirectory>
+                                    <outputDirectory>${project.build.directory}/artifacts/sling-tooling-support-install</outputDirectory>
                                 </artifactItem>
+                                <artifactItem>
+                                  <groupId>org.apache.sling</groupId>
+                                  <artifactId>sling-bundle-archetype</artifactId>
+                                  <version>${sling-bundle-archetype.version}</version>
+                                  <outputDirectory>${project.build.directory}/artifacts/archetypes</outputDirectory>
+                                </artifactItem>
+                                <artifactItem>
+                                  <groupId>org.apache.sling</groupId>
+                                  <artifactId>sling-bundle-archetype</artifactId>
+                                  <version>${sling-bundle-archetype.version}</version>
+                                  <type>pom</type>
+                                  <outputDirectory>${project.build.directory}/artifacts/archetypes</outputDirectory>
+                                </artifactItem>                                
                             </artifactItems>
                             <overWriteReleases>false</overWriteReleases>
                             <overWriteSnapshots>true</overWriteSnapshots>
@@ -43,4 +55,7 @@
             </plugin>
         </plugins>
     </build>
+    <properties>
+        <sling-bundle-archetype.version>1.0.1-SNAPSHOT</sling-bundle-archetype.version>
+    </properties>
 </project>

Modified: sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifactLocator.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifactLocator.java?rev=1527531&r1=1527530&r2=1527531&view=diff
==============================================================================
--- sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifactLocator.java (original)
+++ sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifactLocator.java Mon Sep 30 12:25:14 2013
@@ -22,4 +22,9 @@ public interface EmbeddedArtifactLocator
 
     EmbeddedArtifact loadToolingSupportBundle();
 
+    /**
+     * @return a two-element array, where the first element is the pom artifact, and the second element is the jar
+     *         artifact
+     */
+    EmbeddedArtifact[] loadSlingBundleArchetype();
 }

Modified: sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/impl/ArtifactsLocatorImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/impl/ArtifactsLocatorImpl.java?rev=1527531&r1=1527530&r2=1527531&view=diff
==============================================================================
--- sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/impl/ArtifactsLocatorImpl.java (original)
+++ sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/impl/ArtifactsLocatorImpl.java Mon Sep 30 12:25:14 2013
@@ -25,6 +25,8 @@ import org.osgi.service.component.Compon
 
 public class ArtifactsLocatorImpl implements EmbeddedArtifactLocator {
 
+    private static final String ARTIFACTS_LOCATION = "target/artifacts";
+
     private ComponentContext context;
 
     protected void activate(ComponentContext context) {
@@ -38,16 +40,47 @@ public class ArtifactsLocatorImpl implem
 
         BundleContext bundleContext = context.getBundleContext();
 
+        String version = "0.0.1.SNAPSHOT"; // TODO - remove version hardcoding
         String artifactId = "org.apache.sling.tooling.support.install";
         String extension = "jar";
-        String resourceLocation = "target/sling-tooling-support-install/" + artifactId + "." + extension;
-        URL jarUrl = bundleContext.getBundle().getResource(resourceLocation);
-        String version = "0.0.1.SNAPSHOT"; // TODO - remove version hardcoding
-        if (jarUrl == null) {
-            throw new RuntimeException("Unable to locate bundle resource " + resourceLocation);
-        }
+
+        URL jarUrl = loadResource(bundleContext, ARTIFACTS_LOCATION + "/sling-tooling-support-install/" + artifactId
+                + "." + extension);
 
         return new EmbeddedArtifact(artifactId + "-" + version + "." + extension, version, jarUrl);
     }
 
+    @Override
+    public EmbeddedArtifact[] loadSlingBundleArchetype() {
+
+        BundleContext bundleContext = context.getBundleContext();
+
+        String version = "1.0.1-SNAPSHOT"; // TODO - remove version hardcoding
+        String artifactId = "sling-bundle-archetype";
+        String extension = "jar";
+
+        URL resourceUrl = loadResource(bundleContext, ARTIFACTS_LOCATION + "/archetypes/" + artifactId + "."
+                + extension);
+
+        EmbeddedArtifact jarArtifact = new EmbeddedArtifact(artifactId + "-" + version + "." + extension, version,
+                resourceUrl);
+
+        extension = "pom";
+        resourceUrl = loadResource(bundleContext, ARTIFACTS_LOCATION + "/archetypes/" + artifactId + "." + extension);
+
+        EmbeddedArtifact pomArtifact = new EmbeddedArtifact(artifactId + "-" + version + "." + extension, version,
+                resourceUrl);
+
+        return new EmbeddedArtifact[] { pomArtifact, jarArtifact };
+    }
+
+    private URL loadResource(BundleContext bundleContext, String resourceLocation) {
+
+        URL resourceUrl = bundleContext.getBundle().getResource(resourceLocation);
+        if (resourceUrl == null) {
+            throw new RuntimeException("Unable to locate bundle resource " + resourceLocation);
+        }
+        return resourceUrl;
+    }
+
 }

Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/build.properties
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/build.properties?rev=1527531&r1=1527530&r2=1527531&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/build.properties (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/build.properties Mon Sep 30 12:25:14 2013
@@ -1,6 +1,4 @@
 bin.includes = plugin.xml,\
                META-INF/,\
-               .,\
-               target/sling-tooling-support-install/,\
-               target/archetypes/
+               .
 source.. = src/

Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/pom.xml?rev=1527531&r1=1527530&r2=1527531&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/pom.xml (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/pom.xml Mon Sep 30 12:25:14 2013
@@ -19,81 +19,5 @@
         </excludes>
       </resource>
     </resources>
-    <plugins>
-	  <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-dependency-plugin</artifactId>
-        <version>2.8</version>
-        <executions>
-          <execution>
-            <id>copy</id>
-            <phase>compile</phase>
-            <goals>
-              <goal>copy</goal>
-            </goals>
-            <configuration>
-              <artifactItems>
-                <artifactItem>
-                  <groupId>org.apache.sling</groupId>
-                  <artifactId>org.apache.sling.tooling.support.install</artifactId>
-                  <version>0.0.1-SNAPSHOT</version>
-                  <overWrite>false</overWrite>
-                  <outputDirectory>${project.build.directory}/sling-tooling-support-install</outputDirectory>
-                </artifactItem>
-                <artifactItem>
-                  <groupId>org.apache.sling</groupId>
-                  <artifactId>sling-bundle-archetype</artifactId>
-                  <version>1.0.1-SNAPSHOT</version>
-                  <overWrite>false</overWrite>
-                  <outputDirectory>${project.build.directory}/archetypes</outputDirectory>
-                </artifactItem>
-                <artifactItem>
-                  <groupId>org.apache.sling</groupId>
-                  <artifactId>sling-bundle-archetype</artifactId>
-                  <version>1.0.1-SNAPSHOT</version>
-                  <type>pom</type>
-                  <overWrite>false</overWrite>
-                  <outputDirectory>${project.build.directory}/archetypes</outputDirectory>
-                </artifactItem>
-              </artifactItems>
-              <overWriteReleases>false</overWriteReleases>
-              <overWriteSnapshots>true</overWriteSnapshots>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-    <pluginManagement>
-    	<plugins>
-    		<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
-    		<plugin>
-    			<groupId>org.eclipse.m2e</groupId>
-    			<artifactId>lifecycle-mapping</artifactId>
-    			<version>1.0.0</version>
-    			<configuration>
-    				<lifecycleMappingMetadata>
-    					<pluginExecutions>
-    						<pluginExecution>
-    							<pluginExecutionFilter>
-    								<groupId>
-    									org.apache.maven.plugins
-    								</groupId>
-    								<artifactId>
-    									maven-dependency-plugin
-    								</artifactId>
-    								<versionRange>[2.8,)</versionRange>
-    								<goals>
-    									<goal>copy</goal>
-    								</goals>
-    							</pluginExecutionFilter>
-    							<action>
-    								<ignore></ignore>
-    							</action>
-    						</pluginExecution>
-    					</pluginExecutions>
-    				</lifecycleMappingMetadata>
-    			</configuration>
-    		</plugin>
-    	</plugins>
-    </pluginManagement>
-</build></project>
+</build>
+</project>

Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstaller.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstaller.java?rev=1527531&r1=1527530&r2=1527531&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstaller.java (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstaller.java Mon Sep 30 12:25:14 2013
@@ -84,6 +84,10 @@ public class EmbeddedArchetypeInstaller 
 	public void addResource(String fileExtension, URL origin) throws IOException {
 		origins.put(fileExtension, origin.openStream());
 	}
+
+    public void addResource(String fileExtension, InputStream inputStream) throws IOException {
+        origins.put(fileExtension, inputStream);
+    }
 	
 	public void addResource(String fileExtension, File origin) throws FileNotFoundException {
 		origins.put(fileExtension, new FileInputStream(origin));

Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java?rev=1527531&r1=1527530&r2=1527531&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/NewSlingBundleWizard.java Mon Sep 30 12:25:14 2013
@@ -17,9 +17,10 @@
 package org.apache.sling.ide.eclipse.ui.wizards.np;
 
 import java.io.IOException;
-import java.net.URL;
 
 import org.apache.maven.archetype.catalog.Archetype;
+import org.apache.sling.ide.artifacts.EmbeddedArtifact;
+import org.apache.sling.ide.artifacts.EmbeddedArtifactLocator;
 import org.apache.sling.ide.eclipse.m2e.EmbeddedArchetypeInstaller;
 import org.apache.sling.ide.eclipse.m2e.internal.Activator;
 import org.apache.sling.ide.eclipse.m2e.internal.SharedImages;
@@ -40,16 +41,18 @@ public class NewSlingBundleWizard extend
 
 	@Override
 	public void installArchetypes() {
-		// embedding the 1.0.1-SNAPSHOT cos the 1.0.0 doesn't include the pom
+
+        EmbeddedArtifactLocator artifactsLocator = Activator.getDefault().getArtifactsLocator();
+
+        // TODO - should we remove the special slingclipse-embedded artifact and simply install our version?
 	    EmbeddedArchetypeInstaller archetypeInstaller = new EmbeddedArchetypeInstaller(
 	    		"org.apache.sling", "sling-bundle-archetype", "slingclipse-embedded");
 	    try {
-	    	URL jarUrl = Activator.getDefault().getBundle().getResource(
-	    			"target/archetypes/sling-bundle-archetype-1.0.1-SNAPSHOT.jar");
-			archetypeInstaller.addResource("jar", jarUrl);
-			URL pomUrl = Activator.getDefault().getBundle().getResource(
-					"target/archetypes/sling-bundle-archetype-1.0.1-SNAPSHOT.pom");
-			archetypeInstaller.addResource("pom", pomUrl);
+
+            EmbeddedArtifact[] archetypeArtifacts = artifactsLocator.loadSlingBundleArchetype();
+
+            archetypeInstaller.addResource("pom", archetypeArtifacts[0].openInputStream());
+            archetypeInstaller.addResource("jar", archetypeArtifacts[1].openInputStream());
 			
 			archetypeInstaller.installArchetype();
 		} catch (IOException e) {