Nexus Maven configuration
For Nexus server see Nexus
Maven Global configuration
To set the Global configuration, edit your Maven/conf/settings.xml
and add:
<!-- Nexus deployment user -->
<!-- (!! Adjust the passwords !!) -->
<servers>
<server>
<id>releases</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>snapshots</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>nexus</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
<!-- declare your NEXUS server -->
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>https://dev.daxiongmao.eu/nexus/content/groups/public</url>
</mirror>
</mirrors>
<!-- Create a profile to proxy all requests through Nexus -->
<profiles>
<profile>
<id>nexus</id>
<!-- This will redirect all requests to Nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!--make the profile active all the time -->
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
Project configuration
As an alternative you can update the project's POM to ensure everyone uses your repository.
Put this before the [BUILD] section of your POM.
<distributionManagement>
<repository>
<id>nexus</id>
<url>https://dev.daxiongmao.eu/nexus/content/repositories/releases/</url>
<layout>default</layout>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
<snapshotRepository>
<id>nexus</id>
<url>https://dev.daxiongmao.eu/nexus/content/repositories/snapshots/</url>
<layout>default</layout>
<snapshots>
<updatePolicy>always</updatePolicy>
</snapshots>
<releases>
<updatePolicy>always</updatePolicy>
</releases>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>dev.daxiongmao.eu</id>
<url>https://dev.daxiongmao.eu/nexus/content/repositories/public/</url>
</repository>
</repositories>
Now your maven client knows only your nexus and everything it needs and how it gets it, should be controlled by nexus.
SSL fixes
You can encounter some issues with SSL, especially if you're using a self-signed certificate.
You need to download the JavaSSL.zip utilities
####### Install JavaSSL utilities
cd /tmp
wget http://daxiongmao.eu/wiki_upload_files/javaSSL/JavaSSL.zip
wget http://demos.erikzaadi.com/jenkins/JavaSSL.zip
unzip JavaSSL.zip
###### Test SSL connection with the target server
java SSLPoke dev.daxiongmao.eu 443
#> You should see an exception
###### Add certificate to the local Java KeyStore
java InstallCert dev.daxiongmao.eu:443
#> You should see an exception (you can discard it)
#> Enter the certificate number: 1
#> Note the last line (alias)
# Added certificate to keystore 'jssecacerts' using alias 'dev.daxiongmao.eu-1'
######### Register certificate to the JVM
sudo cp jssecacerts $JAVA_HOME/jre/lib/security
sudo cp jssecacerts /usr/lib/jvm/java-8-oracle/jre/lib/security/
######### Users binding
# Let the local user use it
cp jssecacerts ~/.keystore
# Let the user "sisi" use that certificate
cp jssecacerts /home/sisi/.keystore
# Jenkins
cp jssecacerts /var/lib/jenkins/.keystore
# Let root use it
sudo cp jssecacerts /root/.keystore
######### Check results (1)
keytool -list
#> Password: changeit
keytool -list | grep "dev.daxiongmao.eu"
#> You should see something
###### Test SSL connection with the target server (2)
java SSLPoke dev.daxiongmao.eu 443
#> It should work!
Now you should be able to access NEXUS in SSL ! :)
References: