Blah, blah, blah
gmaven-archetype-mojo Archetype
To help get Groovy plugins started faster, you can use the gmaven-archetype-mojo. This will create a new project with the basic POM configuration and an example Groovy-based Mojo class to get you started quickly:
mvn archetype:generate -DarchetypeGroupId=org.codehaus.groovy.maven.archetypes -DarchetypeArtifactId=gmaven-archetype-mojo
|
To use a specific version of an archetype specify |
The Maven Archetype Plugin will ask a few questions about your new project:
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate]
[WARNING] No archetype repository found. Falling back to central repository (http://repo1.maven.org/maven2).
[WARNING] Use -DarchetypeRepository=<your repository> if archetype's repository is elsewhere.
[INFO] snapshot org.codehaus.groovy.maven.archetypes:gmaven-archetype-mojo:1.0-beta-4-SNAPSHOT: checking for updates from gmaven-archetype-mojo-repo
Define value for groupId: : org.mycompany.myproject
Define value for artifactId: : example-maven-plugin
Define value for version: : 1.0-SNAPSHOT
Define value for package: : org.mycompany.myproject.example
Confirm properties configuration:
name: Example Maven Plugin
groupId: org.mycompany.myproject
artifactId: example-maven-plugin
version: 1.0-SNAPSHOT
package: org.mycompany.myproject.example
Y: : y
[WARNING] org.apache.velocity.runtime.exception.ReferenceException: reference : template = archetype-resources/src/main/groovy/HelloMojo.groovy [line 37,column 31] : ${message} is not a valid reference.
[WARNING] org.apache.velocity.runtime.exception.ReferenceException: reference : template = archetype-resources/src/main/groovy/HelloMojo.groovy [line 42,column 18] : ${message} is not a valid reference.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 56 seconds
[INFO] Finished at: Tue Apr 08 14:04:37 ICT 2008
[INFO] Final Memory: 7M/13M
[INFO] ------------------------------------------------------------------------
|
Please ignore the |
The above example would have created the following project structure:
example-maven-plugin example-maven-plugin/pom.xml example-maven-plugin/src example-maven-plugin/src/main example-maven-plugin/src/main/groovy example-maven-plugin/src/main/groovy/org example-maven-plugin/src/main/groovy/org/mycompany example-maven-plugin/src/main/groovy/org/mycompany/myproject example-maven-plugin/src/main/groovy/org/mycompany/myproject/example example-maven-plugin/src/main/groovy/org/mycompany/myproject/example/HelloMojo.groovy
To build the new project simply change to the newly created project directory and run Maven:
cd example-maven-plugin mvn install
The build output should look something like this:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Example Maven Plugin
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [groovy:generateStubs {execution: default}]
[INFO] Generated 1 Java stub
[INFO] [plugin:descriptor]
[INFO] Using 2 extractors.
[INFO] Applying extractor for language: java
[INFO] Extractor for language: java found 1 mojo descriptors.
[INFO] Applying extractor for language: bsh
[INFO] Extractor for language: bsh found 0 mojo descriptors.
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
[INFO] Compiling 1 source file to /Users/jason/ws/tmp/example-maven-plugin/target/classes
[INFO] [groovy:compile {execution: default}]
[INFO] Compiled 1 Groovy source file
[INFO] [groovy:generateTestStubs {execution: default}]
[INFO] No sources found for Java stub generation
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
[INFO] No sources to compile
[INFO] [groovy:testCompile {execution: default}]
[INFO] No sources found to compile
[INFO] [surefire:test]
[INFO] No tests to run.
[INFO] [jar:jar]
[INFO] Building jar: /Users/jason/ws/tmp/example-maven-plugin/target/example-maven-plugin-1.0-SNAPSHOT.jar
[INFO] [plugin:addPluginArtifactMetadata]
[INFO] [install:install]
[INFO] Installing /Users/jason/ws/tmp/example-maven-plugin/target/example-maven-plugin-1.0-SNAPSHOT.jar to /Users/jason/.m2/repository/org/mycompany/myproject/example-maven-plugin/1.0-SNAPSHOT/example-maven-plugin-1.0-SNAPSHOT.jar
[INFO] [plugin:updateRegistry]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10 seconds
[INFO] Finished at: Tue Apr 08 14:07:00 ICT 2008
[INFO] Final Memory: 15M/26M
[INFO] ------------------------------------------------------------------------
gmaven-plugin Packaging
TODO |
