From 2af370d55dd119c9768a6cd185e267aa2c65bd93 Mon Sep 17 00:00:00 2001 From: catbref Date: Thu, 23 Jan 2020 11:59:34 +0000 Subject: [PATCH] pom.xml modifications for reproducible builds Seems to produce fat JARs with the same MD5 after repeated runs of: mvn clean package Needs testing on other platforms, hence this commit. Also trimmed some unneeded included JAR libraries from pom.xml, e.g. netty, async-http-client, and the *.js.map files from Swagger-UI, which seems to reduce output JAR size from about 51MB to about 44MB. --- pom.xml | 132 +++++++++++++++++++++++----- src/main/resources/build.properties | 4 +- 2 files changed, 111 insertions(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index 2f019e7f..19485797 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,37 @@ + + pl.project13.maven + git-commit-id-plugin + 4.0.0 + + + get-the-git-infos + + revision + + initialize + + + + true + ${project.build.outputDirectory}/git.properties + + ^git.commit.time$ + ^git.commit.id.(abbrev|full)$ + + yyyyMMddHHmmss + UTC + + -devel + + full + true + true + false + + com.google.code.maven-replacer-plugin @@ -79,34 +110,55 @@ 1.5.3 + replace-swagger-ui generate-resources replace + false + + ${project.build.directory}/swagger-ui.unpacked/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}/index.html + + + https://petstore.swagger.io/v2/swagger.json + /openapi.json + + + Swagger UI + API Documentation + + + deepLinking: true, + + deepLinking: true, + tagsSorter: "alpha", + operationsSorter: + "alpha", + + + + + + + replace-git-resources + generate-resources + + replace + + false + + ${project.build.outputDirectory}/git.properties + true + MULTILINE + + + ^(#.*$[\n\r]*) + + + + - - ${project.build.directory}/swagger-ui.unpacked/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}/index.html - - - https://petstore.swagger.io/v2/swagger.json - /openapi.json - - - Swagger UI - API Documentation - - - deepLinking: true, - - deepLinking: true, - tagsSorter: "alpha", - operationsSorter: - "alpha", - - - - @@ -179,12 +231,18 @@ org.apache.maven.plugins maven-jar-plugin - 3.0.2 + 3.2.0 + false true + + ${git.commit.id.full} + ${git.commit.time} + true + @@ -208,6 +266,7 @@ META-INF/*.SF META-INF/*.DSA META-INF/*.RSA + **/*.js.map @@ -234,6 +293,23 @@ + + io.github.zlika + reproducible-build-maven-plugin + 0.11 + + + package + strip-jar + + strip-jar + + + ${git.commit.time} + + + + @@ -360,6 +436,16 @@ com.fasterxml.jackson.core jackson-annotations + + + io.netty + netty + + + + org.asynchttpclient + async-http-client + diff --git a/src/main/resources/build.properties b/src/main/resources/build.properties index 7d9b532d..4aee9ab8 100644 --- a/src/main/resources/build.properties +++ b/src/main/resources/build.properties @@ -1,2 +1,2 @@ -build.timestamp=${build.timestamp} -build.version=${project.version} +build.timestamp=${git.commit.time} +build.version=${project.version}-${git.commit.id.abbrev}