From 5813b1aef26d66203c3e042e5238b767f503dc22 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Thu, 16 Sep 2021 19:25:43 +0000 Subject: [PATCH] Generate, compile and include class 'org.apache.poi.Version' in Gradle build git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1893384 13f79535-47bb-0310-9956-ffa450edef68 --- poi/build.gradle | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/poi/build.gradle b/poi/build.gradle index d71e86bc51..da8eeb9ff1 100644 --- a/poi/build.gradle +++ b/poi/build.gradle @@ -27,6 +27,10 @@ sourceSets { if (JavaVersion.current() != JavaVersion.VERSION_1_8) { output.dir(JAVA9_OUT, builtBy: 'cacheJava9') } + java { + // also include the generated Version.java + srcDirs += 'build/generated-sources' + } } test { if (JavaVersion.current() != JavaVersion.VERSION_1_8) { @@ -55,6 +59,27 @@ dependencies { javadocs project(':poi-scratchpad') } +// generate and compile the file Version.java file +task generateVersionJava() { + //dependsOn ':poi-ooxml:build', ':poi-integration:build', ':poi-excelant:build' + + File fileIn = file("src/main/version/Version.java.template") + File fileOut = file("build/generated-sources/org/apache/poi/Version.java") + + inputs.file fileIn + outputs.file fileOut + + doLast { + String content = fileIn.text + + content = content.replace("@VERSION@", version) + content = content.replace("@DSTAMP@", new Date().format('yyyyMMdd')) + + fileOut.write content + } +} +compileJava.dependsOn 'generateVersionJava' + final String MODULE_NAME = 'org.apache.poi.poi' final Pattern MODULE_NOT_REGEX = ~'(poi[/\\\\][^/\\\\]+$|batik-script)' final Pattern MODULE_REGEX = ~'\\.jar$' @@ -177,4 +202,4 @@ publishing { } } } -} \ No newline at end of file +} -- 2.39.5