Skip to content

Commit

Permalink
Cleanup maven resolver from using TychoProjectUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Dec 16, 2023
1 parent bd2796d commit 8d96025
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
import org.eclipse.tycho.DependencyResolutionException;
import org.eclipse.tycho.IllegalArtifactReferenceException;
import org.eclipse.tycho.MavenArtifactKey;
import org.eclipse.tycho.ReactorProject;
import org.eclipse.tycho.ResolvedArtifactKey;
import org.eclipse.tycho.TargetPlatform;
import org.eclipse.tycho.core.TychoProjectManager;
import org.eclipse.tycho.core.maven.MavenDependenciesResolver;
import org.eclipse.tycho.core.utils.TychoProjectUtils;

/**
* {@link MavenBundleResolver} helps in gathering bundles that are living in P2 and maven world and
Expand Down Expand Up @@ -71,7 +71,7 @@ public Optional<ResolvedArtifactKey> resolveMavenBundle(MavenProject project, Ma
if (project == null) {
return Optional.empty();
}
TargetPlatform tp = TychoProjectUtils.getTargetPlatformIfAvailable(DefaultReactorProject.adapt(project));
TargetPlatform tp = getTargetPlatformIfAvailable(DefaultReactorProject.adapt(project));
String type = mavenArtifactKey.getType();
String resolvedType = PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE.equals(type) ? ArtifactType.TYPE_ECLIPSE_PLUGIN
: type;
Expand Down Expand Up @@ -116,6 +116,17 @@ public Optional<ResolvedArtifactKey> resolveMavenBundle(MavenProject project, Ma
return Optional.empty();
}

/**
* Returns the final target platform of the given project, or <code>null</code> if the target
* platform is not available.
*
* Projects with -Dtycho.targetPlatform use the legacy LocalDependencyResolver, which doesn't
* provide the {@link TargetPlatform} interface.
*/
private static TargetPlatform getTargetPlatformIfAvailable(ReactorProject project) {
return (TargetPlatform) project.getContextValue(TargetPlatform.FINAL_TARGET_PLATFORM_KEY);
}

public Optional<ResolvedArtifactKey> resolveMavenBundle(MavenProject project, MavenSession mavenSession,
String groupId, String artifactId, String version) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Properties;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.project.MavenProject;
import org.eclipse.tycho.DependencyArtifacts;
import org.eclipse.tycho.PlatformPropertiesUtils;
import org.eclipse.tycho.ReactorProject;
import org.eclipse.tycho.TargetPlatform;
import org.eclipse.tycho.TychoConstants;
import org.eclipse.tycho.core.osgitools.DefaultReactorProject;
import org.eclipse.tycho.core.resolver.shared.DependencySeed;
Expand All @@ -34,34 +31,6 @@ public class TychoProjectUtils {
public static final String TYCHO_ENV_OSGI_OS = "tycho.env.osgi.os";
public static final String TYCHO_ENV_OSGI_ARCH = "tycho.env.osgi.arch";

public static Optional<DependencyArtifacts> getOptionalDependencyArtifacts(ReactorProject project) {
DependencyArtifacts resolvedDependencies = (DependencyArtifacts) project
.getContextValue(TychoConstants.CTX_DEPENDENCY_ARTIFACTS);
return Optional.ofNullable(resolvedDependencies);
}

/**
* Returns the final target platform of the given project.
*/
public static TargetPlatform getTargetPlatform(ReactorProject project) {
TargetPlatform targetPlatform = getTargetPlatformIfAvailable(project);
if (targetPlatform == null) {
throw new IllegalStateException(TYCHO_NOT_CONFIGURED + project.toString());
}
return targetPlatform;
}

/**
* Returns the final target platform of the given project, or <code>null</code> if the target
* platform is not available.
*
* Projects with -Dtycho.targetPlatform use the legacy LocalDependencyResolver, which doesn't
* provide the {@link TargetPlatform} interface.
*/
public static TargetPlatform getTargetPlatformIfAvailable(ReactorProject project) {
return (TargetPlatform) project.getContextValue(TargetPlatform.FINAL_TARGET_PLATFORM_KEY);
}

/**
* Returns the (editable) list of {@link DependencySeed}s for the given project.
*/
Expand Down Expand Up @@ -103,7 +72,7 @@ private static Properties computeMergedProperties(MavenProject mavenProject, Mav
return properties;
}

public static void setTychoEnvironmentProperties(Properties properties, MavenProject project) {
private static void setTychoEnvironmentProperties(Properties properties, MavenProject project) {
String arch = PlatformPropertiesUtils.getArch(properties);
String os = PlatformPropertiesUtils.getOS(properties);
String ws = PlatformPropertiesUtils.getWS(properties);
Expand Down

This file was deleted.

0 comments on commit 8d96025

Please sign in to comment.