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 17, 2023
1 parent e9676af commit dc052c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 93 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 @@ -12,53 +12,20 @@
*******************************************************************************/
package org.eclipse.tycho.core.utils;

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;

public class TychoProjectUtils {
private static final String TYCHO_NOT_CONFIGURED = "Tycho build extension not configured for ";

public static final String TYCHO_ENV_OSGI_WS = "tycho.env.osgi.ws";
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);
}

/**
* Computes the merged properties from maven session and the project
*
Expand Down

This file was deleted.

0 comments on commit dc052c2

Please sign in to comment.