Maven archetype - Run external commands after creation
Asked Answered
B

1

7

I'm looking for a way, to execute additional commands (e.g. a perl script) after running mvn archetype:generate on my custom archetype automatically.

Is this possible?

Context

I'm writing an archetype, that creates OSGi bundles which i want to integrate into a parent project as modules. After generating the bundle, i wish to organise it into the parents directory structure and then manipulate poms and other configuration files automatically.

This has been asked on maven forums before 1, however no answer was given.

Belew answered 20/5, 2013 at 20:41 Comment(7)
Are you asking for something more complex than Runtime.getRuntime().exec()?Peacoat
that would do fine. however i do not know, how to hook this into the post-execution of the goal.Belew
Why not just make the exec call in the main goal, after doing whatever Java-native steps you're doing?Peacoat
where and how would i call this? i want to run it implicitly after running archetype:generate.Belew
You're writing the code for generate. Why don't you include the exec call in that code? Is there something that you need to happen after your main archetype code runs but before other goals?Peacoat
i'm sorry you've lost me. i'm not writing the code for the maven goal, i'm running the predefined maven archetype goal "generate". all i'm currently doing is editing the archetype resources.Belew
My fault. The only time I wrote an archetype in Maven, I wrote it as a full-fledged plug-in (because I needed to do more than simple templates). I completely forgot that there is a simpler system. Anyway, for what you're doing, I think the answer is "no" for the same reasons given in #16264559Peacoat
C
2

Thrau, you can invoke mojo post execution of archetype:generate by adding -Dgoals="your custom mojo plugin", within the plugin you can write your custom code. Hope this helps.

Coseismal answered 7/1, 2014 at 6:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.