You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Filip Jirsák <fi...@jirsak.org> on 2008/09/12 15:35:31 UTC
dependencies and attached artifacts
Hello,
I write maven plugin, which packages jar file along with some other files and
create new file. This new file is attached at project as attached artifact with
type "nbm-file":
projectHelper.attachArtifact( project, "nbm-file", null, nbmfile );
This is ProjectA.
Than I have some other project, ProjectB, which depends on ProjectA – either
directly or it has ProjectB in transitive dependencies. In my plugin for
ProjectB I need collect all attached artifacts of type "nbm-file" from whichever
project ProjectB has in its transitive dependencies (i. e. attached artifact of
ProjectA and may be attached artifacts of type "nbm-file" from other transitive
dependencies). What is the right way how to do this? I have some code now, but I
it looks strange to do it this way:
Set artifacts = project.getArtifacts();
Iterator it = artifacts.iterator();
while ( it.hasNext() ) {
Artifact art = (Artifact) it.next();
if (!"nbm-file".equals(art.getType())) {
art = artifactFactory.createArtifact(art.getGroupId(), art.getArtifactId(),
art.getVersion(), art.getScope(), "nbm-file");
try {
resolver.resolve(art, remoteRepos, local);
} catch (ArtifactResolutionException ex) {
getLog().error( ex );
continue;
// unknown error
} catch (ArtifactNotFoundException ex) {
continue;
//attached artifact of type "nbm-file" not found, probably some normal
"jar" dependency
}
}
}
Should I instead transform each Artifact to MavenProject and use
getAttachedArtifacts() method? Or should this be solved in completely different
manner?
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
RE: dependencies and attached artifacts
Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
If the attached artifacts are not explicitly listed as dependencies, then your best bet is to use the projectBuilder to materialize the MavenProject and then get the attached artifacts.
-----Original Message-----
From: news [mailto:news@ger.gmane.org] On Behalf Of Filip Jirsák
Sent: Friday, September 12, 2008 9:36 AM
To: dev@maven.apache.org
Subject: dependencies and attached artifacts
Hello,
I write maven plugin, which packages jar file along with some other files and
create new file. This new file is attached at project as attached artifact with
type "nbm-file":
projectHelper.attachArtifact( project, "nbm-file", null, nbmfile );
This is ProjectA.
Than I have some other project, ProjectB, which depends on ProjectA – either
directly or it has ProjectB in transitive dependencies. In my plugin for
ProjectB I need collect all attached artifacts of type "nbm-file" from whichever
project ProjectB has in its transitive dependencies (i. e. attached artifact of
ProjectA and may be attached artifacts of type "nbm-file" from other transitive
dependencies). What is the right way how to do this? I have some code now, but I
it looks strange to do it this way:
Set artifacts = project.getArtifacts();
Iterator it = artifacts.iterator();
while ( it.hasNext() ) {
Artifact art = (Artifact) it.next();
if (!"nbm-file".equals(art.getType())) {
art = artifactFactory.createArtifact(art.getGroupId(), art.getArtifactId(),
art.getVersion(), art.getScope(), "nbm-file");
try {
resolver.resolve(art, remoteRepos, local);
} catch (ArtifactResolutionException ex) {
getLog().error( ex );
continue;
// unknown error
} catch (ArtifactNotFoundException ex) {
continue;
//attached artifact of type "nbm-file" not found, probably some normal
"jar" dependency
}
}
}
Should I instead transform each Artifact to MavenProject and use
getAttachedArtifacts() method? Or should this be solved in completely different
manner?
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org