Skip to content

Instantly share code, notes, and snippets.

@parj
Last active May 19, 2019 10:37
Show Gist options
  • Save parj/ae2d0c422c75359605fa5bfab3cb45bf to your computer and use it in GitHub Desktop.
Save parj/ae2d0c422c75359605fa5bfab3cb45bf to your computer and use it in GitHub Desktop.
Sample springboot pom which enables uploading to ossrh
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.parj</groupId>
<artifactId>samplespringbootapp</artifactId>
<packaging>jar</packaging>
<version>1.6-SNAPSHOT</version>
<name>samplespringbootapp</name>
<url>https://github.com/parj/SampleSpringBootApp</url>
<licenses>
<license>
<name>MIT license</name>
<url>https://opensource.org/licenses/MIT</url>
</license>
</licenses>
<!-- Required for pushing tags back to git repo -->
<scm>
<url>https://github.com/parj/AddOnJavaAntTasks</url>
<connection>scm:git:[email protected]:parj/SampleSpringBootApp.git</connection>
<developerConnection>scm:git:[email protected]:parj/SampleSpringBootApp.git</developerConnection>
<tag>HEAD</tag>
</scm>
<!-- Required for publishing artifacts back to OSSRH -->
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
<swagger.version>2.9.2</swagger.version>
<jar_file>${project.build.directory}/${project.build.finalName}.jar</jar_file>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- Optional to scan for known CVE -->
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>4.0.1</version>
</plugin>
<!-- Eliminates the need for a docker file, docker image built with mvn docker:build -->
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.30.0</version>
<extensions>true</extensions>
<configuration>
<verbose>true</verbose>
<images>
<image>
<alias>sample</alias>
<name>parjanya/${project.name}</name>
<build>
<from>gcr.io/distroless/java:11</from>
<maintainer>[email protected]</maintainer>
<tags>
<tag>latest</tag>
<tag>${project.version}</tag>
</tags>
<assembly>
<!-- This is a predefined assembly.xml that will only copy your final artifact to the Docker image -->
<descriptorRef>artifact</descriptorRef>
</assembly>
<entryPoint>
<exec>
<arg>java</arg>
<arg>-jar</arg>
<!-- This extra argument is so Tomcat can start faster due to lack of entropy -->
<arg>-Djava.security.egd=file:/dev/./urandom</arg>
<!-- /maven/ is the default dir that the plugin copies your artifact to -->
<arg>/maven/${project.artifactId}-${project.version}.${project.packaging}</arg>
</exec>
</entryPoint>
</build>
</image>
</images>
</configuration>
</plugin>
<!-- Required to get dockerfile to run junit tests succesfully -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<!-- This is for test coverage, used then in turn by https://codecov.io and https://coveralls.io -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- For https://coveralls.io -->
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.3</version>
</dependency>
</dependencies>
</plugin>
<!-- Used for uploading artifacts to ossrh -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<!-- Used for signing artifacts using gpg -->
<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>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
<keyname>${gpg.keyname}</keyname>
<passphraseServerId>${gpg.keyname}</passphraseServerId>
</configuration>
</execution>
</executions>
</plugin>
<!-- To generate javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Commented out as there is a bug with openjdk 11 -->
<!--plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin-->
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment