aboutsummaryrefslogtreecommitdiffstats
path: root/build.gradle
blob: bf5e8aefcc44f51f9d58c474cb92a07b1f31117c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
/* ====================================================================
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
==================================================================== */
buildscript {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
    }

    dependencies {
        classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.1.2'	// 2.x requires Gradle >=4
        classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5"
    }
}

repositories {
    mavenCentral()
}


// Only add the plugin for Sonar if enabled
if (project.hasProperty('enableSonar')) {
    println 'Enabling Sonar support'
    apply plugin: "org.sonarqube"
}

// For help converting an Ant build to a Gradle build, see
// https://docs.gradle.org/current/userguide/ant.html

configurations {
    antLibs
}

dependencies {
    antLibs("junit:junit:4.12")
    antLibs("org.apache.ant:ant-junit:1.10.4")
    antLibs("org.apache.ant:ant-junit4:1.10.4")
}

ant.taskdef(name: "junit",
        classname: "org.apache.tools.ant.taskdefs.optional.junit.JUnitTask",
        classpath: configurations.antLibs.asPath)

ant.importBuild 'build.xml'

/**

Define properties for all projects, including this one 

*/
allprojects {
    apply plugin: 'eclipse'

    task wrapper(type: Wrapper) {
        gradleVersion = '4.6'
    }

    task adjustWrapperPropertiesFile {
        doLast {
            ant.replaceregexp(match:'^#.*', replace:'', flags:'g', byline:true) {
                fileset(dir: project.projectDir, includes: 'gradle/wrapper/gradle-wrapper.properties')
            }
            new File(project.projectDir, 'gradle/wrapper/gradle-wrapper.properties').with { it.text = it.readLines().findAll { it }.sort().join('\n') }
            ant.fixcrlf(file: 'gradle/wrapper/gradle-wrapper.properties', eol: 'lf')
        }
    }
    wrapper.finalizedBy adjustWrapperPropertiesFile
}

/**

Define things that are only necessary in sub-projects, but not in the master-project itself

*/
subprojects {
    //Put instructions for each sub project, but not the master
    apply plugin: 'java'
    apply plugin: 'jacoco'

    // See https://github.com/melix/japicmp-gradle-plugin 
    apply plugin: 'me.champeau.gradle.japicmp'
        
    version = '4.0.0-SNAPSHOT'
    ext {
        japicmpversion = '3.17'
    }

    tasks.withType(JavaCompile) {
        options.encoding = 'UTF-8'
    }

    sourceCompatibility = 1.8

    repositories {
        mavenCentral()
    }

    jar {
        manifest {
            attributes 'Implementation-Title': 'Apache POI', 'Implementation-Version': version
        }
    }

    test {
        // Exclude some tests that are not actually tests or do not run cleanly on purpose
        exclude '**/BaseTestBorderStyle.class'
        exclude '**/BaseTestCellUtil.class'
        exclude '**/TestUnfixedBugs.class'
        exclude '**/TestOneFile.class'

        // set heap size for the test JVM(s)
        minHeapSize = "128m"
        maxHeapSize = "768m"

        // Specifying the local via system properties did not work, so we set them this way
        jvmArgs '-Duser.language=en -Duser.country=US'
  
        // show standard out and standard error of the test JVM(s) on the console
        //testLogging.showStandardStreams = true

        // http://forums.gradle.org/gradle/topics/jacoco_related_failure_in_multiproject_build
        systemProperties['user.dir'] = workingDir
        
        systemProperties['POI.testdata.path'] = '../../test-data'
    }

    jacoco {
        toolVersion = '0.7.9'
    }
    
    // ensure the build-dir exists
    projectDir.mkdirs()

    if (project.hasProperty('enableSonar')) {
        sonarqube {
            properties {
                // as we currently use build/<module>/ as project-basedir, we need to tell Sonar to use
                // the root-folder as "basedir" for the projects
                property "sonar.projectBaseDir", "$projectDir/../.."
            }
        }
    }

    // japicmp will fail with "Could not load" because we moved some classes out of the root-package
    // for Java 9 compatibility in 4.0.0
    task(japicmp, type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
        to = jar.archivePath
        onlyModified = true
        onlyBinaryIncompatibleModified = true
        failOnModification = false
        txtOutputFile = file("$buildDir/reports/japi.txt")
        htmlOutputFile = file("$buildDir/reports/japi.html")
    }
}

project('main') {
    sourceSets.main.java.srcDirs = ['../../src/java']
    sourceSets.main.resources.srcDirs = ['../../src/resources/main']
    sourceSets.test.java.srcDirs = ['../../src/testcases']

    dependencies {
        compile 'commons-codec:commons-codec:1.11'
        compile 'commons-logging:commons-logging:1.2'
        compile 'org.apache.commons:commons-collections4:4.2'
        compile 'org.apache.commons:commons-math3:3.6.1'

        testCompile 'junit:junit:4.12'
    }

    jar {
        manifest {
            attributes 'Automatic-Module-Name': 'org.apache.poi.main'
        }
    }

    // Create a separate jar for test-code to depend on it in other projects
    // See http://stackoverflow.com/questions/5144325/gradle-test-dependency
    task testJar(type: Jar, dependsOn: testClasses) {
        baseName = "test-${project.archivesBaseName}"
        from sourceSets.test.output
    }

    configurations {
        tests
    }

    artifacts {
        tests testJar
    }

    japicmp.baseline = 'org.apache.poi:poi:' + japicmpversion + '@jar'
}

project('ooxml') {
    sourceSets.main.java.srcDirs = ['../../src/ooxml/java']
    sourceSets.main.resources.srcDirs = ['../../src/ooxml/resources', '../../src/resources/ooxml']
    sourceSets.test.java.srcDirs = ['../../src/ooxml/testcases']

    // for now import the ant-task for building the jars from build.xml
    // we need to rename the tasks as e.g. task "jar" conflicts with :ooxml:jar
    ant.importBuild('../../build.xml') { antTargetName ->
        'ant-' + antTargetName
    }
    compileJava.dependsOn 'ant-compile-ooxml-xsds'

    dependencies {
        compile 'org.apache.xmlbeans:xmlbeans:3.0.0'
        compile 'org.apache.commons:commons-collections4:4.2'
        compile 'org.apache.commons:commons-math3:3.6.1'
        compile 'org.apache.commons:commons-compress:1.17'
        compile 'org.apache.santuario:xmlsec:2.1.0'
        compile 'org.bouncycastle:bcpkix-jdk15on:1.59'
        compile 'com.github.virtuald:curvesapi:1.05'

        // for ooxml-lite, should we move this somewhere else?
        compile 'junit:junit:4.12'

        compile project(':main')
        compile project(':scratchpad')		// TODO: get rid of this dependency!
        compile files('../../ooxml-lib/ooxml-schemas-1.4.jar')
        compile files('../../ooxml-lib/ooxml-security-1.1.jar')

        testCompile 'junit:junit:4.12'
        testCompile 'org.mockito:mockito-core:2.13.0'
        testCompile 'org.xmlunit:xmlunit-core:2.5.1'
        testCompile project(path: ':main', configuration: 'tests')
        testCompile 'org.openjdk.jmh:jmh-core:1.19'
        testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.19'
    }

    jar {
        manifest {
            attributes 'Automatic-Module-Name': 'org.apache.poi.ooxml'
        }
    }

    japicmp.baseline = 'org.apache.poi:poi-ooxml:' + japicmpversion + '@jar'
}

project('examples') {
    sourceSets.main.java.srcDirs = ['../../src/examples/src']

    dependencies {
        compile project(':main')
        compile project(':ooxml')
    }

    japicmp.enabled = false
}


project('excelant') {
    sourceSets.main.java.srcDirs = ['../../src/excelant/java']
    sourceSets.main.resources.srcDirs = ['../../src/excelant/resources']
    sourceSets.test.java.srcDirs = ['../../src/excelant/testcases']

    dependencies {
        compile 'org.apache.ant:ant:1.10.4'

        compile project(':main')
        compile project(':ooxml')

        testCompile project(path: ':main', configuration: 'tests')
    }

	jar {
		manifest {
			attributes 'Automatic-Module-Name': 'org.apache.poi.excelant'
		}
	}

    japicmp.baseline = 'org.apache.poi:poi-excelant:' + japicmpversion + '@jar'
}

project('integrationtest') {
    sourceSets.test.java.srcDirs = ['../../src/integrationtest']

    dependencies {
        compile 'org.apache.ant:ant:1.10.4'

        compile project(':main')
        compile project(':ooxml')
        compile project(':scratchpad')
        compile project(':examples')

        testCompile 'junit:junit:4.12'
    }

	jar {
		manifest {
			attributes 'Automatic-Module-Name': 'org.apache.poi.integrationtest'
		}
	}

	test {
        // exclude these from the normal test-run
        exclude '**/TestAllFiles.class'
        exclude '**/*FileHandler.class'
        exclude '**/RecordsStresser.class'
    }

    task integrationTest(type: Test) {
        // these are just tests used during development of more test-code
        exclude '**/*FileHandler.class'
        exclude '**/RecordStresser.class'
    }

    japicmp.enabled = false
}

project('scratchpad') {
    sourceSets.main.java.srcDirs = ['../../src/scratchpad/src']
    sourceSets.main.resources.srcDirs = ['../../src/resources/scratchpad']
    sourceSets.test.java.srcDirs = ['../../src/scratchpad/testcases']

    dependencies {
        compile project(':main')
        // cyclic-dependency here: compile project(':ooxml')

        testCompile 'junit:junit:4.12'
        testCompile project(path: ':main', configuration: 'tests')
    }

	jar {
		manifest {
			attributes 'Automatic-Module-Name': 'org.apache.poi.scratchpad'
		}
	}

    japicmp.baseline = 'org.apache.poi:poi-scratchpad:' + japicmpversion + '@jar'
}