Upgrade to Pro — share decks privately, control downloads, hide ads and more …

managing build artifacts with nexus

managing build artifacts with nexus

...on using sonatype nexus as a repository for software artifacts that have been created for internal consumption.

Avinash Chugh

August 13, 2013
Tweet

More Decks by Avinash Chugh

Other Decks in Programming

Transcript

  1. A repository manager Stores and organizes binary software components (a.k.a

    jars) for use during your development lifecycle
  2. benefits •A destination for internally developed software artifacts •Share software

    components across other internally developed projects •Can proxy between the organization and public repositories •Faster and reliable builds •Greater visibility into your component library, and its usage
  3. our use case... ✓A destination for internally developed software artifacts

    ✓Share software components across other internally developed projects •Can proxy between the organization and public repositories ✓Faster and reliable builds •Greater visibility into your component library, and its usage
  4. our use case... •Host snapshot releases for components being developed

    •Host fixed versions of artifacts for environments that need specific releases •Segregate artifacts into different repositories (e.g. frameworks, apps, etc) •A local Maven repository
  5. A sample pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http:/ /maven.apache.org/POM/4.0.0" xmlns:xsi="http:/

    /www.w3.org/2001/XMLSchema-instance"> <groupId>com.foo.app</groupId> <artifactId>shared-lib</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> .... <distributionManagement> <snapshotRepository> <id>nexus-snapshots</id> <url>http:/ /10.15.1.150:3001/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> </project> mvn deploy (and that’s it)
  6. Consuming artifacts <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http:/ /maven.apache.org/POM/4.0.0" xmlns:xsi="http:/ /www.w3.org/2001/XMLSchema-instance">

    <groupId>com.foo.app</groupId> <artifactId>consumer-api</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> .... <repositories> <repository> <id>nexus</id> <name>Nexus</name> <snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> <checksumPolicy>fail</checksumPolicy> </snapshots> <url>http:/ /10.15.1.150:3001/nexus/content/repositories/snapshots/</url> <layout>default</layout> </repository> </repositories> ... 1. declare the maven repository
  7. Consuming artifacts .... <dependencies> <dependency> <groupId>com.foo.app</groupId> <artifactId>shared-lib</artifactId> <version>1.0-SNAPSHOT</version> </dependency> ...

    </dependencies> </project> 3. mvn compile (and that’s it) 2. declare the jar- dependency 2. declare the jar- dependency
  8. Releasing the artifacts 1. Declare git URLs <?xml version="1.0" encoding="UTF-8"?>

    <project xmlns="http:/ /maven.apache.org/POM/4.0.0" xmlns:xsi="http:/ /www.w3.org/2001/XMLSchema-instance"> <groupId>com.foo.app</groupId> <artifactId>shared-lib</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> ... <scm> <connection>scm:git:[email protected]:<some-org>/shared-lib.git</connection> <url>scm:git:[email protected]:<some-org>/shared-lib.git</url> <developerConnection>scm:git:[email protected]:<some-org>/shared-lib.git</developerConnection> </scm> .... <distributionManagement> <releaseRepository> <id>nexus-releases</id> <url>http:/ /10.15.1.150:3001/nexus/content/repositories/releases/</url> </releaseRepository> </distributionManagement> 2. Declare release repository
  9. Releasing the artifacts .... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.4.1</version>

    </plugin> </plugins> </build> ... </project> 4. mvn release:prepare mvn release:perform (and that’s it) 3. Use the release plugin
  10. Nexus Setup •A war that can be deployed to Tomcat

    •Register an ‘ admin’ user •And you’re good to go.