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 2014/06/22 01:39:41 UTC
svn commit: r1604495 - in /sling/trunk/tooling/ide: artifacts/
artifacts/src/org/apache/sling/ide/artifacts/
artifacts/src/org/apache/sling/ide/artifacts/impl/
eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/ eclipse-m2e-ui/
eclipse-m2e-ui/META-I...
Author: rombert
Date: Sat Jun 21 23:39:40 2014
New Revision: 1604495
URL: http://svn.apache.org/r1604495
Log:
SLING-3592 - Remove embedded bundle archetype in favour of released
version
- no longer embed a bundle archetype
- better tracing and error reporting for the bundle wizard page
- only accept sling-bundle-archetype 1.0.2 or newer ( SNAPSHOTS included
)
Added:
sling/trunk/tooling/ide/eclipse-m2e-ui/.options
Modified:
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-test/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstallerTest.java
sling/trunk/tooling/ide/eclipse-m2e-ui/META-INF/MANIFEST.MF
sling/trunk/tooling/ide/eclipse-m2e-ui/build.properties
sling/trunk/tooling/ide/eclipse-m2e-ui/plugin.xml
sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/Activator.java
sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ChooseArchetypeWizardPage.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/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/artifacts/pom.xml?rev=1604495&r1=1604494&r2=1604495&view=diff
==============================================================================
--- sling/trunk/tooling/ide/artifacts/pom.xml (original)
+++ sling/trunk/tooling/ide/artifacts/pom.xml Sat Jun 21 23:39:40 2014
@@ -39,19 +39,6 @@
<version>1.0.0</version>
<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>
@@ -62,7 +49,4 @@
</plugin>
</plugins>
</build>
- <properties>
- <sling-bundle-archetype.version>1.0.2</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=1604495&r1=1604494&r2=1604495&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 Sat Jun 21 23:39:40 2014
@@ -21,10 +21,4 @@ public interface EmbeddedArtifactLocator
public static final String SUPPORT_BUNDLE_SYMBOLIC_NAME = "org.apache.sling.tooling.support.install";
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=1604495&r1=1604494&r2=1604495&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 Sat Jun 21 23:39:40 2014
@@ -50,30 +50,6 @@ public class ArtifactsLocatorImpl implem
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);
Modified: sling/trunk/tooling/ide/eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstallerTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstallerTest.java?rev=1604495&r1=1604494&r2=1604495&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstallerTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-test/src/org/apache/sling/ide/eclipse/m2e/EmbeddedArchetypeInstallerTest.java Sat Jun 21 23:39:40 2014
@@ -23,8 +23,6 @@ import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.sling.ide.artifacts.EmbeddedArtifact;
-import org.apache.sling.ide.artifacts.EmbeddedArtifactLocator;
-import org.apache.sling.ide.eclipse.m2e.internal.Activator;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.IMaven;
@@ -52,12 +50,15 @@ public class EmbeddedArchetypeInstallerT
@Test
public void testInstallArchetype() throws IOException, CoreException {
- EmbeddedArtifactLocator artifactsLocator = Activator.getDefault().getArtifactsLocator();
-
EmbeddedArchetypeInstaller archetypeInstaller = new EmbeddedArchetypeInstaller(archetypeGroupId,
archetypeArtifactId, archetypeVersion);
- EmbeddedArtifact[] archetypeArtifacts = artifactsLocator.loadSlingBundleArchetype();
+ EmbeddedArtifact[] archetypeArtifacts = new EmbeddedArtifact[] {
+ new EmbeddedArtifact("jar", archetypeVersion, getClass().getClassLoader().getResource(
+ "META-INF/MANIFEST.MF")),
+ new EmbeddedArtifact("pom", archetypeVersion, getClass().getClassLoader().getResource(
+ "META-INF/MANIFEST.MF"))
+ };
archetypeInstaller.addResource("pom", archetypeArtifacts[0].openInputStream());
archetypeInstaller.addResource("jar", archetypeArtifacts[1].openInputStream());
Added: sling/trunk/tooling/ide/eclipse-m2e-ui/.options
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/.options?rev=1604495&view=auto
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/.options (added)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/.options Sat Jun 21 23:39:40 2014
@@ -0,0 +1 @@
+org.apache.sling.ide.eclipse-m2e-ui/debug=false
\ No newline at end of file
Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/META-INF/MANIFEST.MF?rev=1604495&r1=1604494&r2=1604495&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/META-INF/MANIFEST.MF (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/META-INF/MANIFEST.MF Sat Jun 21 23:39:40 2014
@@ -20,11 +20,13 @@ Import-Package: org.apache.commons.httpc
org.apache.maven.artifact.handler,
org.apache.maven.artifact.installer,
org.apache.maven.artifact.repository,
+ org.apache.maven.artifact.versioning,
org.apache.maven.execution,
org.apache.maven.model,
org.apache.maven.plugin,
org.apache.sling.ide.artifacts,
org.apache.sling.ide.eclipse.core,
+ org.apache.sling.ide.eclipse.core.debug,
org.apache.sling.ide.eclipse.ui,
org.apache.sling.ide.eclipse.ui.wizards,
org.apache.sling.ide.osgi,
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=1604495&r1=1604494&r2=1604495&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/build.properties (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/build.properties Sat Jun 21 23:39:40 2014
@@ -1,5 +1,6 @@
bin.includes = plugin.xml,\
META-INF/,\
.,\
- icons/
+ icons/,\
+ .options
source.. = src/
Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/plugin.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/plugin.xml?rev=1604495&r1=1604494&r2=1604495&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/plugin.xml (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/plugin.xml Sat Jun 21 23:39:40 2014
@@ -16,4 +16,13 @@
project="true">
</wizard>
</extension>
+ <extension
+ point="org.eclipse.ui.trace.traceComponents">
+ <component
+ id="org.eclipse.ui.trace.tracingPrefPage"
+ label="Sling IDE Tooling">
+ <bundle
+ name="org.apache.sling.ide.eclipse-m2e-ui"></bundle>
+ </component>
+ </extension>
</plugin>
Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/Activator.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/Activator.java?rev=1604495&r1=1604494&r2=1604495&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/Activator.java (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/m2e/internal/Activator.java Sat Jun 21 23:39:40 2014
@@ -2,9 +2,13 @@ package org.apache.sling.ide.eclipse.m2e
import org.apache.sling.ide.artifacts.EmbeddedArtifactLocator;
import org.apache.sling.ide.eclipse.core.ServiceUtil;
+import org.apache.sling.ide.eclipse.core.debug.PluginLogger;
+import org.apache.sling.ide.eclipse.core.debug.PluginLoggerRegistrar;
import org.apache.sling.ide.osgi.OsgiClientFactory;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTracker;
public class Activator extends Plugin {
@@ -15,6 +19,9 @@ public class Activator extends Plugin {
private ServiceTracker<EmbeddedArtifactLocator, EmbeddedArtifactLocator> artifactLocator;
private ServiceTracker<OsgiClientFactory, OsgiClientFactory> osgiClientFactory;
+ private ServiceRegistration<?> tracerRegistration;
+ private ServiceTracker<Object, Object> tracer;
+
public static Activator getDefault() {
return INSTANCE;
}
@@ -31,6 +38,13 @@ public class Activator extends Plugin {
osgiClientFactory = new ServiceTracker<OsgiClientFactory, OsgiClientFactory>(context, OsgiClientFactory.class,
null);
osgiClientFactory.open();
+
+ tracerRegistration = PluginLoggerRegistrar.register(this);
+
+ // ugh
+ ServiceReference<Object> reference = (ServiceReference<Object>) tracerRegistration.getReference();
+ tracer = new ServiceTracker<Object, Object>(context, reference, null);
+ tracer.open();
}
@Override
@@ -51,4 +65,8 @@ public class Activator extends Plugin {
return ServiceUtil.getNotNull(osgiClientFactory);
}
+
+ public PluginLogger getPluginLogger() {
+ return (PluginLogger) ServiceUtil.getNotNull(tracer);
+ }
}
Modified: sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ChooseArchetypeWizardPage.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ChooseArchetypeWizardPage.java?rev=1604495&r1=1604494&r2=1604495&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ChooseArchetypeWizardPage.java (original)
+++ sling/trunk/tooling/ide/eclipse-m2e-ui/src/org/apache/sling/ide/eclipse/ui/wizards/np/ChooseArchetypeWizardPage.java Sat Jun 21 23:39:40 2014
@@ -25,6 +25,8 @@ import java.util.Set;
import org.apache.maven.archetype.catalog.Archetype;
import org.apache.maven.archetype.catalog.ArchetypeCatalog;
+import org.apache.sling.ide.eclipse.core.debug.PluginLogger;
+import org.apache.sling.ide.eclipse.m2e.internal.Activator;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -203,6 +205,7 @@ public class ChooseArchetypeWizardPage e
private void initialize() {
knownArchetypes.add(LOADING_PLEASE_WAIT);
+ knownArchetypes.select(0);
try {
getContainer().run(true, false, new RefreshArchetypesRunnable());
} catch (InvocationTargetException e) {
@@ -240,7 +243,6 @@ public class ChooseArchetypeWizardPage e
setPageComplete(message == null);
}
-
public IPath getLocation() {
if (!useDefaultWorkspaceLocationButton.getSelection() &&
locationCombo.getText().length()>0) {
@@ -258,6 +260,9 @@ public class ChooseArchetypeWizardPage e
@Override
public void indexChanged(IRepository repository) {
+ Activator.getDefault().getPluginLogger()
+ .trace("Reloading archetypes as index for repository {0} has changed", repository);
+
try {
new RefreshArchetypesRunnable().run(new NullProgressMonitor());
} catch (final InvocationTargetException e) {
@@ -288,6 +293,8 @@ public class ChooseArchetypeWizardPage e
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ PluginLogger logger = Activator.getDefault().getPluginLogger();
+
monitor.beginTask("Discovering archetypes...", 5);
ArchetypeManager manager = MavenPluginActivator.getDefault().getArchetypeManager();
monitor.worked(1);
@@ -297,15 +304,18 @@ public class ChooseArchetypeWizardPage e
Collection<ArchetypeCatalogFactory> archetypeCatalogs = manager.getArchetypeCatalogs();
monitor.worked(2);
- ArrayList<Archetype> list = new ArrayList<Archetype>();
+ ArrayList<Archetype> candidates = new ArrayList<Archetype>();
for (ArchetypeCatalogFactory catalogFactory : archetypeCatalogs) {
try {
ArchetypeCatalog catalog = catalogFactory.getArchetypeCatalog();
@SuppressWarnings("unchecked")
java.util.List<Archetype> arcs = catalog.getArchetypes();
+ logger.trace("Catalog factory {0} provided {1} archetypes", catalogFactory,
+ arcs != null ? arcs.size() : 0);
+
if (arcs != null) {
- list.addAll(arcs);
+ candidates.addAll(arcs);
}
} catch (CoreException ce) {
throw new InvocationTargetException(ce);
@@ -313,18 +323,28 @@ public class ChooseArchetypeWizardPage e
}
monitor.worked(1);
boolean changed = false;
- for (Archetype archetype2 : list) {
- if (getWizard().acceptsArchetype(archetype2)) {
- String key = keyFor(archetype2);
- Archetype old = archetypesMap.put(key, archetype2);
- if (old == null) {
+
+ logger.trace("Considering {0} archetypes from {1} archetype catalogs", candidates.size(),
+ archetypeCatalogs.size());
+
+ for (Archetype candidate : candidates) {
+ if (getWizard().acceptsArchetype(candidate)) {
+ String key = keyFor(candidate);
+ Archetype old = archetypesMap.put(key, candidate);
+
+ logger.trace("Registered archetype {0}", candidate);
+
+ if (old == null || !old.equals(candidate)) {
changed = true;
}
+
+ logger.trace("Old archetype was {0}, changed = {1}", old, changed);
}
}
monitor.worked(1);
- if (changed) {
+ if (changed || archetypesMap.isEmpty()) {
+ logger.trace("Triggering refresh since changed is true");
Display.getDefault().asyncExec(new Runnable() {
public void run() {
Set<String> keys = archetypesMap.keySet();
@@ -333,6 +353,13 @@ public class ChooseArchetypeWizardPage e
knownArchetypes.add(aKey);
}
knownArchetypes.pack();
+
+ if (knownArchetypes.getItems().length == 0) {
+ setErrorMessage("No suitable archetypes found. Please make sure that the proper maven repositories are configured and indexes are up to date.");
+ } else {
+ setErrorMessage(null);
+ }
+
}
});
}
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=1604495&r1=1604494&r2=1604495&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 Sat Jun 21 23:39:40 2014
@@ -16,15 +16,9 @@
*/
package org.apache.sling.ide.eclipse.ui.wizards.np;
-import java.io.IOException;
-
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.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.sling.ide.eclipse.ui.WhitelabelSupport;
-import org.eclipse.core.runtime.CoreException;
public class NewSlingBundleWizard extends AbstractNewMavenBasedSlingApplicationWizard {
@@ -36,29 +30,28 @@ public class NewSlingBundleWizard extend
@Override
public void installArchetypes() {
- EmbeddedArtifactLocator artifactsLocator = Activator.getDefault().getArtifactsLocator();
-
- EmbeddedArchetypeInstaller archetypeInstaller = new EmbeddedArchetypeInstaller(
- "org.apache.sling", "sling-bundle-archetype", "slingclipse-embedded");
- try {
-
- EmbeddedArtifact[] archetypeArtifacts = artifactsLocator.loadSlingBundleArchetype();
-
- archetypeInstaller.addResource("pom", archetypeArtifacts[0].openInputStream());
- archetypeInstaller.addResource("jar", archetypeArtifacts[1].openInputStream());
-
- archetypeInstaller.installArchetype();
- } catch (IOException e) {
- reportError(e);
- } catch (CoreException e) {
- reportError(e);
- }
+ // rely on public archetypes only
}
@Override
public boolean acceptsArchetype(Archetype archetype) {
- return (archetype.getGroupId().equals("org.apache.sling") &&
- archetype.getArtifactId().equals("sling-bundle-archetype"));
+
+ boolean isSlingBundleArchetype = archetype.getGroupId().equals("org.apache.sling") &&
+ archetype.getArtifactId().equals("sling-bundle-archetype");
+
+ if ( !isSlingBundleArchetype ) {
+ return false;
+ }
+
+ DefaultArtifactVersion version = new DefaultArtifactVersion(archetype.getVersion());
+
+ // release 1.0.2 is the first known good release
+ if (version.compareTo(new DefaultArtifactVersion("1.0.2")) < 0) {
+ return false;
+ }
+
+ return true;
+
}
}