Skip to content

Commit

Permalink
Publishing to Maven Central (#62)
Browse files Browse the repository at this point in the history
* Setting up publishing to Maven central.
- Added required elements to POM such as License, Developers, Issue Management, SCM, Distribution Management, etc.
- Added plugins required for publishing to Maven central
- Added Maven settings files for deploy task (using Travis environment variables)
- Updated travis configuration file to use job configuration where master will always run sonar and deploy where as pull requests, branches and forks will only run tests.
- Import keys to GPG before the build for signing.
- Made sure tests are run on master when its in a fork
- Restricted deploys to be only from master of the original repo (not forks)
- Moved override log4j configuration to surefire plugin configuration than just having it in the profile as it needs to be available for builds that doesn't use coverage-per-test profile
- Replaced deprecated sonar.branch with sonar.branch.name
  • Loading branch information
venushka authored and badgerwithagun committed Nov 1, 2018
1 parent 8a72346 commit bef69c9
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 26 deletions.
23 changes: 23 additions & 0 deletions .maven-settings.xml
@@ -0,0 +1,23 @@
<settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/SETTINGS/1.0.0" xsi:schemalocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>ossrh</id>
<username>${env.SONATYPE_USERNAME}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>

<profiles>
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.keyname>${env.GPG_KEYNAME}</gpg.keyname>
<gpg.executable>${env.GPG_EXECUTABLE}</gpg.executable>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
21 changes: 16 additions & 5 deletions .travis.yml
Expand Up @@ -5,15 +5,26 @@ addons:
organization: "alfasoftware"
token:
secure: "Rk0cQ9JL2/DB8xrKjaU/m9HEvZllokUZ8c7Q+6g3DHwOsMvZi1OoCdUtDXf9Zl0xtdFPMvoWsGPeZ6+sZK9evHscvRH83hVMTrTabWK4+QL660QeMXboBprwuBIpAI0XBCfNcslsT3zPd/e4v35FHPdvRr1yOQlibrjEgs1MZo6/LQ7QgRNJAHsskiqOOJS6LLDHceYJEW7wd/y7R0BvXoxch6xQhDOFvowoc22/cEyUVCSCMMas74hD//veSXdHt0CNOY+H+/PAzAYsbM0rkJnrysqO8UgLZwpnP/Mjsoi0InoisvriSl9MYgQwMAfcrtVxxR94vt4Pu62LXsnt6ufGfwFBrdTh1Rna05fzTAmm9bwywIR2UsMwNeM4iDoz+Rc2ImnwMKRipn5lib5kCOlwqjTv6NVi0oV5XEzTfU51HIrQMmmsq60YwMZgcYwckHoVVOojv29dAjLe0Z/LbfUH8MHprt8/MdWA8ir2egxHHW3dXVY11MgDKzQ2RyYb1uPNJgkVfZDm7uHDcj13dFR61Gy1mTdrtpnWx1ojU2IJQ4oKuGb04RbqQ5lCq7dgsHlaeaAJFMlcn1I6IOk8t6QkYy/3vhSXgkZpQAO3K5Zp4aaGZD90sYdQO3JQNCe2S8mhgEGOqsAdxytFygCaMxOKG5NV9qxVilkzfGPvmqM="
script:
- SONAR_SKIP=$(if [ "$TRAVIS_PULL_REQUEST" = "false" -a $TRAVIS_REPO_SLUG = 'alfasoftware/morf' ]; then echo "false"; else echo "true"; fi)
- if [ $SONAR_SKIP = "false" ]; then git fetch --unshallow --quiet; fi
- mvn $GOALS -Dsonar.branch=$TRAVIS_BRANCH -Dsonar.skip=$SONAR_SKIP
jobs:
include:
- if: branch = master AND repo = alfasoftware/morf AND NOT type = pull_request
name: "Test with coverage"
script:
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent test sonar:sonar -Pcoverage-per-test -Dsonar.branch.name=master -B -U
- if: branch = master AND repo = alfasoftware/morf AND NOT type = pull_request
name: "Deploy"
script:
- echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import
- echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --import-ownertrust
- mvn clean deploy --settings .maven-settings.xml -B -U -Prelease
- if: NOT branch = master OR NOT repo = alfasoftware/morf OR type = pull_request
name: "Test"
script:
- mvn clean test -B -U
matrix:
fast_finish: true
include:
- jdk: oraclejdk8
env: GOALS="clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Pcoverage-per-test"
cache:
directories:
- '$HOME/.m2/repository'
Expand Down
127 changes: 106 additions & 21 deletions pom.xml
Expand Up @@ -88,6 +88,11 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<log4j.configuration>file:${basedir}/../etc/log4j-maven.properties</log4j.configuration>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -352,9 +357,6 @@
<value>org.sonar.java.jacoco.JUnitListener</value>
</property>
</properties>
<systemPropertyVariables>
<log4j.configuration>file:${basedir}/../etc/log4j-maven.properties</log4j.configuration>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
Expand All @@ -368,24 +370,107 @@
</dependency>
</dependencies>
</profile>

<profile>
<id>release</id>
<properties>
<gpg.executable>gpg2</gpg.executable>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</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>
<configuration>
<keyname>${gpg.keyname}</keyname>
<passphraseServerId>${gpg.keyname}</passphraseServerId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<!-- <scm> -->
<!-- <connection>scm:?????</connection> -->
<!-- <developerConnection>scm:?????</developerConnection> -->
<!-- <url>?????</url> -->
<!-- </scm> -->
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<developers>
<developer>
<name>Andrew Flegg</name>
<email>andrew.flegg@alfasystems.com</email>
<organization>Alfa Financial Software Limited</organization>
<organizationUrl>http://alfasystems.com</organizationUrl>
</developer>
<developer>
<name>Graham Crockford</name>
<email>graham.crockford@alfasystems.com</email>
<organization>Alfa Financial Software Limited</organization>
<organizationUrl>http://alfasystems.com</organizationUrl>
</developer>
<developer>
<name>Tim Gage</name>
<email>tim.gage@alfasystems.com</email>
<organization>Alfa Financial Software Limited</organization>
<organizationUrl>http://alfasystems.com</organizationUrl>
</developer>
<developer>
<name>Venushka Perera</name>
<email>venushka.perera@alfasystems.com</email>
<organization>Alfa Financial Software Limited</organization>
<organizationUrl>http://alfasystems.com</organizationUrl>
</developer>
<developer>
<name>Will Nicholson</name>
<email>will.nicholson@alfasystems.com</email>
<organization>Alfa Financial Software Limited</organization>
<organizationUrl>http://alfasystems.com</organizationUrl>
</developer>
</developers>

<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/alfasoftware/morf/issues</url>
</issueManagement>

<scm>
<connection>scm:git:https://github.com/alfasoftware/morf.git</connection>
<developerConnection>scm:git:git@github.com:alfasoftware/morf.git</developerConnection>
<url>https://github.com/alfasoftware/morf</url>
</scm>

<!-- <distributionManagement> -->
<!-- <repository> -->
<!-- <id>?????</id> -->
<!-- <name>Releases</name> -->
<!-- <url>http://?????</url> -->
<!-- </repository> -->
<!-- <snapshotRepository> -->
<!-- <id>?????</id> -->
<!-- <name>Snapshots</name> -->
<!-- <url>http://?????</url> -->
<!-- </snapshotRepository> -->
<!-- </distributionManagement> -->
</project>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</project>

0 comments on commit bef69c9

Please sign in to comment.