It turns out it is super easy to create one plugin by using the maven archetype in eclipse , here is quick tutorial to create one plugin that we can add to any project, the plugin will rename the packaged jars to our desired format. I will put a data in the jar names as an example.
for the demo, I will create one parent Project named Container, and two modules under this container, one is named MyPlugin, another module will be Client which reference the Plugin.
so one project which is the parent, pom as the target, and two modules.
for the Client, it’s just a regular simple Maven module.
for the MyPlugin project, we want it to use the archetype maven-arechetype-mojo as the base type.
once done, we can right click the pom.xml in client library, and plugin dependency, you can see our new plugin is there.
Now, the plugin is ready, we can go the client folder, and run our plugin,
before we run this, run a “mvn install” under Container folder to install the plugins to local repository.
on the Client folder, run “mvn MyPlugin:touch”
you can see the touch.txt is there, which is created by our plugin.
go back to demo for the file renaming, we want the plugin to rename the jar file from Client-0.0.1-SNAPSHOT.jar to Client-0.0.1-SNAPSHOT-20140310.jar
so let’s rewrite our plugin execution logic,
run this target again, we can see the file is renamed to our format
if we want add this plugin to our package target, we can change the execution for this plugin to package.
then once we run the package , this plugin will be invoked automatically.