diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractEclipseTestMojo.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractEclipseTestMojo.java index f066418d79..a9947e645e 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractEclipseTestMojo.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractEclipseTestMojo.java @@ -639,17 +639,11 @@ private EquinoxInstallation createProvisionedInstallation() throws MojoExecution File workingDir = new File(project.getBuild().getDirectory(), "p2temp"); workingDir.mkdirs(); installationBuilder.setWorkingDir(workingDir); - TargetEnvironment runningEnvironment = TargetEnvironment.getRunningEnvironment(); - if (PlatformPropertiesUtils.OS_MACOSX.equals(runningEnvironment.getOs())) { - if (work.getName().endsWith(".app")) { - installationBuilder.setDestination(work); - } else { - installationBuilder.setDestination(new File(work, "Eclipse.app/Contents/Eclipse/")); - } - } else { - installationBuilder.setDestination(work); - } - return installationBuilder.install(); + installationBuilder.setDestination(work); + List list = getTestTargetEnvironments(); + TargetEnvironment env = list.get(0); + getLog().info("Provisioning with environment " + env + "..."); + return installationBuilder.install(env); } catch (Exception ex) { throw new MojoExecutionException(ex.getMessage(), ex); } @@ -1054,7 +1048,7 @@ private EquinoxLaunchConfiguration createCommandLine(EquinoxInstallation testRun addProgramArgs(cli, "-data", osgiDataDirectory.getAbsolutePath(), // "-install", testRuntime.getLocation().getAbsolutePath(), // "-configuration", testRuntime.getConfigurationLocation().getAbsolutePath(), // - "-application", getTestApplication(testRuntime.getInstallationDescription()), // + "-application", getTestApplication(), // "-testproperties", surefireProperties.getAbsolutePath()); if (application != null) { cli.addProgramArguments("-testApplication", application); @@ -1122,7 +1116,7 @@ String[] splitArgLine(String argLine) throws MojoExecutionException { } } - private String getTestApplication(EquinoxInstallationDescription testRuntime) { + private String getTestApplication() { if (useUIHarness) { return "org.eclipse.tycho.surefire.osgibooter.uitest"; } else { diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedEquinoxInstallation.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedEquinoxInstallation.java index 6c44ba1cfa..934f48f3bc 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedEquinoxInstallation.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedEquinoxInstallation.java @@ -17,7 +17,6 @@ import org.eclipse.sisu.equinox.launching.EquinoxInstallation; import org.eclipse.sisu.equinox.launching.EquinoxInstallationDescription; import org.eclipse.sisu.equinox.launching.internal.EquinoxInstallationLaunchConfiguration; -import org.eclipse.tycho.core.osgitools.BundleReader; /** * This class provides an implementation of an {@link EquinoxInstallation} which represents an RCP @@ -32,9 +31,9 @@ public class ProvisionedEquinoxInstallation implements EquinoxInstallation { private File configurationLocation; private EquinoxInstallationDescription description; - public ProvisionedEquinoxInstallation(File location, BundleReader bundleReader) { + public ProvisionedEquinoxInstallation(File location) { this.location = location; - description = new ProvisionedInstallationDescription(location, bundleReader); + description = new ProvisionedInstallationDescription(location, null); } @Override diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationBuilder.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationBuilder.java index 5b207f99b8..20b5b902aa 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationBuilder.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationBuilder.java @@ -22,15 +22,14 @@ import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.FileUtils; import org.eclipse.sisu.equinox.launching.EquinoxInstallation; +import org.eclipse.tycho.PlatformPropertiesUtils; import org.eclipse.tycho.TargetEnvironment; -import org.eclipse.tycho.core.osgitools.BundleReader; import org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException; import org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime; public class ProvisionedInstallationBuilder { private Logger log; - private BundleReader bundleReader; private DirectorRuntime directorRuntime; private List metadataRepos = new ArrayList<>(); @@ -48,9 +47,8 @@ public void setWorkingDir(File workingDir) { this.workingDir = workingDir; } - public ProvisionedInstallationBuilder(BundleReader bundleReader, DirectorRuntime directorRuntime, Logger log) { + public ProvisionedInstallationBuilder(DirectorRuntime directorRuntime, Logger log) { this.log = log; - this.bundleReader = bundleReader; this.directorRuntime = directorRuntime; this.bundlesPublisher = new BundlesPublisher(log); } @@ -97,11 +95,11 @@ public void setInstallFeatures(boolean installFeatures) { this.installFeatures = installFeatures; } - public EquinoxInstallation install() throws Exception { + public EquinoxInstallation install(TargetEnvironment main) throws Exception { validate(); publishPlainBundleJars(); - executeDirector(); - return new ProvisionedEquinoxInstallation(effectiveDestination, bundleReader); + executeDirector(main); + return new ProvisionedEquinoxInstallation(getFinalDestination(main)); } private void publishPlainBundleJars() throws Exception { @@ -121,17 +119,17 @@ private void publishPlainBundleJars() throws Exception { artifactRepos.add(bundlesRepoURI); } - private void executeDirector() throws MojoFailureException { + private void executeDirector(TargetEnvironment env) throws MojoFailureException { DirectorRuntime.Command command = directorRuntime.newInstallCommand(); command.addMetadataSources(metadataRepos); command.addArtifactSources(artifactRepos); for (String iu : ius) { command.addUnitToInstall(iu); } - command.setDestination(effectiveDestination); + command.setDestination(getFinalDestination(env)); command.setProfileName(profileName); command.setInstallFeatures(installFeatures); - command.setEnvironment(TargetEnvironment.getRunningEnvironment()); + command.setEnvironment(env); log.info("Installing IUs " + ius + " to " + effectiveDestination); try { command.execute(); @@ -140,6 +138,15 @@ private void executeDirector() throws MojoFailureException { } } + private File getFinalDestination(TargetEnvironment env) { + if (PlatformPropertiesUtils.OS_MACOSX.equals(env.getOs())) { + if (!effectiveDestination.getName().endsWith(".app")) { + return new File(effectiveDestination, "Eclipse.app/Contents/Eclipse/"); + } + } + return effectiveDestination; + } + private void validate() { assertNotNull(workingDir, "workingDir"); assertNotNull(effectiveDestination, "destination"); diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationBuilderFactory.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationBuilderFactory.java index d5784f63f3..03b8f53289 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationBuilderFactory.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationBuilderFactory.java @@ -15,15 +15,11 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; -import org.eclipse.tycho.core.osgitools.BundleReader; import org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime; @Component(role = ProvisionedInstallationBuilderFactory.class) public class ProvisionedInstallationBuilderFactory { - @Requirement - private BundleReader bundleReader; - @Requirement private DirectorRuntime directorRuntime; @@ -31,7 +27,7 @@ public class ProvisionedInstallationBuilderFactory { private Logger logger; public ProvisionedInstallationBuilder createInstallationBuilder() { - return new ProvisionedInstallationBuilder(bundleReader, directorRuntime, logger); + return new ProvisionedInstallationBuilder(directorRuntime, logger); } } diff --git a/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationBuilderTest.java b/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationBuilderTest.java index 650fa54776..65d734ce59 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationBuilderTest.java +++ b/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provisioning/ProvisionedInstallationBuilderTest.java @@ -27,7 +27,7 @@ public class ProvisionedInstallationBuilderTest { @Test public void setDestination_LayoutNormal() throws Exception { - ProvisionedInstallationBuilder builder = new ProvisionedInstallationBuilder(null, null, null); + ProvisionedInstallationBuilder builder = new ProvisionedInstallationBuilder(null, null); File work = tempDir.newFolder("work"); builder.setDestination(work); @@ -36,7 +36,7 @@ public void setDestination_LayoutNormal() throws Exception { @Test public void setDestination_LayoutMacOS() throws Exception { - ProvisionedInstallationBuilder builder = new ProvisionedInstallationBuilder(null, null, null); + ProvisionedInstallationBuilder builder = new ProvisionedInstallationBuilder(null, null); File work = tempDir.newFolder("work.app"); builder.setDestination(work);