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

Use maven 3.9 #461

Closed
wants to merge 2 commits into from
Closed
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
26 changes: 13 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<properties>
<java.version>21</java.version>
<maven.version>3.6.3</maven.version>
<maven.version>3.9.8</maven.version>
<!-- version should match ivy Engine sfl4j version! And version in EngineClassLoaderFactory.SLF4J_VERSION -->
<slf4j.version>2.0.13</slf4j.version>
<site.path>snapshot</site.path>
Expand Down Expand Up @@ -81,7 +81,7 @@
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-filtering</artifactId>
<version>3.2.0</version>
<version>3.3.2</version>
<!--NOT provided: will fail on consuming builds -->
</dependency>
<dependency>
Expand Down Expand Up @@ -134,17 +134,17 @@
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.14</version>
<scope>compile</scope>
</dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.14</version>
<scope>compile</scope>
</dependency>

<!-- Logging environment: Required for engine classLoader (but not for the plugin runtime itself) -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

import java.io.File;

import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.repository.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;

import ch.ivyteam.ivy.maven.AbstractEngineMojo;
import ch.ivyteam.ivy.maven.engine.EngineClassLoaderFactory;
Expand Down Expand Up @@ -53,8 +53,8 @@ public abstract class AbstractEngineInstanceMojo extends AbstractEngineMojo {
@Component
private RepositorySystem repository;

@Parameter(defaultValue = "${localRepository}")
public ArtifactRepository localRepository;
@Parameter( defaultValue = "${repositorySystemSession}", readonly = true, required = true )
protected RepositorySystemSession repoSession;

private static MavenProjectBuilderProxy builder;

Expand Down Expand Up @@ -97,8 +97,7 @@ protected MavenProjectBuilderProxy getMavenProjectBuilder() throws Exception {
}

public final EngineClassLoaderFactory getEngineClassloaderFactory() {
MavenContext context = new EngineClassLoaderFactory.MavenContext(
repository, localRepository, project, getLog());
MavenContext context = new EngineClassLoaderFactory.MavenContext(repository, project, getLog());
return new EngineClassLoaderFactory(context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.commons.io.filefilter.SuffixFileFilter;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.apache.maven.repository.RepositorySystem;
Expand Down Expand Up @@ -141,25 +141,27 @@ private static URL[] toUrls(List<File> ivyEngineClassPathFiles) throws Malformed

public static class MavenContext {
private final RepositorySystem repoSystem;
private final ArtifactRepository localRepository;
private final MavenProject project;
private final Log log;

public MavenContext(RepositorySystem repoSystem, ArtifactRepository localRepository, MavenProject project,
public MavenContext(RepositorySystem repoSystem, MavenProject project,
Log log) {
this.repoSystem = repoSystem;
this.localRepository = localRepository;
this.project = project;
this.log = log;
}

public File getJar(String groupId, String artifactId, String version) {
Artifact artifact = repoSystem.createArtifact(groupId, artifactId, version, "jar");
File jar = new File(localRepository.getBasedir(), localRepository.pathOf(artifact));
if (!jar.exists()) {
log.warn("Failed to resolve '" + artifactId + "' from local repository in '" + jar + "'.");
var request = new ArtifactResolutionRequest();
request.setArtifact(artifact);
var response = repoSystem.resolve(request);
if (response.isSuccess()) {
return response.getArtifacts().iterator().next().getFile();
} else {
log.warn("Failed to resolve '" + artifactId + "' from local repository.");
}
return jar;
return null;
}
}

Expand Down
36 changes: 1 addition & 35 deletions src/test/java/ch/ivyteam/ivy/maven/compile/CompileMojoRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@

package ch.ivyteam.ivy.maven.compile;

import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.plugin.LegacySupport;
import org.apache.maven.plugin.internal.DefaultLegacySupport;

import ch.ivyteam.ivy.maven.BaseEngineProjectMojoTest;
import ch.ivyteam.ivy.maven.BaseEngineProjectMojoTest.EngineMojoRule;

public class CompileMojoRule<T extends AbstractEngineInstanceMojo> extends EngineMojoRule<T> {
Expand All @@ -36,30 +28,4 @@ protected void before() throws Throwable {
super.before();
configureMojo(getMojo());
}

public void configureMojo(AbstractEngineInstanceMojo newMojo) throws IllegalAccessException {
newMojo.localRepository = provideLocalRepository();
}

/**
* maven-plugin-testing-harness can not inject local repositories (though the
* real runtime supports it). and the default stubs have no sufficient
* implementation of getPath():
* @see "http://maven.apache.org/plugin-testing/maven-plugin-testing-harness/examples/repositories.html"
*/
private ArtifactRepository provideLocalRepository() throws IllegalAccessException {
DefaultArtifactRepositoryFactory factory = new DefaultArtifactRepositoryFactory();
setVariableValueToObject(factory, "factory",
new org.apache.maven.repository.legacy.repository.DefaultArtifactRepositoryFactory());

LegacySupport legacySupport = new DefaultLegacySupport();
setVariableValueToObject(factory, "legacySupport", legacySupport);

ArtifactRepository localRepository = factory.createArtifactRepository("local", "http://localhost",
new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy());

setVariableValueToObject(localRepository, "basedir", BaseEngineProjectMojoTest.LOCAL_REPOSITORY);

return localRepository;
}
}
}
Loading