Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of TychoProjectUtils entirely #3277

Merged
merged 1 commit into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
import org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils;
import org.eclipse.tycho.core.ee.StandardExecutionEnvironment;
import org.eclipse.tycho.core.osgitools.DependencyComputer.DependencyEntry;
import org.eclipse.tycho.core.utils.TychoProjectUtils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
Expand Down Expand Up @@ -215,8 +214,7 @@ protected Properties getPlatformProperties(ReactorProject project, MavenSession
//FIXME formally we should resolve the configuration for ALL declared environments!
TargetEnvironment environment = configuration.getEnvironments().get(0);
logger.debug("Using TargetEnvironment " + environment.toFilterExpression() + " to create resolver properties");
Properties properties = new Properties();
properties.putAll(TychoProjectUtils.getMergedProperties(project.adapt(MavenProject.class), mavenSession));
Properties properties = computeMergedProperties(project.adapt(MavenProject.class), mavenSession);
return getPlatformProperties(properties, mavenSession, environment, ee);
}

Expand Down Expand Up @@ -578,4 +576,15 @@ public List<AccessRule> getBootClasspathExtraAccessRules() {
};
}

public static Properties computeMergedProperties(MavenProject mavenProject, MavenSession mavenSession) {
Properties properties = new Properties();
properties.putAll(mavenProject.getProperties());
if (mavenSession != null) {
properties.putAll(mavenSession.getSystemProperties()); // session wins
properties.putAll(mavenSession.getUserProperties());
} else {
properties.putAll(System.getProperties());
}
return properties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.eclipse.tycho.core.resolver;

import java.util.Optional;
import java.util.Properties;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
Expand All @@ -23,20 +24,25 @@
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
import org.eclipse.tycho.DependencyArtifacts;
import org.eclipse.tycho.PlatformPropertiesUtils;
import org.eclipse.tycho.ReactorProject;
import org.eclipse.tycho.core.DependencyResolver;
import org.eclipse.tycho.core.TychoProject;
import org.eclipse.tycho.core.TychoProjectManager;
import org.eclipse.tycho.core.osgitools.AbstractTychoProject;
import org.eclipse.tycho.core.osgitools.DebugUtils;
import org.eclipse.tycho.core.osgitools.DefaultReactorProject;
import org.eclipse.tycho.core.osgitools.EquinoxResolver;
import org.eclipse.tycho.resolver.TychoResolver;

@Component(role = TychoResolver.class)
public class DefaultTychoResolver implements TychoResolver {

private static final String SETUP_MARKER = "DefaultTychoResolver/Setup";
private static final String RESOLVE_MARKER = "DefaultTychoResolver/Resolve";
private static final String TYCHO_ENV_OSGI_WS = "tycho.env.osgi.ws";
private static final String TYCHO_ENV_OSGI_OS = "tycho.env.osgi.os";
private static final String TYCHO_ENV_OSGI_ARCH = "tycho.env.osgi.arch";

@Requirement
private Logger logger;
Expand All @@ -58,6 +64,17 @@ public void setupProject(MavenSession session, MavenProject project) {
return;
}
reactorProject.setContextValue(SETUP_MARKER, true);

//enhance the current project properties with the currently used environment
Properties properties = EquinoxResolver.computeMergedProperties(project, session);
String arch = PlatformPropertiesUtils.getArch(properties);
String os = PlatformPropertiesUtils.getOS(properties);
String ws = PlatformPropertiesUtils.getWS(properties);
Properties projectProperties = project.getProperties();
projectProperties.put(TYCHO_ENV_OSGI_WS, ws);
projectProperties.put(TYCHO_ENV_OSGI_OS, os);
projectProperties.put(TYCHO_ENV_OSGI_ARCH, arch);

//FIXME this should actually happen lazy on first access so we do not require more here than bootstrap the project with a session above
dr.setupProject(session, project);
dependencyResolver.setupProjects(session, project, reactorProject);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
import org.eclipse.tycho.core.osgitools.DependenciesResolver;
import org.eclipse.tycho.core.osgitools.DependencyComputer;
import org.eclipse.tycho.core.osgitools.DependencyComputer.DependencyEntry;
import org.eclipse.tycho.test.util.MavenSessionUtils;
import org.eclipse.tycho.core.osgitools.EquinoxResolver;
import org.eclipse.tycho.core.utils.MavenSessionUtils;
import org.eclipse.tycho.testing.AbstractTychoMojoTestCase;
import org.eclipse.tycho.version.TychoVersion;
import org.junit.Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Contributors:
* Sonatype Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.tycho.core.utils;
package org.eclipse.tycho.test.util;

import java.io.File;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
import org.eclipse.tycho.core.TychoProject;
import org.eclipse.tycho.core.osgitools.DefaultReactorProject;
import org.eclipse.tycho.core.osgitools.project.BuildOutputJar;
import org.eclipse.tycho.core.utils.TychoProjectUtils;
import org.eclipse.tycho.dev.DevBundleInfo;
import org.eclipse.tycho.dev.DevWorkspaceResolver;
import org.eclipse.tycho.p2.tools.RepositoryReferences;
Expand Down Expand Up @@ -1046,11 +1045,10 @@ private EquinoxLaunchConfiguration createCommandLine(EquinoxInstallation testRun
}

cli.addVMArguments("-Dosgi.noShutdown=false");

Properties properties = TychoProjectUtils.getMergedProperties(project, session);
cli.addVMArguments("-Dosgi.os=" + PlatformPropertiesUtils.getOS(properties), //
"-Dosgi.ws=" + PlatformPropertiesUtils.getWS(properties), //
"-Dosgi.arch=" + PlatformPropertiesUtils.getArch(properties));
TargetEnvironment environment = TargetEnvironment.getRunningEnvironment();
cli.addVMArguments("-Dosgi.os=" + environment.getOs(), //
"-Dosgi.ws=" + environment.getWs(), //
"-Dosgi.arch=" + environment.getArch());
addCustomProfileArg(cli);
cli.addVMArguments(splitArgLine(argLine));

Expand Down
Loading