From 65132b0401061917677e9ae2a8be02498e7a9dc9 Mon Sep 17 00:00:00 2001 From: cushon Date: Wed, 18 Oct 2017 12:27:14 -0700 Subject: [PATCH] Bake version numbers in at build-time `getPackage().getImplementationVersion()` may not be reliable, see: https://github.com/google/google-java-format/commit/352aac773940c27d14fb06069dcb367b376b28be#commitcomment-25048691 MOE_MIGRATED_REVID=172638406 --- core/pom.xml | 42 +++++++++++++++++++ ... => GoogleJavaFormatVersion.java.template} | 5 +-- 2 files changed, 44 insertions(+), 3 deletions(-) rename core/src/main/java/com/google/googlejavaformat/java/{GoogleJavaFormatVersion.java => GoogleJavaFormatVersion.java.template} (83%) diff --git a/core/pom.xml b/core/pom.xml index 28c8abc43..907d8f84f 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -191,6 +191,48 @@ + + com.google.code.maven-replacer-plugin + replacer + 1.5.3 + + + generate-sources + + replace + + + + + core/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java.template + ${project.build.directory}/generated-sources/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java + + + %VERSION% + ${project.version} + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.0.0 + + + add-source + generate-sources + + add-source + + + + ${project.build.directory}/generated-sources/java/ + + + + + diff --git a/core/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java b/core/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java.template similarity index 83% rename from core/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java rename to core/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java.template index c681126bd..eed8e1b8c 100644 --- a/core/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java +++ b/core/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java.template @@ -18,8 +18,7 @@ class GoogleJavaFormatVersion { - static Object version() { - return Optional.ofNullable(Main.class.getPackage().getImplementationVersion()) - .orElse("unknown"); + static String version() { + return "%VERSION%"; } }