$30 off During Our Annual Pro Sale. View Details »

Mission accomplished - Deploy to Maven Central

November 28, 2021

Mission accomplished - Deploy to Maven Central

Many developers have ideas they work on it in their spare time. The most of us are convinced about open source and share their own projects on platforms like GitHub. But what happen after a publication of the source code? If you really want to gain people to use your project you’re not done yet. It’s also a good idea to publish your artifacts for a simple usage.

The most famous storage for binary Java Artifacts is Maven Central. Doesn‘t matter if you use in your projects Ivy, Gradle or Maven as dependency management, all those technologies access to Maven Central. In this talk you will learn how to publish your artifacts with Maven to Sonatype Nexuss OSS. We pass through all steps from creating accounts until the the binaries are available. In between I give some general hints about the usage of repository managers and helpful tricks for a lightweight Release Management.

Homepage : https://elmar-dott.com
AnchorFM : https://anchor.fm/elmar-dott
Twitter - https://twitter.com/ElmarDott
GitHub - https://github.com/ElmarDott
Lbry - https://lbry.tv/@elmar.dott:8
BitChute - https://www.bitchute.com/channel/3IyCzKdX8IpO/


November 28, 2021

More Decks by ElmarDott

Other Decks in Programming


  1. Jc on f 2021 P e r u on l

    i n e © 2021 ElmarDott Mission accomplished - Deploy to Maven Central
  2. © 2021 j Con f P e r u 2021

    Sp e a k e r El ma r Do t t (M. Schulz) studied at HS Merseburg, Germany, computer science and holds an engineers degree in software engineering. He tweets regularly about several technical topics. The main topics in his field of work are Build and Configuration Management, Software Architecture and Release Management. About more than 15 years he is working in different large Web Application projects all over the world. He is an independent consultant / trainer. To share his knowledge he gives talks on conferences, if he is not writing on a new article about software engineering. https://elmar-dott.com + Consultant + Writer + Speaker + Trainer +
  3. © 2021 j Con f P e r u 2021

    Ag e nd a What is a Repository Manager? Sonatype Nexus OSS Publishing Sources and Artifacts How to prepare your project. Register your repository Uploads & Artifact validation
  4. © 2021 j Con f P e r u 2021

    De p e nd e n c y Man a g e m e n t Bower JavaScript DockerHub Java .NET Each platform & also almost each build tool have an own dependency management to deal with artifacts.
  5. © 2021 j Con f P e r u 2021

    Re p o s i t o r y Man a g e r • build tools, dependency management, packet manager & repository manager • essential part of the build / CI-CD infrastructure • speed up the build & deploy pipeline • storage and archive binary artifacts • deal with multiple formats • two major providers JFrog Artifactory & Sonatype Nexus OSS
  6. © 2021 j Con f P e r u 2021

    Son a t y p e N e x u s OSS
  7. © 2021 j Con f P e r u 2021

    Ma v e n D e p l o y m e n t local repository remote repository mvn install mvn deploy <repositories> <repository> <id>nexus-oss</id> <url>http://localhost:8082/repository/maven-public/</url> </repository> </repositories> POM – consume a repository POM – deploy artifacts <distributionManagement> <snapshotRepository> <id>nexus-oss</id> <url>${release.repo}</url> </snapshotRepository> <repository> <id>nexus-oss</id> <url>${snapshot.repro}</url> </repository> <site> <id>webdav</id> <name>Local deployed site</name> <url>${site.repro}</url> </site> </distributionManagement> SETTINGS - credentials POM – consume a repository <servers> <server> <id>nexus-oss</id> <username>mvn-deployer</username> <password>#myS3cr3t#</password> </server> </servers>
  8. © 2021 j Con f P e r u 2021

    Fr om G i tHu b 2 MVN C e n t ra l project-1.0.0.jar sources-1.0.0.jar javadoc-1.0.0.jar Maven central publish code build artifacts publish artifacts
  9. © 2021 j Con f P e r u 2021

    Ma v e n Pl u g i n s <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar|war|ear-plugin</artifactId> <version>3.2.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-gpg-plugin</artifactId> <version>1.6</version> <executions> <execution> <id>sign-artifacts</id> <phase>verify</phase> <goals> <goal>sign</goal> </goals> </execution> </executions> <configuration> <keyname>myKey</keyname> <passphraseServerId>mySecret</passphraseServerId> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.3.0</version> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.2.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>jar-no-fork</goal> <goal>test-jar-no-fork</goal> </goals> </execution> </executions> </plugin>
  10. © 2021 j Con f P e r u 2021

    Re g i s t e r a t Son a t y p e J i ra
  11. © 2021 j Con f P e r u 2021

    Pr e p a r e y ou r POM <name>sample pom</name> <description>Sample project pom fpr publisching on Maven Central.</description> <inceptionYear>2021</inceptionYear> <url>https://elmar-dott.com</url> <groupId>io.github.myProject</groupId> <artifactId>project</artifactId> <version>1.0.0</version> <packaging>jar</packaging> <scm> <connection>scm:git:https://github.com/ElmarDott/TP-CM.git</connection> <developerConnection>scm:git:https://github.com/ElmarDott/TP-CM.git</developerConnection> <url>scm:git:https://github.com/ElmarDott/TP-CM.git</url> </scm> <developers> <developer> <name>Elmar Dott</name> <email>elmar.dott@gmail.com</email> </developer> </developers> <licenses> <license> <name>Apache License 2.0</name> <url>https://www.apache.org/licenses/LICENSE-2.0</url> </license> </licenses>
  12. © 2021 j Con f P e r u 2021

    S i g n i ng y ou r Ar t i f a c t s
  13. © 2021 j Con f P e r u 2021

    OSS Son a t y p e Ar t i f a c t u p l o ad
  14. © 2021 Jc on 2021 : Ro l i ng

    St on e s Re f e r e n z e n [1] Marco Schulz, 2021, Continuous Integration mit Jenkins, Rheinwerk, ISBN: ISBN 978-3-8362-7834-8 https://www.rheinwerk-verlag.de/continuous-integration-mit-jenki ns/ [2] https://www.sonatype.com/products/repository-oss/ [3] https://search.maven.org [4] https://issues.sonatype.org/login.jsp [5] https://oss.sonatype.org [6] https://central.sonatype.org/publish/requirements/gpg/ [7] https://central.sonatype.org/publish/publish-guide/
  15. © 2021 j Con f P e r u 2021

    Cr e d e n t i a l s --------------------------------------------------------- Homepage : https://elmar-dott.com GitHub : https://github.com/ElmarDott AnchorFM : https://anchor.fm/elmar-dott Twitter : https://twitter.com/ElmarDott Speaker Deck : https://speakerdeck.com/elmardott Lbry : https://lbry.tv/@elmar.dott:8 BitChute : https://www.bitchute.com/channel/3IyCzKdX8IpO/ --------------------------------------------------------- Danke / thank you / Gracias
  16. None