|
|
@ -26,12 +26,12 @@ import java.util.Arrays;
|
|
|
|
import java.util.LinkedHashSet;
|
|
|
|
import java.util.LinkedHashSet;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.maven.RepositoryUtils;
|
|
|
|
import org.apache.maven.artifact.Artifact;
|
|
|
|
import org.apache.maven.artifact.Artifact;
|
|
|
|
import org.apache.maven.artifact.DefaultArtifact;
|
|
|
|
import org.apache.maven.artifact.DefaultArtifact;
|
|
|
|
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
|
|
|
|
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
|
|
|
|
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
|
|
|
|
|
|
|
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
|
|
|
|
|
|
|
import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
|
|
|
|
import org.apache.maven.artifact.resolver.ResolutionErrorHandler;
|
|
|
|
import org.apache.maven.plugin.MojoExecutionException;
|
|
|
|
import org.apache.maven.plugin.MojoExecutionException;
|
|
|
|
import org.apache.maven.plugins.annotations.Component;
|
|
|
|
import org.apache.maven.plugins.annotations.Component;
|
|
|
@ -39,7 +39,13 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
|
|
|
|
import org.apache.maven.plugins.annotations.Mojo;
|
|
|
|
import org.apache.maven.plugins.annotations.Mojo;
|
|
|
|
import org.apache.maven.plugins.annotations.Parameter;
|
|
|
|
import org.apache.maven.plugins.annotations.Parameter;
|
|
|
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
|
|
|
import org.apache.maven.plugins.annotations.ResolutionScope;
|
|
|
|
import org.apache.maven.repository.RepositorySystem;
|
|
|
|
import org.eclipse.aether.RepositorySystem;
|
|
|
|
|
|
|
|
import org.eclipse.aether.collection.CollectRequest;
|
|
|
|
|
|
|
|
import org.eclipse.aether.resolution.ArtifactResult;
|
|
|
|
|
|
|
|
import org.eclipse.aether.resolution.DependencyRequest;
|
|
|
|
|
|
|
|
import org.eclipse.aether.resolution.DependencyResult;
|
|
|
|
|
|
|
|
import org.eclipse.aether.util.artifact.JavaScopes;
|
|
|
|
|
|
|
|
import org.eclipse.aether.util.filter.DependencyFilterUtils;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Invoke the AOT engine on tests.
|
|
|
|
* Invoke the AOT engine on tests.
|
|
|
@ -97,20 +103,6 @@ public class ProcessTestAotMojo extends AbstractAotMojo {
|
|
|
|
@Parameter(defaultValue = "${project.build.directory}/spring-aot/main/classes", required = true)
|
|
|
|
@Parameter(defaultValue = "${project.build.directory}/spring-aot/main/classes", required = true)
|
|
|
|
private File generatedClasses;
|
|
|
|
private File generatedClasses;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Local artifact repository used to resolve JUnit platform launcher jars.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
|
|
|
|
@Parameter(defaultValue = "${localRepository}", required = true, readonly = true)
|
|
|
|
|
|
|
|
private org.apache.maven.artifact.repository.ArtifactRepository localRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Remote artifact repositories used to resolve JUnit platform launcher jars.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
|
|
|
|
@Parameter(defaultValue = "${project.remoteArtifactRepositories}", required = true, readonly = true)
|
|
|
|
|
|
|
|
private List<org.apache.maven.artifact.repository.ArtifactRepository> remoteRepositories;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
@Component
|
|
|
|
private RepositorySystem repositorySystem;
|
|
|
|
private RepositorySystem repositorySystem;
|
|
|
|
|
|
|
|
|
|
|
@ -165,10 +157,10 @@ public class ProcessTestAotMojo extends AbstractAotMojo {
|
|
|
|
String version = getJUnitPlatformVersion();
|
|
|
|
String version = getJUnitPlatformVersion();
|
|
|
|
DefaultArtifactHandler handler = new DefaultArtifactHandler("jar");
|
|
|
|
DefaultArtifactHandler handler = new DefaultArtifactHandler("jar");
|
|
|
|
handler.setIncludesDependencies(true);
|
|
|
|
handler.setIncludesDependencies(true);
|
|
|
|
ArtifactResolutionResult resolutionResult = resolveArtifact(new DefaultArtifact(JUNIT_PLATFORM_GROUP_ID,
|
|
|
|
Set<Artifact> artifacts = resolveArtifact(new DefaultArtifact(JUNIT_PLATFORM_GROUP_ID,
|
|
|
|
JUNIT_PLATFORM_LAUNCHER_ARTIFACT_ID, version, null, "jar", null, handler));
|
|
|
|
JUNIT_PLATFORM_LAUNCHER_ARTIFACT_ID, version, null, "jar", null, handler));
|
|
|
|
Set<URL> fullClassPath = new LinkedHashSet<>(Arrays.asList(classPath));
|
|
|
|
Set<URL> fullClassPath = new LinkedHashSet<>(Arrays.asList(classPath));
|
|
|
|
for (Artifact artifact : resolutionResult.getArtifacts()) {
|
|
|
|
for (Artifact artifact : artifacts) {
|
|
|
|
fullClassPath.add(artifact.getFile().toURI().toURL());
|
|
|
|
fullClassPath.add(artifact.getFile().toURI().toURL());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fullClassPath.toArray(URL[]::new);
|
|
|
|
return fullClassPath.toArray(URL[]::new);
|
|
|
@ -185,16 +177,20 @@ public class ProcessTestAotMojo extends AbstractAotMojo {
|
|
|
|
return version;
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ArtifactResolutionResult resolveArtifact(Artifact artifact) throws Exception {
|
|
|
|
private Set<Artifact> resolveArtifact(Artifact artifact) throws Exception {
|
|
|
|
ArtifactResolutionRequest request = new ArtifactResolutionRequest();
|
|
|
|
CollectRequest collectRequest = new CollectRequest();
|
|
|
|
request.setArtifact(artifact);
|
|
|
|
collectRequest.setRoot(RepositoryUtils.toDependency(artifact, null));
|
|
|
|
request.setLocalRepository(this.localRepository);
|
|
|
|
collectRequest.setRepositories(this.project.getRemotePluginRepositories());
|
|
|
|
request.setResolveTransitively(true);
|
|
|
|
DependencyRequest request = new DependencyRequest();
|
|
|
|
request.setCollectionFilter(new RuntimeArtifactFilter());
|
|
|
|
request.setCollectRequest(collectRequest);
|
|
|
|
request.setRemoteRepositories(this.remoteRepositories);
|
|
|
|
request.setFilter(DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME));
|
|
|
|
ArtifactResolutionResult result = this.repositorySystem.resolve(request);
|
|
|
|
DependencyResult dependencyResult = this.repositorySystem
|
|
|
|
this.resolutionErrorHandler.throwErrors(request, result);
|
|
|
|
.resolveDependencies(getSession().getRepositorySession(), request);
|
|
|
|
return result;
|
|
|
|
return dependencyResult.getArtifactResults()
|
|
|
|
|
|
|
|
.stream()
|
|
|
|
|
|
|
|
.map(ArtifactResult::getArtifact)
|
|
|
|
|
|
|
|
.map(RepositoryUtils::toArtifact)
|
|
|
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|