ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
My First MOJO Plugin

Tibor Diga¨¾a

Github repository
https://github.com/Tibor17/maven/tree/master/plugins/firstMojo
My Mojo Plugin
sample.plugin.MyMojo
Plugin Project pom.xml
Locations of files
? If your plugin pom.xml is located in ${basedir},
  then place the java source class
  sample.plugin.MyMojo
  in to
  ${basedir}/src/main/java
Install plugin
? cd ${basedir}
? mvn install
Plugin usage in another pom.xml
Running the plugin¡¯s goal sayhi on
         another pom.xml
mvn sample.plugin:hello-maven-plugin:1.0:sayhi
Running the plugin¡¯s goal sayhi on
             another pom.xml
[INFO] Scanning for projects...
[INFO] -------------------------------------------------------------
[INFO] Building my plugin usage
[INFO] task-segment: [sample.plugin:hello-maven-plugin:1.0:sayhi]
[INFO] -------------------------------------------------------------
[INFO] [hello:sayhi {execution: default-cli}]
[INFO] Hi There!
[INFO] base dir c:Userstibor17IdeaProjectsfirstMojopluginUsage
[INFO] -------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] -------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Fri Jun 15 13:47:40 CEST 2012
[INFO] Final Memory: 2M/15M
[INFO] -------------------------------------------------------------
Running the plugin¡¯s goal sayhi on
          another pom.xml
? Logger printed ¡°Hi There!¡±
? instead of default-value "Hello World!¡°
? See the field ¡°greeting¡± in MyMojo class

More Related Content

My First MOJO Plugin

  • 1. My First MOJO Plugin Tibor Diga¨¾a Github repository https://github.com/Tibor17/maven/tree/master/plugins/firstMojo
  • 4. Locations of files ? If your plugin pom.xml is located in ${basedir}, then place the java source class sample.plugin.MyMojo in to ${basedir}/src/main/java
  • 5. Install plugin ? cd ${basedir} ? mvn install
  • 6. Plugin usage in another pom.xml
  • 7. Running the plugin¡¯s goal sayhi on another pom.xml mvn sample.plugin:hello-maven-plugin:1.0:sayhi
  • 8. Running the plugin¡¯s goal sayhi on another pom.xml [INFO] Scanning for projects... [INFO] ------------------------------------------------------------- [INFO] Building my plugin usage [INFO] task-segment: [sample.plugin:hello-maven-plugin:1.0:sayhi] [INFO] ------------------------------------------------------------- [INFO] [hello:sayhi {execution: default-cli}] [INFO] Hi There! [INFO] base dir c:Userstibor17IdeaProjectsfirstMojopluginUsage [INFO] ------------------------------------------------------------- [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------- [INFO] Total time: < 1 second [INFO] Finished at: Fri Jun 15 13:47:40 CEST 2012 [INFO] Final Memory: 2M/15M [INFO] -------------------------------------------------------------
  • 9. Running the plugin¡¯s goal sayhi on another pom.xml ? Logger printed ¡°Hi There!¡± ? instead of default-value "Hello World!¡° ? See the field ¡°greeting¡± in MyMojo class