Nexus Proxy Example
Written using Nexus 1.0.0-beta2
Nexus provides proxy, grouping, and local repository functionality along with a rich web-ui for administration. There are no security options included with Nexus beyond an administrative account for configuration.
To use Nexus as a caching proxy for a uPortal 3 build five release and three snapshot repository proxies must be configured along with an optional public repository group. A sample Nexus configuration file is attached that provides these eight proxy repositories and the public repository group.
<mirrors> in settings.xml
To configure maven on a machine to use the local repositories a ~/.m2/settings.xml file is needed. The following is an example settings.xml the works with the attached Nexus configuration. Simply change the hostname and port in the URLs to point to your Nexus server.
There are two options presented in the sample.
- One is to list each of the repositories that needs to be proxied explicitly. This is recommended for developers as it allows them to still download artifacts from repositories that are not proxied by Nexus.
- The second option is to just have one entry in the mirrors section that mirrors all repositories via a repository group defined in Nexus. This is recommended for actual build environments when you want to make sure that all artifacts downloaded during the build process are proxied by Nexus. If Maven encounters an artifact not found in any of the repositories specified in the group the build will fail.
<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <mirrors> <!-- | Each mirror is listed individually here, this configuration is better for portal developers | who may need to retrieve artifacts from non-proxied repositories. +--> <mirror> <id>my-tools.central</id> <name>my-tools Nexus Mirror of central</name> <url>http://bohemia.doit.wisc.edu:8081/nexus/content/repositories/central</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>my-tools.jasig-repository</id> <name>my-tools Nexus Mirror of jasig-repository</name> <url>http://bohemia.doit.wisc.edu:8081/nexus/content/repositories/jasig-repository</url> <mirrorOf>jasig-repository</mirrorOf> </mirror> <mirror> <id>my-tools.maven2-repository.dev.java.net</id> <name>my-tools Nexus Mirror of maven2-repository.dev.java.net</name> <url>http://bohemia.doit.wisc.edu:8081/nexus/content/repositories/java.net</url> <mirrorOf>maven2-repository.dev.java.net</mirrorOf> </mirror> <mirror> <id>my-tools.maven-repository.dev.java.net</id> <name>my-tools Nexus Mirror of maven-repository.dev.java.net</name> <url>http://bohemia.doit.wisc.edu:8081/nexus/content/repositories/m1.java.net</url> <mirrorOf>maven-repository.dev.java.net</mirrorOf> </mirror> <mirror> <id>my-tools.dist.codehaus.org/mule</id> <name>my-tools Nexus Mirror of dist.codehaus.org/mule</name> <url>http://bohemia.doit.wisc.edu:8081/nexus/content/repositories/dist.codehaus.org-mule</url> <mirrorOf>dist.codehaus.org/mule</mirrorOf> </mirror> <mirror> <id>my-tools.jasig-snapshot</id> <name>my-tools Nexus Mirror of jasig-snapshot</name> <url>http://bohemia.doit.wisc.edu:8081/nexus/content/repositories/jasig-snapshot</url> <mirrorOf>jasig-snapshot</mirrorOf> </mirror> <mirror> <id>my-tools.Codehaus Snapshots</id> <name>my-tools Nexus Mirror of Codehaus Snapshots</name> <url>http://bohemia.doit.wisc.edu:8081/nexus/content/repositories/codehaus-snapshots</url> <mirrorOf>Codehaus Snapshots</mirrorOf> </mirror> <mirror> <id>my-tools.apache.snapshots</id> <name>my-tools Nexus Mirror of apache.snapshots</name> <url>http://bohemia.doit.wisc.edu:8081/nexus/content/repositories/apache-snapshots</url> <mirrorOf>apache.snapshots</mirrorOf> </mirror> <!-- | Sends Everything to the public group, this should be used for production builds when attempting | to download an artifact directly from _any_ repository should be considered a build error +--> <!-- <mirror> <id>my-tools.public</id> <mirrorOf>*</mirrorOf> <url>http://bohemia.doit.wisc.edu:8081/nexus/content/groups/public</url> </mirror> --> </mirrors> </settings>