Search
Calendar
May 2025
S M T W T F S
« Apr    
 123
45678910
11121314151617
18192021222324
25262728293031
Archives

Posts Tagged ‘settings.xml’

PostHeaderIcon Change settings.xml location

Case

You have to use a custom-set settings.xml file, rather the default one.

By default, settings.xml is assumed to be in one the two following folders:

$M2_HOME/conf/settings.xml
$HOME/.m2/settings.xml

Fix

Use the -s option, for instance:

mvn install -s /path/to/file/otherSettings.xml

PostHeaderIcon Multi-profiles with Maven 2

Case: you work on two different projects, which use different repositories. How to search, find and download needed jars owing to the project?

Maven2 allows you to define different profiles.
For that, edit your Maven2 config file, available at $HOME/.m2/settings.xml.

Define your first profile:

<profile>
    <properties>
       <maven.user>jlalou</maven.user>
       <myProject.version>12.3</myProject.version>
    </properties>
    <repositories><repository>
  <id>FirstProjectID</id>
  <name>My First Project</name>
  <url>http://blabla.bla.bla</url>
  <releases>
    <enabled>true</enabled>
    <checksumPolicy>warn</checksumPolicy>
  </releases>
  <snapshots>
    <enabled>true</enabled>
  <checksumPolicy>fail</checksumPolicy>
  </snapshots>
</repository></repositories>
</profile>

Define your first profile:

<profile>
    <properties>
      <maven.user>genericUser</maven.user>
      <myProject.version>45.6</myProject.version>
    </properties>
    <repositories><repository>
  <id>SecondProjectID</id>
  <name>My Personnal Project</name>
  <url>http://foo.foo.foo</url>
  <releases>
    <enabled>true</enabled>
    <checksumPolicy>warn</checksumPolicy>
  </releases>
  <snapshots>
    <enabled>true</enabled>
  <checksumPolicy>fail</checksumPolicy>
  </snapshots>
</repository></repositories>
</profile>

At the end of the file, add following tags:

    
<activeProfiles>
    <activeProfile>FirstProjectID</activeProfile>
    <activeProfile>SecondProjectID</activeProfile>
 </activeProfiles>

Now, on compiling, use the option -P to hint which project/profile you want to use:
maven clean install -PFirstProjectID