6. Maven Help Plugin
• mvn help:describe -Dplugin=<anygoal>
‣ Lists and describes plugin goals.
• mvn help:system
‣ Outputs environment variables and system
properties.
• mvn help:active-profiles
‣ See what profiles are being triggered by
environment, files, params.
• mvn help:effective-pom
‣ Outputs the resultant pom.
‣ Includes inherited sections.
7. Exec Plugin
• Run any Java main class or external tool.
• Builds classpath from pom dependencies.
• Primarily used for testing.
$ mvn exec:java -Dexec.mainClass="com.foo.Main“
9. Report Sets
• Example: to configure
the javadoc:javadoc goal
to link to
"http://java.sun.com/j2s
e/1.5.0/docs/api/", but
only the javadoc goal
(not the goal maven-
javadoc-plugin:jar).
• We would also like this
configuration passed to
its children, and
set inherited to true.
Used to configure execution of a report plugin's goals.
10. Lisences
Licenses are legal documents defining how and when a project
(or parts of a project) may be used.
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
11. Organization
Projects are run by some sort of organization (business, private group, etc.)
<organization>
<name>Codehaus Mojo</name>
<url>http://mojo.codehaus.org</url>
</organization>
12. Developers
Developers are presumably members of the project's core development.
<developers>
<developer>
<id>jdoe</id>
<name>John Doe</name>
<email>jdoe@example.com<email>
<url>http://www.example.com/jdoe</url>
<organization>ACME</organization>
<organizationUrl>http://www.example.com</organizationUrl>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>America/New_York</timezone>
<properties>
<picUrl>http://www.example.com/jdoe/pic</picUrl>
</properties>
</developer>
</developers>
13. Contributors
• Contributors are like developers yet play an ancillary role in a project's lifecycle.
Perhaps the contributor sent in a bug fix, or added some important documentation.
<contributors>
<contributor>
<name>Noelle</name>
<email>some.name@gmail.com</email>
<url>http://noellemarie.com</url>
<organization>Noelle Marie</organization>
<organizationUrl>http://noellemarie.com</organizationUrl>
<roles>
<role>tester</role>
</roles>
<timezone>America/Vancouver</timezone>
<properties>
<gtalk>some.name@gmail.com</gtalk>
</properties>
</contributor>
</contributors>
15. Issue Management
• This defines the defect tracking system
(Bugzilla, TestTrack, ClearQuest, etc) used.
• Although there is nothing stopping a plugin from
using this information for something, its primarily
used for generating project documentation.
<issueManagement>
<system>Bugzilla</system>
<url>http://127.0.0.1/bugzilla/</url>
</issueManagement>
16. Continuous Integration Management
• Configurations within the POM for Continuous integration build systems based upon triggers or
timings (such as, hourly or daily)
• Example : A notifier of type mail and configuring the email address to use on the specified
triggers sendOnError, sendOnFailure, and not sendOnSuccess or sendOnWarning.
<ciManagement>
<system>continuum</system>
<url>http://127.0.0.1:8080/continuum</url>
<notifiers>
<notifier>
<type>mail</type>
<sendOnError>true</sendOnError>
<sendOnFailure>true</sendOnFailure>
<sendOnSuccess>false</sendOnSuccess>
<sendOnWarning>false</sendOnWarning>
<configuration><address>continuum@127.0.0.1</address></configuration>
</notifier>
</notifiers>
</ciManagement>
17. Mailing Lists
• Mailing lists are a great tool for keeping in touch with people about a
project.
<mailingLists>
<mailingList>
<name>User List</name>
<subscribe>user-subscribe@127.0.0.1</subscribe>
<unsubscribe>user-unsubscribe@127.0.0.1</unsubscribe>
<post>user@127.0.0.1</post>
<archive>http://127.0.0.1/user/</archive>
<otherArchives>
<otherArchive>http://base.google.com/base/1/127.0.0.1</otherArchive>
</otherArchives>
</mailingList>
</mailingLists>
18. Source Code Control Integration
• Seamlessly integrates Maven
• processes with your SCM repo.
‣ mvn scm:diff
‣ Creates UNIX diff file
‣ mvn scm:tag
‣ mvn scm:status
• Dozens of SCM systems supported.
‣ CVS
‣ Subversion
‣ Git
• mvn release:prepare
‣ Increments all pom.xml version tags.
<scm>
<connection>scm:svn:http://127.0.0.1/svn/my-project</connection>
<developerConnection>scm:svn:https://127.0.0.1/svn/my-project</developerConnection>
<tag>HEAD</tag>
<url>http://127.0.0.1/websvn/my-project</url>
</scm>
19. Repositories
• Repositories exist as a place to collect and
store artifacts.
• In order to be a Maven repository artifact,
a POM file must live within the structure
$BASE_REPO/groupId/artifactId/version/artifactI
d-version.pom.
– $BASE_REPO can be local (file structure) or
remote (base URL);
– the remaining layout will be the same.
20.
21. Distribution Management
• Manages the distribution of the artifact and supporting files generated
throughout the build process.
• Starting with the last elements first
• Status is set by Maven – It can have values like
– None : Default
– Converted : Converted from another maven version
– Partner: Synched with a partner repository.
– Deployed: Artifact was deployed from a Maven 2 or 3 instance.
– Verified: Project has been verified, and should be considered
finalized
<distributionManagement>
...
<downloadUrl>http://mojo.codehaus.org/my-project</downloadUrl>
<status>deployed</status>
</distributionManagement>
24. Profiles
• A new feature of the POM 4.0
• Ability of a project to change settings depending on the environment
where it is being built.
• A profile element contains both an optional activation (a profile trigger)
and the set of changes to be made to the POM if that profile has been
activated.
• Examples:
– A project built for a test environment may point to a different database than
that of the final deployment.
– Dependencies may be pulled from different repositories based upon the JDK
version used
25. Activation
• Activations are the key of a
profile.
• The power of a profile comes
from its ability to modify the
basic POM only under certain
circumstances.
• Those circumstances are
specified via
an activation element.
26. Debugging
• Exception Full Stack Traces
– If a Maven plugin is reporting an error, to see the full detail of the exception’s stack trace run
Maven with the -e flag.
mvn <yourgoal> -e
• Output Debugging Info
– Whenever reporting a Maven bug, or troubleshooting a problem, turn on all the debugging info
by running Maven like so:
mvn <yourgoal> -X
• Debug Maven Core/Plugins
– Core Maven operations and plugins can be stepped through with any compatible debugger, the
most common option being Eclipse. When run in debug mode, Maven will wait for you to
connect your debugger to socket port 8000 before continuing with its lifecycle.
mvnDebug <yourgoal>
• Debug a Unit Test
– Your suite or an individual unit test can be debugged by telling the Surefire test-execution plugin
– to wait for you to attach a debugger to port 5005.
mvn test -Dmaven.surefire.debug
29. Release Cycle
• Using the Maven Release Plugin
• Audits your code...
– Check that there is no uncommitted code
– Check that there are no snapshot dependencies
– Prompts for release tag, branch and new version numbers
• ...then does the bookkeeping
– Updates version numbers to release versions
– Creates a new release tag in SCM
– Updates version numbers to next SNAPSHOT versions
– Commit these changes to SCM
30. • $ mvn release:perform
• Do the real work
– Checkout a release version
– Build, test and deploy to the Enterprise repository
– Requires a file called release.properties to be present within the
project root directory
32. Developing MOJO
• MOJO is Maven plain Old Java Object
• It’s a Java Plugin
• Name your plugin <yourplugin>-maven-plugin
• Plugin maven project packaging should be
• Specify a class as Mojo by annotating it with @Mojo annotation
• And it has to be extended from AbstractMojo class
35. Executing the Mojo
• Specify the plugin goal directly on the command
line
mvn groupId:artifactId:version:goal
• For example, to run the simple mojo in the sample
plugin, you would enter
"mvn sample.plugin:hello-maven-plugin:1.0-SNAPSHOT:sayhi"
on the command line.