Tkz for the answer.
I tried what u said, but my ArtifactManager doenst have the "resolve" method
with one parameter, look:
void resolve( Artifact, List
On 6/5/07, Roland Asmann <[EMAIL PROTECTED]> wrote:
Thanks for the numerous replies.
> > > > ${project.dependencies} ?
The ${project.dependencies} is not the correct one, since it gives me the
dependencies of the project, not the plugin! Also, it resolves the
dependencies transitively!
> ArtifactoryFactory : interface
> ArtifactResolver : interface
>
> Where can we find the implementations? I already have a list of
> dependencies, just need resolve the full path for each dependency.
>
> > Use the information in the dependency list and an ArtifactFactory to
> > create
> > an Artifact with , then use an ArtifactResolver to resolve them fully.
> > Afterwards, you can call getFile(), to get the File objet.
When using those interfaces, add something similar to these lines in your
MOJO:
/**
* @component role="
org.apache.maven.artifact.resolver.ArtifactResolver"
* @required
* @readonly
*/
private ArtifactResolver artifactResolver;
Now, you can use
artifactResolver.resolve(artifact)
for you artifact (if it has not been resolved already), after which you
can
ask the artifact
artifact.getFile()
which will give you the full path to the JAR/POM/whatever file of this
artifact.
For my situation though (dependencies of the plugin), I use the following
code:
for (Object object : this.project.getPluginArtifacts()) {
Artifact artifact = (Artifact) object;
if ("my.group.id".equals(artifact.getGroupId())
&& "myArtifactId".equals(artifact.getArtifactId())) {
for (Object object2 : this.artifactMetadataSource.retrieve
(artifact,
this.localRepository,
this.project.getRemoteArtifactRepositories()).getArtifacts()) {
Artifact artifact2 = (Artifact) object2;
this.artifactResolver.resolve(artifact2,
this.project.getRemoteArtifactRepositories(), this.localRepository);
JarFile jarFile = new JarFile(artifact2.getFile());
JarEntry workflow = null;
for (Enumeration<JarEntry> jarEntries = jarFile.entries();
workflow == null && jarEntries.hasMoreElements();) {
JarEntry jarEntry = jarEntries.nextElement();
if (jarEntry.getName() != null &&
jarEntry.getName().endsWith("filename.extension")) {
workflow = jarEntry;
}
}
if (workflow != null) {
workflowFiles.add(workflow.getName());
}
}
}
}
In short, this code runs through the plugins until it finds the one I'm
looking for ("my.group.id" & "myArtifactId"). It then retrieves this
artifact
from the repository and gets its dependencies.
Those are resolved (to make sure all properties have been initialized --
eg
fileName doesn't work without it) and opened as JAR-files (atm I'm sure
they
are JARs, but need to change this code to make sure it doesn't fail if
they're not).
I then iterate over the JAR to look for a specific file ("
filename.extension")
and save the full names of the entry in a Map.
This works like a charm for me, you just need to make sure you add all the
right components in the MOJO.
If anybody needs some more info/help, feel free to ask!
--
Roland Asmann
CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien
Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: [EMAIL PROTECTED]
Web: www.cfc.at
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Paulo Cesar Silva Reis
-------------------------------
Powered by GMAIL