diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedEquinoxInstallation.java b/sisu-osgi/sisu-equinox-launching/src/main/java/org/eclipse/sisu/equinox/launching/ProvisionedEquinoxInstallation.java similarity index 91% rename from tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedEquinoxInstallation.java rename to sisu-osgi/sisu-equinox-launching/src/main/java/org/eclipse/sisu/equinox/launching/ProvisionedEquinoxInstallation.java index 934f48f3bc..1ad3576d94 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedEquinoxInstallation.java +++ b/sisu-osgi/sisu-equinox-launching/src/main/java/org/eclipse/sisu/equinox/launching/ProvisionedEquinoxInstallation.java @@ -10,12 +10,10 @@ * Contributors: * Mickael Istria (Red Hat Inc.) - 386988 Support for provisioned applications ******************************************************************************/ -package org.eclipse.tycho.surefire.provisioning; +package org.eclipse.sisu.equinox.launching; import java.io.File; -import org.eclipse.sisu.equinox.launching.EquinoxInstallation; -import org.eclipse.sisu.equinox.launching.EquinoxInstallationDescription; import org.eclipse.sisu.equinox.launching.internal.EquinoxInstallationLaunchConfiguration; /** @@ -33,7 +31,7 @@ public class ProvisionedEquinoxInstallation implements EquinoxInstallation { public ProvisionedEquinoxInstallation(File location) { this.location = location; - description = new ProvisionedInstallationDescription(location, null); + description = new ProvisionedInstallationDescription(location); } @Override diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationDescription.java b/sisu-osgi/sisu-equinox-launching/src/main/java/org/eclipse/sisu/equinox/launching/ProvisionedInstallationDescription.java similarity index 77% rename from tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationDescription.java rename to sisu-osgi/sisu-equinox-launching/src/main/java/org/eclipse/sisu/equinox/launching/ProvisionedInstallationDescription.java index ca8df0d362..7ebd4de566 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationDescription.java +++ b/sisu-osgi/sisu-equinox-launching/src/main/java/org/eclipse/sisu/equinox/launching/ProvisionedInstallationDescription.java @@ -10,23 +10,22 @@ * Contributors: * Mickael Istria (Red Hat Inc.) - 386988 Support for provisioned applications ******************************************************************************/ -package org.eclipse.tycho.surefire.provisioning; +package org.eclipse.sisu.equinox.launching; import java.io.File; import java.io.FileFilter; +import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.jar.JarFile; import org.eclipse.osgi.internal.framework.EquinoxContainer; -import org.eclipse.sisu.equinox.launching.BundleReference; -import org.eclipse.sisu.equinox.launching.BundleStartLevel; -import org.eclipse.sisu.equinox.launching.EquinoxInstallationDescription; import org.eclipse.tycho.ArtifactKey; import org.eclipse.tycho.ArtifactType; import org.eclipse.tycho.DefaultArtifactKey; -import org.eclipse.tycho.core.osgitools.BundleReader; +import org.osgi.framework.Constants; /** * A "read-only" equinox installation (no bundles can be added, nothing configured). All @@ -36,11 +35,9 @@ public class ProvisionedInstallationDescription implements EquinoxInstallationDe private File location; private BundleReference systemBundleDescriptor; - private BundleReader bundleReader; - ProvisionedInstallationDescription(File location, BundleReader bundleReader) { + ProvisionedInstallationDescription(File location) { this.location = location; - this.bundleReader = bundleReader; } @Override @@ -61,27 +58,31 @@ public BundleReference getSystemBundle() { } else { systemBundle = systemBundles[0]; } - String version = bundleReader.loadManifest(systemBundle).getBundleVersion(); - ArtifactKey systemBundleKey = new DefaultArtifactKey(ArtifactType.TYPE_ECLIPSE_PLUGIN, EquinoxContainer.NAME, - version); - systemBundleDescriptor = new BundleReference() { - - @Override - public String getVersion() { - return systemBundleKey.getVersion(); - } - - @Override - public File getLocation() { - return systemBundle; - } - - @Override - public String getId() { - return systemBundleKey.getId(); - } - }; - return systemBundleDescriptor; + try (JarFile jarFile = new JarFile(systemBundle)) { + String version = jarFile.getManifest().getMainAttributes().getValue(Constants.BUNDLE_VERSION); + ArtifactKey systemBundleKey = new DefaultArtifactKey(ArtifactType.TYPE_ECLIPSE_PLUGIN, + EquinoxContainer.NAME, version); + systemBundleDescriptor = new BundleReference() { + + @Override + public String getVersion() { + return systemBundleKey.getVersion(); + } + + @Override + public File getLocation() { + return systemBundle; + } + + @Override + public String getId() { + return systemBundleKey.getId(); + } + }; + return systemBundleDescriptor; + } catch (IOException e) { + throw new IllegalArgumentException("Can't read system bundle " + systemBundle.getAbsolutePath()); + } } @Override diff --git a/tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipserun/EclipseRunMojo.java b/tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipserun/EclipseRunMojo.java index c694169d93..5864300038 100644 --- a/tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipserun/EclipseRunMojo.java +++ b/tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipserun/EclipseRunMojo.java @@ -43,6 +43,7 @@ import org.eclipse.sisu.equinox.launching.EquinoxInstallationFactory; import org.eclipse.sisu.equinox.launching.EquinoxLauncher; import org.eclipse.sisu.equinox.launching.LaunchConfiguration; +import org.eclipse.sisu.equinox.launching.ProvisionedEquinoxInstallation; import org.eclipse.sisu.equinox.launching.internal.EquinoxLaunchConfiguration; import org.eclipse.tycho.ArtifactType; import org.eclipse.tycho.ExecutionEnvironmentConfiguration; @@ -84,6 +85,13 @@ public class EclipseRunMojo extends AbstractMojo { @Parameter(defaultValue = "${project.build.directory}/eclipserun-work") private File work; + /** + * Allows to use a prebuild installation to perform the run instead of one + * assembled by Tycho + */ + @Parameter + private File installation; + /** * Whether the workspace should be cleared before running eclipse. *
@@ -139,7 +147,7 @@ public class EclipseRunMojo extends AbstractMojo {
* </repositories>
*
*/
- @Parameter(required = true)
+ @Parameter
private List