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
This commit is contained in:
Dominik Stadler 2021-09-16 19:25:43 +00:00
parent 914614f7a8
commit 5813b1aef2
1 changed files with 26 additions and 1 deletions

View File

@ -27,6 +27,10 @@ sourceSets {
if (JavaVersion.current() != JavaVersion.VERSION_1_8) { if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
output.dir(JAVA9_OUT, builtBy: 'cacheJava9') output.dir(JAVA9_OUT, builtBy: 'cacheJava9')
} }
java {
// also include the generated Version.java
srcDirs += 'build/generated-sources'
}
} }
test { test {
if (JavaVersion.current() != JavaVersion.VERSION_1_8) { if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
@ -55,6 +59,27 @@ dependencies {
javadocs project(':poi-scratchpad') 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 String MODULE_NAME = 'org.apache.poi.poi'
final Pattern MODULE_NOT_REGEX = ~'(poi[/\\\\][^/\\\\]+$|batik-script)' final Pattern MODULE_NOT_REGEX = ~'(poi[/\\\\][^/\\\\]+$|batik-script)'
final Pattern MODULE_REGEX = ~'\\.jar$' final Pattern MODULE_REGEX = ~'\\.jar$'