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%"; } }