I'm trying to enclose some legacy code in a maven plugin. The legacy code is writing its outputs in the OS current working directory. I want to move all that into the target dir. I.e. if my project nesting is
A
-B
-C
and I run mvn install in B or C, I get the outputs in B or C and want to move them to B/target and C/target. Even worse, if I launch mvn install in A, outputs for both B and C wind up in A, which is obviously very bad (overwrites).
I've looked for a way to get the current project folder (not the place mvn install was launched from), but have found nothing so far that doesn't involve pushing this all back at the user (command line hacks, pom hacks, properties files, etc). I've also wished for a way to change the working directory before launching the legacy, but Java doesn't allow that. So how should I proceed?
Just a quick note: for latest maven plugins, annotations could be used instead:
@Parameter(readonly = true, defaultValue = "${project}")
private MavenProject project;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With