1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
/**
* @goal parse-xml
* @requiresDependencyResolution
* @phase process-resources
*/
public class ExamplePlugin extends AbstractMojo {
/**
* @parameter default-value="${project}"
*/
private MavenProject project;
/**
* Location of the local repository.
*
* @parameter expression="${localRepository}"
* @readonly
* @required
*/
protected ArtifactRepository localRepository;
@Override
public void execute() throws MojoFailureException {
Set<?> artifacts = project.getArtifacts(); // add @requiresDependencyResolution to Goal class
for (Iterator<?> artifactIterator = artifacts.iterator(); artifactIterator.hasNext();) {
Artifact artifact = (Artifact) artifactIterator.next();
System.out.println(artifact.getType());
System.out.println(artifact.getArtifactId());
System.out.println(" ... ");
File artifactfile = new File(localRepository.getBasedir(), localRepository.pathOf(artifact));
}
}
} |