CD part XV: Configuring Maven to use Nexus

  • 17/02/2017
  • 2 minuten leestijd

CD part XV: Configuring Maven to use Nexus

After installation of Maven and Nexus, we need to configure maven to connect to the Nexus Repository Manager

maven configuration to use the nexus repository

source: http://www.vineetmanohar.com/2010/06/getting-started-with-nexus-maven-repo-manager/

  1. configure settings.xml
  2. navigate to C:\tools\apache-maven-3.3.9\conf and open settings.xml
  3. add a server in the server section of this file
    <!-- Nexus Repository Manager -->
    <server>
        <id>NexusRepoManager</id>
        <username>deployment</username>
        <password>admin</password>
    </server>
  1. configure the pom.xml of the AccountStatusWebservice
  2. navigate to AccountStatusWebservice and open pom.xml
  3. add distribution management and repositories to the pom file
    <distributionManagement>  
        <!-- Publish the versioned releases here -->  
        <repository>  
            <id>NexusRepoManager</id>  
            <name>Continuous Delivery Blog Nexus Releases</name>  
            <url>https://localhost:8081/nexus/content/repositories/releases</url>  
        </repository>  

        <!-- Publish the versioned snapshots here -->  
        <snapshotRepository>  
            <id>NexusRepoManager</id>  
            <name>Continuous Delivery Blog Nexus Snapshots</name>  
            <url>http://localhost:8081/nexus/content/repositories/snapshots</url>  
        </snapshotRepository>  
    </distributionManagement>

    <repositories>
        <repository>
            <id>NexusRepoManager</id>
            <name>Continuous Delivery Blog Nexus</name>
            <url>http://localhost:8081/nexus/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
  1. next we need to add the maven-deploy-plugin to the develop profile
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.8.2</version>
    </plugin>

test configuration

  1. test the configuration by entering the next commands
  2. build project and deploy it to the local repo: mvn clean install
  3. build project and deploy it to the nexus repo: mvn clean deploy -Pdevelop
  4. navigate to http://localhost:8081/nexus/content/repositories/snapshots/nl/com/devnl/AccountStatusWebservice/1.0-SNAPSHOT/
  5. and check if there is a war file [IMG]