How to allow local artifacts in Maven 3?

How to resolve artifact path in local repository in Maven 3?

In Maven 2, you can use ArtifactResolver to populate the Artifact object with relevant information, but this class is deprecated in Maven 3.

+4
source share
2 answers

The best replacement for ArtifactFactory (also deprecated since M3) is RepositorySystem . createDependencyArtifact , ... operations are available.

+3
source

Answering my own question:

 /** * @component */ private ArtifactFactory artifactFactory; /** * The local maven repository. * * @parameter expression="${localRepository}" * @required * @readonly */ private ArtifactRepository localRepository; [...] Artifact artifact = artifactFactory.createArtifactWithClassifier(groupId, artifactId, version, type, classifier); artifact.setFile(new File(localRepository.getBasedir(), localRepository.pathOf(artifact))); 
+2
source

All Articles