Settings Profiles
Project profiles are useful when a specific project needs to
customize a build setting for a specific environment,
but why would you want to override a build setting for every project
in Maven? How do you do something like add an internal repository that
is consulted on every Maven build? You can do this with a settings
profile. Where project profiles are concerned with overriding the
configuration of a specific project, settings profiles can be applied
to any and all projects you build with Maven. You can place settings
profiles in two locations: a user-specific settings profile defined in ~/.m2/settings.xml or
a global settings profile defined in ${M2_HOME}/conf/settings.xml. Here is an
example of a settings profile defined in ~/.m2/settings.xml that might set some
user-specific configuration properties for all builds. The settings.xml file shown in Example 11-7 is defined for
user tobrien
.
Example 11-7. Defining user-specific settings profiles (~/.m2/settings.xml)
<settings> <profiles> <profile> <id>dev</id> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <executions> <execution> <goals> <goal>sign</goal> </goals> </execution> </executions> <configuration> <keystore>/home/tobrien/java/keystore</keystore> <alias>tobrien</alias> <storepass>s3cr3tp@ssw0rd</storepass> <signedjar>${project.build.directory}/signed/ ${project.build.finalName}.jar</signedjar> <verify>true</verify> </configuration> </plugin> </profile> ...
Get Maven: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.