RSS Feed for This PostCurrent Article

Setting Nexus Maven Repository Manager on Windows

Setting Nexus Maven Repository Manager on Windows is easy. You can download and follow the instructions in Maven Definitive Guide. Below are the summarized steps.

1. Download the latest Nexus webapps bundle.

2. Unzip it to a folder that you want.

3. Goto “bin\jsw\windows-x86-32” folder. Run InstallNexus.bat and then StartNexus.bat. Nexus will be installed as a Windows service using Java Service Wrapper.

image

4. Point your browser to http://localhost:8081/nexus, login as admin/admin123.

5. Create or modify the file settings.xml under <Document and Settings>\<user name>\.m2 folder. Here is the content of my settings.xml

   1: <?xml version="1.0"?>
   2: <settings>
   3:  <mirrors>
   4:     <mirror>
   5:       <!--This is used to direct the public snapshots repo in the 
   6:           profile below over to a different nexus group -->
   7:       <id>nexus-public-snapshots</id>
   8:       <mirrorOf>public-snapshots</mirrorOf>
   9:       <url>http://localhost:8081/nexus/content/groups/public-snapshots</url>
  10:     </mirror>
  11:     <mirror>
  12:       <!--This sends everything else to /public -->
  13:       <id>nexus</id>
  14:       <mirrorOf>*</mirrorOf>
  15:       <url>http://localhost:8081/nexus/content/groups/public</url>
  16:     </mirror>
  17:   </mirrors>
  18:   <profiles>
  19:     <profile>
  20:       <id>development</id>
  21:       <repositories>
  22:         <repository>
  23:           <id>central</id>
  24:           <url>http://central</url>
  25:           <releases><enabled>true</enabled></releases>
  26:           <snapshots><enabled>true</enabled></snapshots>
  27:         </repository>
  28:       </repositories>
  29:      <pluginRepositories>
  30:         <pluginRepository>
  31:           <id>central</id>
  32:           <url>http://central</url>
  33:           <releases><enabled>true</enabled></releases>
  34:           <snapshots><enabled>true</enabled></snapshots>
  35:         </pluginRepository>
  36:       </pluginRepositories>
  37:     </profile>
  38:     <profile>
  39:       <!--this profile will allow snapshots to be searched when activated-->
  40:       <id>public-snapshots</id>
  41:       <repositories>
  42:         <repository>
  43:           <id>public-snapshots</id>
  44:           <url>http://public-snapshots</url>
  45:           <releases><enabled>false</enabled></releases>
  46:           <snapshots><enabled>true</enabled></snapshots>
  47:         </repository>
  48:       </repositories>
  49:      <pluginRepositories>
  50:         <pluginRepository>
  51:           <id>public-snapshots</id>
  52:           <url>http://public-snapshots</url>
  53:           <releases><enabled>false</enabled></releases>
  54:           <snapshots><enabled>true</enabled></snapshots>
  55:         </pluginRepository>
  56:       </pluginRepositories>
  57:     </profile>
  58:   </profiles>
  59:   <activeProfiles>
  60:     <activeProfile>development</activeProfile>
  61:   </activeProfiles>
  62: </settings>

5. Point your maven pom.xml to use the Nexus repository. Here is my master pom.xml

   1: <?xml version="1.0" encoding="UTF-8"?>
   2: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   3:          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   4:  
   5:     <modelVersion>4.0.0</modelVersion>
   6:     <groupId>com.cdp</groupId>
   7:     <artifactId>cdp</artifactId>
   8:     <packaging>pom</packaging>
   9:     <name>cdp</name>
  10:     <version>0.1</version>
  11:     <description>Content Delivery Platform</description>
  12:  
  13:     <mailingLists>
  14:         <mailingList>
  15:             <name>Maven User List</name>
  16:             <subscribe>users-subscribe@maven.apache.org</subscribe>
  17:             <unsubscribe>users-unsubscribe@maven.apache.org</unsubscribe>
  18:             <post>users@maven.apache.org</post>
  19:             <archive>http://mail-archives.apache.org/mod_mbox/maven-users</archive>
  20:             <otherArchives>
  21:                 <otherArchive>http://www.mail-archive.com/users@maven.apache.org/</otherArchive>
  22:                 <otherArchive>http://www.nabble.com/Maven---Users-f178.html</otherArchive>
  23:             </otherArchives>
  24:         </mailingList>
  25:     </mailingLists>
  26:  
  27:     <licenses>
  28:         <license>
  29:             <name>Licensed to twit88</name>
  30:             <url>http://www.twit88.com/</url>
  31:             <distribution>repo</distribution>
  32:         </license>
  33:     </licenses>
  34:  
  35:     <build>
  36:         <plugins>
  37:  
  38:             <plugin>
  39:                 <artifactId>maven-compiler-plugin</artifactId>
  40:                 <configuration>
  41:                     <source>1.5</source>
  42:                     <target>1.5</target>
  43:                 </configuration>
  44:             </plugin>
  45:  
  46:             <plugin>
  47:                 <groupId>org.apache.maven.plugins</groupId>
  48:                 <artifactId>maven-scm-plugin</artifactId>
  49:                 <version>1.0</version>
  50:             </plugin>
  51:  
  52:             <plugin>
  53:                 <groupId>org.apache.maven.plugins</groupId>
  54:                 <artifactId>maven-resources-plugin</artifactId>
  55:                 <version>2.2</version>
  56:             </plugin>
  57:  
  58:         </plugins>
  59:     </build>
  60:     <modules>
  61:         <module>cdp-proxy</module>
  62:     </modules>
  63:     <repositories>
  64:         <repository>
  65:             <snapshots>
  66:                 <enabled>true</enabled>
  67:             </snapshots>
  68:             <id>central</id>
  69:             <url>${maven.repository}</url>
  70:         </repository>
  71:         <repository>
  72:             <releases>
  73:                 <enabled>true</enabled>
  74:             </releases>
  75:             <id>snapshots</id>
  76:             <url>${maven.repository}</url>
  77:         </repository>
  78:     </repositories>
  79:     <pluginRepositories>
  80:         <pluginRepository>
  81:             <snapshots>
  82:                 <enabled>true</enabled>
  83:             </snapshots>
  84:             <id>central</id>
  85:             <url>${maven.repository}</url>
  86:         </pluginRepository>
  87:         <pluginRepository>
  88:             <releases>
  89:                 <enabled>true</enabled>
  90:             </releases>
  91:             <id>snapshots</id>
  92:             <url>${maven.repository}</url>
  93:         </pluginRepository>
  94:     </pluginRepositories>
  95:  
  96:     <dependencyManagement>
  97:         <dependencies>
  98:  
  99:         <dependency>
 100:                 <groupId>org.codehaus.plexus</groupId>
 101:                 <artifactId>plexus-container-default</artifactId>
 102:                 <version>1.0-alpha-9</version>
 103:             </dependency>
 104:  
 105:         </dependencies>
 106:     </dependencyManagement>
 107:  
 108:     <dependencies>
 109:         <dependency>
 110:             <groupId>junit</groupId>
 111:             <artifactId>junit</artifactId>
 112:             <version>4.4</version>
 113:             <scope>test</scope>
 114:         </dependency>
 115:  
 116:     </dependencies>
 117:     <reporting>
 118:         <plugins>
 119:             <plugin>
 120:                 <artifactId>maven-surefire-report-plugin</artifactId>
 121:                 <configuration>
 122:                     <showSuccess>false</showSuccess>
 123:                 </configuration>
 124:             </plugin>
 125:             <plugin>
 126:                 <artifactId>maven-jxr-plugin</artifactId>
 127:             </plugin>
 128:             <plugin>
 129:                 <artifactId>maven-javadoc-plugin</artifactId>
 130:                 <configuration>
 131:                     <links>
 132:                         <link>http://java.sun.com/j2se/1.4.2/docs/api</link>
 133:                         <link>http://plexus.codehaus.org/ref/1.0-alpha-9/apidocs</link>
 134:                     </links>
 135:                     <aggregate>true</aggregate>
 136:                 </configuration>
 137:             </plugin>
 138:             <plugin>
 139:                 <artifactId>maven-pmd-plugin</artifactId>
 140:                 <configuration>
 141:                     <rulesets>
 142:                         <ruleset>/rulesets/basic.xml</ruleset>
 143:                         <ruleset>/rulesets/imports.xml</ruleset>
 144:                         <ruleset>/rulesets/unusedcode.xml</ruleset>
 145:                         <ruleset>/rulesets/finalizers.xml</ruleset>
 146:                     </rulesets>
 147:                 </configuration>
 148:             </plugin>
 149:             <plugin>
 150:                 <artifactId>maven-checkstyle-plugin</artifactId>
 151:                 <configuration>
 152:                     <configLocation>config/maven_checks.xml</configLocation>
 153:                 </configuration>
 154:             </plugin>
 155:             <plugin>
 156:                 <groupId>org.codehaus.mojo</groupId>
 157:                 <artifactId>taglist-maven-plugin</artifactId>
 158:                 <configuration>
 159:                     <tags>
 160:                         <tag>TODO</tag>
 161:                         <tag>@todo</tag>
 162:                         <tag>FIXME</tag>
 163:                         <tag>XXX</tag>
 164:                     </tags>
 165:                 </configuration>
 166:             </plugin>
 167:             <plugin>
 168:                 <groupId>org.codehaus.mojo</groupId>
 169:                 <artifactId>cobertura-maven-plugin</artifactId>
 170:             </plugin>
 171:         </plugins>
 172:     </reporting>
 173:  
 174:  
 175:     <profiles>
 176:  
 177:         <profile>
 178:             <id>dev</id>
 179:             <activation>
 180:                 <property>
 181:                     <name>!env</name>
 182:                 </property>
 183:             </activation>
 184:             <properties>
 185:                 <maven.repository>http://localhost:8081/nexus/content/groups/public</maven.repository>
 186:             </properties>
 187:         </profile>
 188:  
 189:         <profile>
 190:             <id>prod</id>
 191:             <activation>
 192:                 <property>
 193:                     <name>env</name>
 194:                     <value>prod</value>
 195:                 </property>
 196:             </activation>
 197:             <properties>
 198:                 <maven.repository>http://localhost:8081/nexus/content/groups/public</maven.repository>
 199:             </properties>
 200:         </profile>
 201:  
 202:     </profiles>
 203: </project>
 204:  

I use 2 Maven profiles, one for development and another one for production.


Trackback URL


Sorry, comments for this entry are closed at this time.