-
Notifications
You must be signed in to change notification settings - Fork 10
howToDeployToMavenRepository
To deploy to our Maven repository at Sonatype.org you need to follow some simple steps mentioned at
https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide
This is a summary to spare you reading the document.
Note*: The summary assumes that you are using Ubuntu 12.04+. If you are not consider to read the document instead.
Please notice that deployed JAR files will not contain the source folder for test files.
At first you need to prepare an account and your computer.
Browse to https://issues.sonatype.org/ and sign up.
You may use your GHRKO identifier as username.
Run
svn --version
to check if Subversion is installed yet.
If it is not install it via
sudo apt-get install subversion
In addition you need to have a PGP key pair.
Use gpg --gen-key
to create one.
Secondly you have to make a few changed to the pom file to match the pattern below.
<project 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/maven-4.0.0.xsd">
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>de.metalcon.utils</groupId>
<artifactId>form-item-list</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>FormItemList</name>
<description>Helper to extract form items from multi-part requests in Tomcat servlets.</description>
<url>https://github.com/renepickhardt/metalcon.git</url>
<licenses>
<license>
<name>GNU General Public License 3.0</name>
<url>http://www.gnu.org/licenses/gpl.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:https://github.com/renepickhardt/metalcon</connection>
<developerConnection>scm:git:https://github.com/renepickhardt/metalcon</developerConnection>
<url>https://github.com/renepickhardt/metalcon.git</url>
</scm>
<developers>
<developer>
<id>sebschlicht</id>
<name>Sebastian Schlicht</name>
<email>sebschlicht@uni-koblenz.de</email>
<roles>
<role>developer</role>
</roles>
</developer>
</developers>
<dependencies>
...
</dependencies>
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<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>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.1</version>
</plugin>
</plugins>
</build>
</project>
Root group id is "de.metalcon" but you may use a sub-package, e.g. "de.metalcon.utils" for utility projects.
Use a new unique artifact id matching to the component!
Insert the artifact version here. Version must end with "-SNAPSHOT".
Type in the component's name and a short description.
Add the developers contributed to the project. Each developer tag has sub-tags:
id
Unique developer identifier, e.g. GHRKO identifier from university
name
Developer's real name
email
E-Mail-Address, e.g. from university
Now commit and push your changes to github.
In addition you have to change your Maven settings to deploy to the Sonatype repositories.
Run
cp $M2_HOME/conf/settings.xml ~/.m2/
on the command line to copy the global settings into your user settings directory.
Then append the Sonatype servers to the servers-tag in the settings.xml:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
...
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>xxx</username>
<password>xxx</password>
</server>
<server>
<id>sonatype-nexus-staging</id>
<username>xxx</username>
<password>xxx</password>
</server>
</servers>
</settings>
Insert the login data of the JIRA account you created in the first step.
You may now deploy to our Maven repository.
To deploy snapshots run
mvn clean deploy
At this stage you can use your artifact in a Maven project by adding
<repositories>
<repository>
<id>Nexus Sonatype Snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
to the project element of the project's pom.xml
.
To deploy releases run
mvn release:clean
mvn release:prepare
mvn release:perform
Do not worry if Maven asks for your github login data.
To release your artifact visit https://oss.sonatype.org/ and login. Click at "Staging repositories", select your repository and click "Close".
After the repository is closed do a manual test before you finally release it. Right click at the closed repository and choose "Download".
When this is done choose the repository and click either "Drop" or "Release" depending on your results.
Our repositories will get synchronized to the Central Maven Repository roughly every 2 hours.
Sometimes mvn release:preprare
does stop to output its status. In that case abort the command after you waited about 1 minute and simply go on.
If the next step fails you have to change your pom.xml again, as "-SNAPSHOT" was removed from the version in the preparation before. Commit and push your changes to be synchronized. If you can see your version in the releases on github you have to remove the release tag created automatically by executing
git tag -d tagname
git push origin :refs/tags/tagname
where tagname
is the name of the release tag, equal to the artifact version.
Source: http://nathanhoad.net/how-to-delete-a-remote-git-tag
Try to deploy your release again now.