Permalink
Browse files

395281 [refactor] move platform utils to core.shared

and use it in TargetEnvironment to provide
running os/ws/arch environment as default
environment.
P2ResolverImpl now uses running environment as default
unless explicitly set otherwise.

Change-Id: If6c30caf351b170f52d93be49bb0c38b99225326
  • Loading branch information...
1 parent 5bc6500 commit e61c06d3cf1d33f37c10e1cdc4816362e538a614 @jsievers jsievers committed Jan 11, 2013
@@ -12,6 +12,9 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Properties;
+
+import org.eclipse.tycho.core.resolver.shared.PlatformPropertiesUtils;
public final class TargetEnvironment {
private static final String OSGI_OS = "osgi.os";
@@ -148,4 +151,15 @@ private static boolean eq(String a, String b) {
return a != null ? a.equals(b) : b == null;
}
+ public static TargetEnvironment getRunningEnvironment() {
+ Properties properties = new Properties();
+ properties.put(PlatformPropertiesUtils.OSGI_OS, PlatformPropertiesUtils.getOS(properties));
+ properties.put(PlatformPropertiesUtils.OSGI_WS, PlatformPropertiesUtils.getWS(properties));
+ properties.put(PlatformPropertiesUtils.OSGI_ARCH, PlatformPropertiesUtils.getArch(properties));
+
+ return new TargetEnvironment(properties.getProperty(PlatformPropertiesUtils.OSGI_OS),
+ properties.getProperty(PlatformPropertiesUtils.OSGI_WS),
+ properties.getProperty(PlatformPropertiesUtils.OSGI_ARCH));
+ }
+
}
@@ -9,7 +9,7 @@
* Andrew Niefer - IBM Corporation - initial API and implementation
* Sonatype Inc. - ongoing development
*******************************************************************************/
-package org.eclipse.tycho.core.utils;
+package org.eclipse.tycho.core.resolver.shared;
import java.util.Properties;
@@ -13,6 +13,7 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
@@ -64,6 +65,7 @@
public P2ResolverImpl(MavenLogger logger) {
this.logger = logger;
this.monitor = new LoggingProgressMonitor(logger);
+ this.environments = Collections.singletonList(TargetEnvironment.getRunningEnvironment());
}
public List<P2ResolutionResult> resolveProject(TargetPlatform targetPlatform, File projectLocation) {
@@ -28,7 +28,7 @@
import org.eclipse.tycho.core.ArtifactDependencyWalker;
import org.eclipse.tycho.core.PluginDescription;
import org.eclipse.tycho.core.facade.TargetEnvironment;
-import org.eclipse.tycho.core.utils.PlatformPropertiesUtils;
+import org.eclipse.tycho.core.resolver.shared.PlatformPropertiesUtils;
import org.eclipse.tycho.model.Feature;
import org.eclipse.tycho.model.FeatureRef;
import org.eclipse.tycho.model.PluginRef;
@@ -41,7 +41,7 @@
import org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils;
import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment;
import org.eclipse.tycho.core.facade.TargetEnvironment;
-import org.eclipse.tycho.core.utils.PlatformPropertiesUtils;
+import org.eclipse.tycho.core.resolver.shared.PlatformPropertiesUtils;
import org.eclipse.tycho.core.utils.TychoProjectUtils;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -54,7 +54,7 @@
import org.eclipse.tycho.core.osgitools.project.BuildOutputJar;
import org.eclipse.tycho.core.osgitools.project.EclipsePluginProject;
import org.eclipse.tycho.core.osgitools.project.EclipsePluginProjectImpl;
-import org.eclipse.tycho.core.utils.PlatformPropertiesUtils;
+import org.eclipse.tycho.core.resolver.shared.PlatformPropertiesUtils;
import org.eclipse.tycho.core.utils.TychoProjectUtils;
import org.eclipse.tycho.model.Feature;
import org.eclipse.tycho.model.ProductConfiguration;
@@ -31,7 +31,7 @@
import org.eclipse.tycho.core.TychoProject;
import org.eclipse.tycho.core.facade.TargetEnvironment;
import org.eclipse.tycho.core.resolver.shared.OptionalResolutionAction;
-import org.eclipse.tycho.core.utils.PlatformPropertiesUtils;
+import org.eclipse.tycho.core.resolver.shared.PlatformPropertiesUtils;
@Component(role = DefaultTargetPlatformConfigurationReader.class)
public class DefaultTargetPlatformConfigurationReader {
@@ -54,7 +54,7 @@
import org.eclipse.tycho.core.PluginDescription;
import org.eclipse.tycho.core.facade.TargetEnvironment;
import org.eclipse.tycho.core.osgitools.BundleReader;
-import org.eclipse.tycho.core.utils.PlatformPropertiesUtils;
+import org.eclipse.tycho.core.resolver.shared.PlatformPropertiesUtils;
import org.eclipse.tycho.core.utils.TychoProjectUtils;
import org.eclipse.tycho.locking.facade.FileLockService;
import org.eclipse.tycho.locking.facade.FileLocker;
@@ -64,7 +64,7 @@
import org.eclipse.tycho.core.osgitools.project.BuildOutputJar;
import org.eclipse.tycho.core.resolver.DefaultTargetPlatformResolverFactory;
import org.eclipse.tycho.core.resolver.shared.OptionalResolutionAction;
-import org.eclipse.tycho.core.utils.PlatformPropertiesUtils;
+import org.eclipse.tycho.core.resolver.shared.PlatformPropertiesUtils;
import org.eclipse.tycho.core.utils.TychoProjectUtils;
import org.eclipse.tycho.dev.DevBundleInfo;
import org.eclipse.tycho.dev.DevWorkspaceResolver;

0 comments on commit e61c06d

Please sign in to comment.