Hi Danny,
Does it *have* to be done from within the Maven build infrastructure? That
is, do you really need it to be a Maven goal? Because this problem sounds
much, much easier to achieve with a shell script.
Start with:
mvn dependency:list
or
mvn dependency:tree
And massage the result using GNU tools (sed, grep, etc.) to do what you
want.
E.g., for plain text, something like:
mvn dependency:list \
| grep '^\[INFO\] \w' \
| sed 's/^\[INFO\] *//' \
> dependencies.txt
Or for XML, something like ("-E" flag on OS X only):
mvn dependency:list \
| grep '^\[INFO\] \w' \
| sed -E 's/^\[INFO\]
*([^:]*):([^:]*):([^:]*):([^:]*):([^:]*)/<dependency><groupId>\1<\/groupId><artifactId>\2<\/artifactId><packaging>\3<\/packaging><version>\4<\/version><scope>\5<\/scope><\/dependency>/'
I am not a shell scripting ninja so there are surely tons of
shorter/better/cuter ways of doing it, but you get the idea.
Regards,
Curtis
On Wed, Jan 16, 2013 at 1:33 PM, Danny Schimke <[email protected]
> wrote:
> Hi,
>
> for 3 years now I have no more experience with Maven. But today I got a
> challenge. I have to resolve the projects dependencies and write those into
> a file. There already a template file exists with placeholders where to
> replace with the dependencies. Finally the file will be copied to a
> specified directory. The output should be plain text as well XML depending
> upon the POMs configuration. It should be possible to configure in the pom
> which artifacts are written/captured. Important is to gather the version of
> depending artifacts in a file.
>
> Entire thoughts were to write a new maven plugin. But then I need to call
> the dependency:resolve plugin within my plugin and use its result to
> achieve my goal. How can I do this?
>
> Are there other possible and good solutions to do it (maybe using Groovy
> script and call "mvn" on command line)?
>
> Thanks a lot!
>
> --
> Mit freundlichen Grüßen / Kind regards
> -Danny Schimke*
>
>
> Place To Remember* (Android- App)
> goo.gl/M9OGs - *Free*
> goo.gl/A8bZ3 - *Donate*
>
> Viel Spaß und vielen Dank!
>