Skip to content

Commit 1dbcea4

Browse files
committed
Some changes to the Gradle build
Apply IDE suggestions for Gradle build files Remove obsolete sorting of gradle-wrapper.properties git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1923284 13f79535-47bb-0310-9956-ffa450edef68
1 parent 045a37f commit 1dbcea4

File tree

12 files changed

+113
-124
lines changed

12 files changed

+113
-124
lines changed

build.gradle

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,6 @@ wrapper {
8080
gradleVersion = '8.12'
8181
}
8282

83-
task adjustWrapperPropertiesFile {
84-
doLast {
85-
ant.replaceregexp(match:'^#.*', replace:'', flags:'g', byline:true) {
86-
fileset(dir: project.projectDir, includes: 'gradle/wrapper/gradle-wrapper.properties')
87-
}
88-
new File(project.projectDir, 'gradle/wrapper/gradle-wrapper.properties').with { it.text = it.readLines().findAll { it }.sort().join('\n') }
89-
ant.fixcrlf(file: 'gradle/wrapper/gradle-wrapper.properties', eol: 'lf')
90-
}
91-
}
92-
wrapper.finalizedBy adjustWrapperPropertiesFile
93-
9483
group = 'org.apache.poi'
9584

9685
/**
@@ -150,7 +139,7 @@ subprojects {
150139
}
151140

152141
configurations {
153-
all {
142+
configureEach {
154143
resolutionStrategy {
155144
force "commons-io:commons-io:${commonsIoVersion}"
156145
force 'org.slf4j:slf4j-api:2.0.16'
@@ -159,16 +148,16 @@ subprojects {
159148
}
160149
}
161150

162-
tasks.withType(JavaCompile) {
151+
tasks.withType(JavaCompile).configureEach {
163152
options.encoding = 'UTF-8'
164153
options.compilerArgs += '-Xlint:unchecked'
165154
options.deprecation = true
166155
options.incremental = true
167156
}
168-
tasks.withType(Test) {
157+
tasks.withType(Test).configureEach {
169158
systemProperty "file.encoding", "UTF-8"
170159
}
171-
tasks.withType(Javadoc) {
160+
tasks.withType(Javadoc).configureEach {
172161
options.encoding = 'UTF-8'
173162
}
174163
tasks.withType(AbstractArchiveTask).configureEach {
@@ -227,13 +216,13 @@ subprojects {
227216

228217
// helper-target to get a directory with all third-party libraries
229218
// this is used for mass-regression-testing
230-
task getDeps(type: Copy) {
219+
tasks.register('getDeps', Copy) {
231220
from sourceSets.main.runtimeClasspath
232221
into 'build/runtime/'
233222
}
234223

235-
tasks.withType(Jar) {
236-
duplicatesStrategy = 'fail'
224+
tasks.withType(Jar).configureEach {
225+
duplicatesStrategy = DuplicatesStrategy.FAIL
237226
destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
238227

239228
doLast {
@@ -375,10 +364,10 @@ subprojects {
375364
]
376365

377366
// detect if running on Jenkins/CI
378-
isCIBuild |= Boolean.valueOf(System.getenv("CI_BUILD"));
367+
isCIBuild |= Boolean.valueOf(System.getenv("CI_BUILD"))
379368

380369
if (isCIBuild) {
381-
System.out.println("Run with reduced parallelism for CI build");
370+
System.out.println("Run with reduced parallelism for CI build")
382371

383372
jvmArgs += [
384373
// Strictly serial
@@ -597,7 +586,7 @@ subprojects {
597586

598587
generatePomFileForPOIPublication.destination = "../build/dist/maven/${project.archivesBaseName}/${project.archivesBaseName}-${project.version}.pom"
599588

600-
tasks.withType(GenerateModuleMetadata) {
589+
tasks.withType(GenerateModuleMetadata).configureEach {
601590
enabled = false
602591
}
603592

@@ -625,14 +614,14 @@ subprojects {
625614
}
626615

627616
// initial try to provide a combined JavaDoc, grouping is still missing here, though!
628-
task allJavaDoc(type: Javadoc) {
629-
var prj = [ project(':poi'), project(':poi-excelant'), project(':poi-ooxml'), project(':poi-scratchpad') ]
617+
tasks.register('allJavaDoc', Javadoc) {
618+
var prj = [project(':poi'), project(':poi-excelant'), project(':poi-ooxml'), project(':poi-scratchpad')]
630619
source prj.collect { it.sourceSets.main.allJava }
631620

632621
// for possible settings see https://docs.gradle.org/current/dsl/org.gradle.api.tasks.javadoc.Javadoc.html
633622
classpath = files(subprojects.collect { it.sourceSets.main.compileClasspath })
634623
destinationDir = file("${buildDir}/docs/javadoc")
635-
maxMemory="2048M"
624+
maxMemory = "2048M"
636625

637626
// for possible options see https://docs.gradle.org/current/javadoc/org/gradle/external/javadoc/StandardJavadocDocletOptions.html
638627
options.use = true
@@ -647,7 +636,7 @@ task allJavaDoc(type: Javadoc) {
647636
options.group('SS - Common Spreadsheet Format', 'org.apache.poi.ss*')
648637
options.group('HSSF - Horrible Spreadsheet Format', 'org.apache.poi.hssf*')
649638
options.group('XSSF - Open Office XML Spreadsheet Format', 'org.apache.poi.xssf*')
650-
options.group('SL - Common Slideshow Format', 'org.apache.poi.sl*')
639+
options.group('SL - Common Slideshow Format', 'org.apache.poi.sl*')
651640
options.group('HSLF - Horrible Slideshow Format', 'org.apache.poi.hslf*', 'org.apache.poi.hwmf*', 'org.apache.poi.hemf*')
652641
options.group('XSLF - Open Office XML Slideshow Format', 'org.apache.poi.xslf*')
653642
options.group('HWPF - Horrible Word Processor Format', 'org.apache.poi.hwpf*')
@@ -725,21 +714,21 @@ rat {
725714
}
726715

727716
task jenkins(dependsOn: [
728-
'replaceVersion',
729-
subprojects.build,
730-
subprojects.check,
731-
subprojects.javadoc,
732-
subprojects.jacocoTestReport,
733-
subprojects.getDeps,
734-
'srcDistZip',
735-
'srcDistTar',
736-
rat
717+
'replaceVersion',
718+
subprojects.build,
719+
subprojects.check,
720+
subprojects.javadoc,
721+
subprojects.jacocoTestReport,
722+
subprojects.getDeps,
723+
'srcDistZip',
724+
'srcDistTar',
725+
rat
737726
]) {}
738727

739728
task jenkinsLite(dependsOn: [
740-
'replaceVersion',
741-
subprojects.build,
742-
subprojects.test
729+
'replaceVersion',
730+
subprojects.build,
731+
subprojects.test
743732
]) {}
744733

745734
/*task downloadJarsToLibs() {
@@ -753,14 +742,14 @@ task jenkinsLite(dependsOn: [
753742

754743
//compileJava.dependsOn 'downloadJarsToLibs'
755744

756-
task replaceVersion() {
745+
tasks.register('replaceVersion') {
757746
outputs.upToDateWhen { false }
758747

759748
var version = subprojects[0].version
760749
var tokens = [
761-
[ 'osgi', 'pom.xml', '(packaging>\\n\\s*<version>)[0-9.]+(?:-SNAPSHOT|-RC\\d+)?', "\\1${version}" ],
762-
[ 'osgi', 'pom.xml', '(<poi.version>)[0-9.]+(?:-SNAPSHOT|-RC\\d+)?', "\\1${version}" ]
763-
// [ '.', 'build.gradle', ' version = \'[0-9.]+(?:-SNAPSHOT)?\'', " version = '${version}'" ]
750+
['osgi', 'pom.xml', '(packaging>\\n\\s*<version>)[0-9.]+(?:-SNAPSHOT|-RC\\d+)?', "\\1${version}"],
751+
['osgi', 'pom.xml', '(<poi.version>)[0-9.]+(?:-SNAPSHOT|-RC\\d+)?', "\\1${version}"]
752+
// [ '.', 'build.gradle', ' version = \'[0-9.]+(?:-SNAPSHOT)?\'', " version = '${version}'" ]
764753
]
765754

766755
doLast {
@@ -784,7 +773,7 @@ task zipJavadocs(type: Zip, dependsOn: allJavaDoc) {
784773
archiveExtension = 'jar'
785774
}
786775

787-
tasks.withType(Tar) {
776+
tasks.withType(Tar).configureEach {
788777
compression = Compression.GZIP
789778
archiveExtension = 'tgz'
790779
}
@@ -843,7 +832,7 @@ distributions {
843832
}
844833
}
845834

846-
task soLinkCheck() {
835+
tasks.register('soLinkCheck') {
847836
doLast {
848837
def path = ant.path {
849838
fileset(dir: '.', includes: '**/*.java') {
@@ -887,7 +876,7 @@ srcDistZip.dependsOn srcDep
887876
soLinkCheck.dependsOn srcDep
888877
rat.dependsOn soLinkCheck
889878

890-
task fixDistDir {
879+
tasks.register('fixDistDir') {
891880
doLast {
892881
ant.mkdir(dir: 'build/dist')
893882
ant.move(todir: 'build/dist') {

poi-examples/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ final String MODULE_NAME = 'org.apache.poi.examples'
4949
final Pattern MODULE_REGEX = ~'\\.jar$'
5050
final List MODULE_COMPILE_PATH = sourceSets.main.compileClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique()
5151

52-
task compileJava9(type: JavaCompile) {
52+
tasks.register('compileJava9', JavaCompile) {
5353
dependsOn 'compileJava', ':poi-ooxml:jar', ':poi-scratchpad:jar'
5454

5555
javaCompiler = javaToolchains.compilerFor {
@@ -61,8 +61,8 @@ task compileJava9(type: JavaCompile) {
6161
source = file(JAVA9_SRC)
6262
classpath = files()
6363
options.compilerArgs = [
64-
'--patch-module', "${MODULE_NAME}=${sourceSets.main.output.classesDirs.asPath}",
65-
'--module-path', files(MODULE_COMPILE_PATH).asPath
64+
'--patch-module', "${MODULE_NAME}=${sourceSets.main.output.classesDirs.asPath}",
65+
'--module-path', files(MODULE_COMPILE_PATH).asPath
6666
]
6767
}
6868

poi-examples/src/main/groovy/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ sourceSets {
3434
}
3535

3636
// Run out read demo by default
37-
tasks.withType(JavaExec) {
38-
classpath = sourceSets.main.runtimeClasspath
37+
tasks.withType(JavaExec).configureEach {
38+
classpath = sourceSets.main.runtimeClasspath
3939
}
40-
task runScript(type: JavaExec) {
40+
tasks.register('runScript', JavaExec) {
4141
mainClass = "SpreadSheetDemo"
4242
args = ["../../../../test-data/spreadsheet/Simple.xls"]
4343
}

poi-excelant/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ final String OOXML_LITE_AGENT = "../build/dist/maven/poi-ooxml-lite-agent/poi-oo
5757
final String OOXML_LITE_REPORT = '../src/resources/ooxml-lite-report'
5858
final String OOXML_LITE_INCLUDES = "^(com/microsoft/schemas|org/(etsi|openxmlformats|w3/)|org/apache/poi/schemas)"
5959

60-
task compileJava9(type: JavaCompile) {
60+
tasks.register('compileJava9', JavaCompile) {
6161
dependsOn 'compileJava', ':poi-ooxml:jar', ':poi-scratchpad:jar'
6262

6363
javaCompiler = javaToolchains.compilerFor {
@@ -69,12 +69,12 @@ task compileJava9(type: JavaCompile) {
6969
source = file(JAVA9_SRC)
7070
classpath = files()
7171
options.compilerArgs = [
72-
'--patch-module', "${MODULE_NAME}=${sourceSets.main.output.classesDirs.asPath}",
73-
'--module-path', files(MAIN_MODULE_PATH).asPath
72+
'--patch-module', "${MODULE_NAME}=${sourceSets.main.output.classesDirs.asPath}",
73+
'--module-path', files(MAIN_MODULE_PATH).asPath
7474
]
7575
}
7676

77-
task compileTest9(type: JavaCompile) {
77+
tasks.register('compileTest9', JavaCompile) {
7878
dependsOn 'compileTestJava', ':poi-ooxml:jar', ':poi-scratchpad:jar'
7979

8080
javaCompiler = javaToolchains.compilerFor {
@@ -85,8 +85,8 @@ task compileTest9(type: JavaCompile) {
8585
destinationDirectory = file(TEST9_OUT + VERSIONS9)
8686
source = file(TEST9_SRC)
8787
options.compilerArgs = [
88-
'--patch-module', "${MODULE_NAME}=${(sourceSets.main.output.classesDirs + sourceSets.test.output.classesDirs).asPath}",
89-
'--module-path', files(TEST_MODULE_PATH).asPath
88+
'--patch-module', "${MODULE_NAME}=${(sourceSets.main.output.classesDirs + sourceSets.test.output.classesDirs).asPath}",
89+
'--module-path', files(TEST_MODULE_PATH).asPath
9090
]
9191
classpath = files()
9292
}
@@ -123,7 +123,7 @@ task testJar(type: Jar, dependsOn: [ testClasses, compileTest9 ] ) {
123123

124124
setArchiveClassifier 'tests'
125125
// ignore second module-info.class from main
126-
duplicatesStrategy = 'exclude'
126+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
127127

128128
from sourceSets.test.output + sourceSets.main.output
129129

poi-integration/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ final String OOXML_LITE_AGENT = "../build/dist/maven/poi-ooxml-lite-agent/poi-oo
9090
final String OOXML_LITE_REPORT = '../src/resources/ooxml-lite-report'
9191
final String OOXML_LITE_INCLUDES = "^(com/microsoft/schemas|org/(etsi|openxmlformats|w3/)|org/apache/poi/schemas)"
9292

93-
task compileTest9(type: JavaCompile) {
93+
tasks.register('compileTest9', JavaCompile) {
9494
dependsOn 'compileTestJava', ':poi-ooxml:testJar', ':poi-scratchpad:testJar', ':poi-examples:jar'
9595

9696
javaCompiler = javaToolchains.compilerFor {
@@ -101,8 +101,8 @@ task compileTest9(type: JavaCompile) {
101101
destinationDirectory = file(TEST9_OUT + VERSIONS9)
102102
source = file(TEST9_SRC)
103103
options.compilerArgs = [
104-
'--patch-module', "${MODULE_NAME}=${(sourceSets.main.output.classesDirs + sourceSets.test.output.classesDirs).asPath}",
105-
'--module-path', files(MODULE_COMPILE_PATH).asPath
104+
'--patch-module', "${MODULE_NAME}=${(sourceSets.main.output.classesDirs + sourceSets.test.output.classesDirs).asPath}",
105+
'--module-path', files(MODULE_COMPILE_PATH).asPath
106106
]
107107
classpath = files()
108108
}
@@ -123,7 +123,7 @@ task testJar(type: Jar, dependsOn: [ testClasses, compileTest9 ] ) {
123123

124124
setArchiveClassifier 'tests'
125125
// ignore second module-info.class from main
126-
duplicatesStrategy = 'exclude'
126+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
127127

128128
from sourceSets.test.output + sourceSets.main.output
129129

poi-ooxml-full/build.gradle

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ compileJava {
5454
options.forkOptions.jvmArgs += '-Xmx2G'
5555
}
5656

57-
task compileJava9(type: JavaCompile) {
57+
tasks.register('compileJava9', JavaCompile) {
5858
dependsOn 'compileJava'
5959

6060
javaCompiler = javaToolchains.compilerFor {
@@ -66,24 +66,24 @@ task compileJava9(type: JavaCompile) {
6666
source = file(JAVA9_SRC)
6767
classpath = files()
6868
options.compilerArgs = [
69-
'--patch-module', "${MODULE_NAME}=${sourceSets.main.output.asPath}",
70-
'--module-path', files(MAIN_MODULE_PATH).asPath
69+
'--patch-module', "${MODULE_NAME}=${sourceSets.main.output.asPath}",
70+
'--module-path', files(MAIN_MODULE_PATH).asPath
7171
]
7272
}
7373

74-
task copy_xsds(type: Copy) {
75-
from ('src/main/xmlschema/org/apache/poi/xdgf')
76-
from ('src/main/xmlschema/org/apache/poi/schemas') {
74+
tasks.register('copy_xsds', Copy) {
75+
from('src/main/xmlschema/org/apache/poi/xdgf')
76+
from('src/main/xmlschema/org/apache/poi/schemas') {
7777
include 'XAdES*.xsd', '*.xsdconfig', 'xmldsig*.xsd', 'ooxmlSchemas.xsdconfig', 'markup-compatibility.xsd',
7878
'vmlDrawing.xsd', 'word10.xsd', 'word12.xsd', 'xlThreaded*.xsd', 'dml-drawing.xsd', 'drawing-chart2012.xsd',
7979
'chartEx.xsd'
8080
exclude '*.zip'
8181
}
82-
from ('src/main/xmlschema/org/apache/poi/poifs/crypt') {
82+
from('src/main/xmlschema/org/apache/poi/poifs/crypt') {
8383
include 'signatureInfo.xsd'
8484
}
85-
from (zipTree('src/main/xmlschema/org/apache/poi/schemas/OfficeOpenXML-XMLSchema-Transitional.zip'))
86-
from (zipTree('src/main/xmlschema/org/apache/poi/schemas/OpenPackagingConventions-XMLSchema.zip')) {
85+
from(zipTree('src/main/xmlschema/org/apache/poi/schemas/OfficeOpenXML-XMLSchema-Transitional.zip'))
86+
from(zipTree('src/main/xmlschema/org/apache/poi/schemas/OpenPackagingConventions-XMLSchema.zip')) {
8787
include 'opc-digSig.xsd', 'opc-relationships.xsd'
8888
}
8989
into 'build/xsds'
@@ -95,38 +95,38 @@ task generate_beans(dependsOn: copy_xsds) {
9595

9696
doLast {
9797
ant.uptodate(
98-
property: 'xmlbeans_uptodate',
99-
targetfile: 'build/generated-resources/org/apache/poi/schemas/ooxml/system/ooxml/TypeSystemHolder.class'
98+
property: 'xmlbeans_uptodate',
99+
targetfile: 'build/generated-resources/org/apache/poi/schemas/ooxml/system/ooxml/TypeSystemHolder.class'
100100
) {
101101
srcFiles(dir: 'build/xsds', includes: '*.xsd')
102102
}
103103

104104
ant.taskdef(
105-
name: 'xmlbean',
106-
classname: 'org.apache.xmlbeans.impl.tool.XMLBean',
107-
classpath: sourceSets.main.runtimeClasspath.asPath
105+
name: 'xmlbean',
106+
classname: 'org.apache.xmlbeans.impl.tool.XMLBean',
107+
classpath: sourceSets.main.runtimeClasspath.asPath
108108
)
109109

110110
if (!ant.properties.xmlbeans_uptodate) {
111111
ant.xmlbean(
112-
schema: 'build/xsds',
113-
srcgendir: BEANS_SRC,
114-
classgendir: BEANS_RES,
115-
destfile: 'build/xsds.jar',
116-
srconly: true,
117-
failonerror: true,
118-
fork: true,
119-
memoryMaximumSize: '1536m',
120-
typesystemname: 'ooxml',
121-
repackage: 'org.apache.xmlbeans.metadata:org.apache.poi.schemas.ooxml'
112+
schema: 'build/xsds',
113+
srcgendir: BEANS_SRC,
114+
classgendir: BEANS_RES,
115+
destfile: 'build/xsds.jar',
116+
srconly: true,
117+
failonerror: true,
118+
fork: true,
119+
memoryMaximumSize: '1536m',
120+
typesystemname: 'ooxml',
121+
repackage: 'org.apache.xmlbeans.metadata:org.apache.poi.schemas.ooxml'
122122
) {
123123
classpath = sourceSets.main.runtimeClasspath.asPath
124124
}
125125
}
126126
}
127127
}
128128

129-
task sourceJar(type: Jar) {
129+
tasks.register('sourceJar', Jar) {
130130
setArchiveClassifier 'sources'
131131
from sourceSets.main.allJava
132132
}

0 commit comments

Comments
 (0)