Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven archetype - Run external commands after creation

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.

like image 435
thrau Avatar asked May 20 '13 20:05

thrau


People also ask

Which maven command do you use for creating project using archetype plugin?

maven. archetype</groupId> <artifactId>archetype-packaging</artifactId>

What goal belonging to the archetype plugin need to be invoked when creating a new maven project from an archetype?

Goals Overview The archetype plugin has four goals for direct use: archetype:generate creates a Maven project from an archetype: asks the user to choose an archetype from the archetype catalog, and retrieves it from the remote repository. Once retrieved, it is processed to create a working Maven project.

What is the command to create a new project based on an archetype commandline?

To create a new project based on an Archetype, you need to call mvn archetype:generate goal, like the following: mvn archetype:generate.

What does mvn archetype generate do?

Generates a new project from an archetype, or updates the actual project if using a partial archetype. If the project is fully generated, it is generated in a directory corresponding to its artifactId.


1 Answers

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.

like image 193
Thiru Avatar answered Oct 11 '22 10:10

Thiru