You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2026/09/29 11:51:47 UTC
(maven-antrun-plugin) branch fix-artifactrepository-deprecation created (now 13f768c)
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a change to branch fix-artifactrepository-deprecation
in repository https://gitbox.apache.org/repos/asf/maven-antrun-plugin.git
at 13f768c Replace deprecated ArtifactRepository with resolver API
This branch includes the following new commits:
new 13f768c Replace deprecated ArtifactRepository with resolver API
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(maven-antrun-plugin) 01/01: Replace deprecated ArtifactRepository with resolver API
Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch fix-artifactrepository-deprecation
in repository https://gitbox.apache.org/repos/asf/maven-antrun-plugin.git
commit 13f768c07926539429a00be163d304e1e06b9a5a
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Tue Sep 29 11:51:36 2026 +0000
Replace deprecated ArtifactRepository with resolver API
org.apache.maven.artifact.repository.ArtifactRepository is deprecated in
favour of "repository system classes", so stop using it. The local
repository now comes from the RepositorySystemSession, which is available
on every Maven version this plugin supports (3.6.3 and up).
The deprecated type was used in three places, so all three had to change:
- The maven.local.repository Ant reference, which DependencyFilesetsTask
reads, now holds an org.eclipse.aether.repository.LocalRepository. A
second reference, maven.local.repository.manager, exposes the
LocalRepositoryManager, so the task can still turn an artifact into a
path relative to the local repository -- ArtifactRepository#pathOf has
no direct equivalent on LocalRepository. getPathForLocalArtifact()
applies the same layout rules pathOf() did, including using the base
version for the directory and the resolved version for the filename of
a SNAPSHOT.
- settings.localRepository is unchanged: it is still the absolute path of
the local repository.
- localRepository changes value. It was ArtifactRepository#toString(),
a multi-line debug dump whose first line read "id: local", which was
not usable as a path by anyone. It is now the same absolute path that
settings.localRepository provides. Neither property is documented on
the site, but this is a visible change for anyone who referenced it.
The @Parameter(property = "localRepository") hook is gone with the field.
It let -DlocalRepository override the repository used by the plugin, which
cannot be expressed as a repository system session, and was not
documented.
---
.../maven/ant/tasks/DependencyFilesetsTask.java | 13 ++++++----
.../apache/maven/plugins/antrun/AntRunMojo.java | 28 +++++++++++++++++-----
2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/src/main/java/org/apache/maven/ant/tasks/DependencyFilesetsTask.java b/src/main/java/org/apache/maven/ant/tasks/DependencyFilesetsTask.java
index 818f506..b3eeae1 100644
--- a/src/main/java/org/apache/maven/ant/tasks/DependencyFilesetsTask.java
+++ b/src/main/java/org/apache/maven/ant/tasks/DependencyFilesetsTask.java
@@ -18,14 +18,13 @@
*/
package org.apache.maven.ant.tasks;
-import java.io.File;
import java.util.LinkedHashSet;
import java.util.Set;
+import org.apache.maven.RepositoryUtils;
import org.apache.maven.ant.tasks.support.SpecificScopesArtifactFilter;
import org.apache.maven.ant.tasks.support.TypesArtifactFilter;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
import org.apache.maven.plugins.antrun.AntRunMojo;
import org.apache.maven.plugins.antrun.taskconfig.DependencyFilesetsConfiguration;
@@ -33,6 +32,8 @@ import org.apache.maven.project.MavenProject;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.FileSet;
+import org.eclipse.aether.repository.LocalRepository;
+import org.eclipse.aether.repository.LocalRepositoryManager;
/**
* Ant task which create a fileset for each dependency in a Maven project, and a
@@ -62,8 +63,9 @@ public class DependencyFilesetsTask extends Task {
FileSet dependenciesFileSet = new FileSet();
dependenciesFileSet.setProject(getProject());
- ArtifactRepository localRepository = getProject().getReference("maven.local.repository");
- dependenciesFileSet.setDir(new File(localRepository.getBasedir()));
+ LocalRepository localRepository = getProject().getReference("maven.local.repository");
+ LocalRepositoryManager localRepositoryManager = getProject().getReference("maven.local.repository.manager");
+ dependenciesFileSet.setDir(localRepository.getBasedir());
if (depArtifacts.isEmpty()) {
// For performance reasons in case of huge local repo, tell Ant to include a single thing, otherwise the
@@ -73,7 +75,8 @@ public class DependencyFilesetsTask extends Task {
}
for (Artifact artifact : depArtifacts) {
- String relativeArtifactPath = localRepository.pathOf(artifact);
+ String relativeArtifactPath =
+ localRepositoryManager.getPathForLocalArtifact(RepositoryUtils.toArtifact(artifact));
dependenciesFileSet.createInclude().setName(relativeArtifactPath);
String fileSetName = getPrefix() + artifact.getDependencyConflictId();
diff --git a/src/main/java/org/apache/maven/plugins/antrun/AntRunMojo.java b/src/main/java/org/apache/maven/plugins/antrun/AntRunMojo.java
index 5ff1844..4f7ef41 100644
--- a/src/main/java/org/apache/maven/plugins/antrun/AntRunMojo.java
+++ b/src/main/java/org/apache/maven/plugins/antrun/AntRunMojo.java
@@ -33,7 +33,6 @@ import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -51,6 +50,8 @@ import org.apache.tools.ant.taskdefs.Typedef;
import org.apache.tools.ant.types.Path;
import org.codehaus.plexus.configuration.PlexusConfiguration;
import org.codehaus.plexus.util.ReaderFactory;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.repository.LocalRepository;
/**
* <p>
@@ -129,11 +130,20 @@ public class AntRunMojo extends AbstractMojo {
@Parameter(property = "plugin.artifacts", required = true, readonly = true)
private List<Artifact> pluginArtifacts;
+ /**
+ * The repository system session, used to locate the local Maven repository.
+ */
+ @Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
+ protected RepositorySystemSession repositorySystemSession;
+
/**
* The local Maven repository
+ *
+ * @since 3.2.1
*/
- @Parameter(property = "localRepository", readonly = true)
- protected ArtifactRepository localRepository;
+ protected LocalRepository getLocalRepository() {
+ return repositorySystemSession.getLocalRepository();
+ }
/**
* String to prepend to project and dependency property names.
@@ -350,7 +360,9 @@ public class AntRunMojo extends AbstractMojo {
antProject.addReference(DEFAULT_MAVEN_PROJECT_REFID, mavenProject);
antProject.addReference(DEFAULT_MAVEN_PROJECT_REF_REFID, new MavenAntRunProject(mavenProject));
antProject.addReference(DEFAULT_MAVEN_PROJECT_HELPER_REFID, projectHelper);
- antProject.addReference(MAVEN_REFID_PREFIX + "local.repository", localRepository);
+ antProject.addReference(MAVEN_REFID_PREFIX + "local.repository", getLocalRepository());
+ antProject.addReference(
+ MAVEN_REFID_PREFIX + "local.repository.manager", repositorySystemSession.getLocalRepositoryManager());
}
/**
@@ -424,8 +436,12 @@ public class AntRunMojo extends AbstractMojo {
antProject.setProperty(
(propertyPrefix + "project.build.testSourceDirectory"),
mavenProject.getBuild().getTestSourceDirectory());
- antProject.setProperty((propertyPrefix + "localRepository"), localRepository.toString());
- antProject.setProperty((propertyPrefix + "settings.localRepository"), localRepository.getBasedir());
+ antProject.setProperty(
+ (propertyPrefix + "localRepository"),
+ getLocalRepository().getBasedir().getAbsolutePath());
+ antProject.setProperty(
+ (propertyPrefix + "settings.localRepository"),
+ getLocalRepository().getBasedir().getAbsolutePath());
// Add properties for dependency artifacts
Set<Artifact> depArtifacts = mavenProject.getArtifacts();