Yes, you can use one ~/.m2/settings.xml
file for both. Below is an example of what I'm using. Servers are outside of profiles, since they are only used when referenced by ID.
In my IDE I have comp
profile enabled for company projects, atlassian
profile for atlassian SDK projects, and none of them for other projects. In IntelliJ IDEA you can do this via sidebar, while in Eclipse you have to do this via Project Properties. From command-line you'll have to activate them manually via -P
. However, you can experiment with property-based automatic profile activation.
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>comp-releases</id>
<username>me</username>
<password>secret</password>
</server>
<server>
<id>comp-snapshots</id>
<username>me</username>
<password>secret</password>
</server>
</servers>
<profiles>
<profile>
<id>comp</id>
<repositories>
<repository>
<id>comp-nexus</id>
<name>Nexus Public</name>
<url>https://www.example.com/nexus/content/groups/public/</url>
</repository>
</repositories>
</profile>
<profile>
<id>atlassian</id>
<repositories>
<repository>
<id>atlassian-public</id>
<url>https://maven.atlassian.com/repository/public</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>atlassian-public</id>
<url>https://maven.atlassian.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>