You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.gradle 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. buildscript {
  16. repositories {
  17. maven { url "https://plugins.gradle.org/m2/" }
  18. }
  19. dependencies {
  20. classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.1.2' // 2.x requires Gradle >=4
  21. classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5"
  22. }
  23. }
  24. repositories {
  25. mavenCentral()
  26. }
  27. // Only add the plugin for Sonar if enabled
  28. if (project.hasProperty('enableSonar')) {
  29. println 'Enabling Sonar support'
  30. apply plugin: "org.sonarqube"
  31. }
  32. // For help converting an Ant build to a Gradle build, see
  33. // https://docs.gradle.org/current/userguide/ant.html
  34. configurations {
  35. antLibs
  36. }
  37. dependencies {
  38. antLibs("junit:junit:4.12")
  39. antLibs("org.apache.ant:ant-junit:1.10.4")
  40. antLibs("org.apache.ant:ant-junit4:1.10.4")
  41. }
  42. ant.taskdef(name: "junit",
  43. classname: "org.apache.tools.ant.taskdefs.optional.junit.JUnitTask",
  44. classpath: configurations.antLibs.asPath)
  45. ant.importBuild 'build.xml'
  46. /**
  47. Define properties for all projects, including this one
  48. */
  49. allprojects {
  50. apply plugin: 'eclipse'
  51. task wrapper(type: Wrapper) {
  52. gradleVersion = '4.6'
  53. }
  54. task adjustWrapperPropertiesFile {
  55. doLast {
  56. ant.replaceregexp(match:'^#.*', replace:'', flags:'g', byline:true) {
  57. fileset(dir: project.projectDir, includes: 'gradle/wrapper/gradle-wrapper.properties')
  58. }
  59. new File(project.projectDir, 'gradle/wrapper/gradle-wrapper.properties').with { it.text = it.readLines().findAll { it }.sort().join('\n') }
  60. ant.fixcrlf(file: 'gradle/wrapper/gradle-wrapper.properties', eol: 'lf')
  61. }
  62. }
  63. wrapper.finalizedBy adjustWrapperPropertiesFile
  64. }
  65. /**
  66. Define things that are only necessary in sub-projects, but not in the master-project itself
  67. */
  68. subprojects {
  69. //Put instructions for each sub project, but not the master
  70. apply plugin: 'java'
  71. apply plugin: 'jacoco'
  72. // See https://github.com/melix/japicmp-gradle-plugin
  73. apply plugin: 'me.champeau.gradle.japicmp'
  74. version = '4.0.1-SNAPSHOT'
  75. ext {
  76. japicmpversion = '4.0.0'
  77. }
  78. tasks.withType(JavaCompile) {
  79. options.encoding = 'UTF-8'
  80. }
  81. sourceCompatibility = 1.8
  82. repositories {
  83. mavenCentral()
  84. }
  85. jar {
  86. manifest {
  87. attributes 'Implementation-Title': 'Apache POI', 'Implementation-Version': version
  88. }
  89. }
  90. test {
  91. // Exclude some tests that are not actually tests or do not run cleanly on purpose
  92. exclude '**/BaseTestBorderStyle.class'
  93. exclude '**/BaseTestCellUtil.class'
  94. exclude '**/TestUnfixedBugs.class'
  95. exclude '**/TestOneFile.class'
  96. // Exclude Test Suites
  97. exclude '**/All*Tests.class'
  98. exclude '**/HSSFTests.class'
  99. // set heap size for the test JVM(s)
  100. minHeapSize = "128m"
  101. maxHeapSize = "768m"
  102. // Specifying the local via system properties did not work, so we set them this way
  103. jvmArgs '-Duser.language=en -Duser.country=US'
  104. // show standard out and standard error of the test JVM(s) on the console
  105. //testLogging.showStandardStreams = true
  106. // http://forums.gradle.org/gradle/topics/jacoco_related_failure_in_multiproject_build
  107. systemProperties['user.dir'] = workingDir
  108. systemProperties['POI.testdata.path'] = '../../test-data'
  109. // this is necessary for JDK 9+ to keep formatting dates the same way as in previous JDK-versions
  110. systemProperties['java.locale.providers'] = 'JRE,CLDR'
  111. }
  112. jacoco {
  113. toolVersion = '0.8.2'
  114. }
  115. // ensure the build-dir exists
  116. projectDir.mkdirs()
  117. if (project.hasProperty('enableSonar')) {
  118. sonarqube {
  119. properties {
  120. // as we currently use build/<module>/ as project-basedir, we need to tell Sonar to use
  121. // the root-folder as "basedir" for the projects
  122. property "sonar.projectBaseDir", "$projectDir/../.."
  123. }
  124. }
  125. }
  126. // japicmp will fail with "Could not load" because we moved some classes out of the root-package
  127. // for Java 9 compatibility in 4.0.0
  128. task(japicmp, type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  129. to = jar.archivePath
  130. onlyModified = true
  131. onlyBinaryIncompatibleModified = true
  132. failOnModification = false
  133. txtOutputFile = file("$buildDir/reports/japi.txt")
  134. htmlOutputFile = file("$buildDir/reports/japi.html")
  135. }
  136. }
  137. project('main') {
  138. sourceSets.main.java.srcDirs = ['../../src/java']
  139. sourceSets.main.resources.srcDirs = ['../../src/resources/main']
  140. sourceSets.test.java.srcDirs = ['../../src/testcases']
  141. dependencies {
  142. compile 'commons-codec:commons-codec:1.11'
  143. compile 'commons-logging:commons-logging:1.2'
  144. compile 'org.apache.commons:commons-collections4:4.2'
  145. compile 'org.apache.commons:commons-math3:3.6.1'
  146. compile 'javax.xml.bind:jaxb-api:2.3.0'
  147. compile 'com.sun.xml.bind:jaxb-impl:2.3.0.1'
  148. compile 'com.sun.xml.bind:jaxb-core:2.3.0.1'
  149. compile 'javax.activation:activation:1.1.1'
  150. testCompile 'junit:junit:4.12'
  151. }
  152. jar {
  153. manifest {
  154. attributes 'Automatic-Module-Name': 'org.apache.poi.main'
  155. }
  156. }
  157. // Create a separate jar for test-code to depend on it in other projects
  158. // See http://stackoverflow.com/questions/5144325/gradle-test-dependency
  159. task testJar(type: Jar, dependsOn: testClasses) {
  160. baseName = "test-${project.archivesBaseName}"
  161. from sourceSets.test.output
  162. }
  163. configurations {
  164. tests
  165. }
  166. artifacts {
  167. tests testJar
  168. }
  169. japicmp.baseline = 'org.apache.poi:poi:' + japicmpversion + '@jar'
  170. }
  171. project('ooxml') {
  172. sourceSets.main.java.srcDirs = ['../../src/ooxml/java']
  173. sourceSets.main.resources.srcDirs = ['../../src/ooxml/resources', '../../src/resources/ooxml']
  174. sourceSets.test.java.srcDirs = ['../../src/ooxml/testcases']
  175. // for now import the ant-task for building the jars from build.xml
  176. // we need to rename the tasks as e.g. task "jar" conflicts with :ooxml:jar
  177. ant.importBuild('../../build.xml') { antTargetName ->
  178. 'ant-' + antTargetName
  179. }
  180. compileJava.dependsOn 'ant-compile-ooxml-xsds'
  181. dependencies {
  182. compile 'org.apache.xmlbeans:xmlbeans:3.0.1'
  183. compile 'org.apache.commons:commons-collections4:4.2'
  184. compile 'org.apache.commons:commons-math3:3.6.1'
  185. compile 'org.apache.commons:commons-compress:1.18'
  186. compile 'org.apache.santuario:xmlsec:2.1.0'
  187. compile 'org.bouncycastle:bcpkix-jdk15on:1.59'
  188. compile 'com.github.virtuald:curvesapi:1.05'
  189. // for ooxml-lite, should we move this somewhere else?
  190. compile 'junit:junit:4.12'
  191. compile project(':main')
  192. compile project(':scratchpad') // TODO: get rid of this dependency!
  193. compile files('../../ooxml-lib/ooxml-schemas-1.4.jar')
  194. compile files('../../ooxml-lib/ooxml-security-1.1.jar')
  195. testCompile 'junit:junit:4.12'
  196. testCompile 'org.mockito:mockito-core:2.21.0'
  197. testCompile 'org.xmlunit:xmlunit-core:2.5.1'
  198. testCompile project(path: ':main', configuration: 'tests')
  199. testCompile 'org.openjdk.jmh:jmh-core:1.19'
  200. testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.19'
  201. }
  202. jar {
  203. manifest {
  204. attributes 'Automatic-Module-Name': 'org.apache.poi.ooxml'
  205. }
  206. }
  207. japicmp.baseline = 'org.apache.poi:poi-ooxml:' + japicmpversion + '@jar'
  208. }
  209. project('examples') {
  210. sourceSets.main.java.srcDirs = ['../../src/examples/src']
  211. dependencies {
  212. compile project(':main')
  213. compile project(':ooxml')
  214. }
  215. japicmp.enabled = false
  216. }
  217. project('excelant') {
  218. sourceSets.main.java.srcDirs = ['../../src/excelant/java']
  219. sourceSets.main.resources.srcDirs = ['../../src/excelant/resources']
  220. sourceSets.test.java.srcDirs = ['../../src/excelant/testcases']
  221. dependencies {
  222. compile 'org.apache.ant:ant:1.10.4'
  223. compile project(':main')
  224. compile project(':ooxml')
  225. testCompile project(path: ':main', configuration: 'tests')
  226. }
  227. jar {
  228. manifest {
  229. attributes 'Automatic-Module-Name': 'org.apache.poi.excelant'
  230. }
  231. }
  232. japicmp.baseline = 'org.apache.poi:poi-excelant:' + japicmpversion + '@jar'
  233. }
  234. project('integrationtest') {
  235. sourceSets.test.java.srcDirs = ['../../src/integrationtest']
  236. dependencies {
  237. compile 'org.apache.ant:ant:1.10.4'
  238. compile project(':main')
  239. compile project(':ooxml')
  240. compile project(':scratchpad')
  241. compile project(':examples')
  242. testCompile 'junit:junit:4.12'
  243. }
  244. jar {
  245. manifest {
  246. attributes 'Automatic-Module-Name': 'org.apache.poi.integrationtest'
  247. }
  248. }
  249. test {
  250. // exclude these from the normal test-run
  251. exclude '**/TestAllFiles.class'
  252. exclude '**/*FileHandler.class'
  253. exclude '**/RecordsStresser.class'
  254. }
  255. task integrationTest(type: Test) {
  256. // these are just tests used during development of more test-code
  257. exclude '**/*FileHandler.class'
  258. exclude '**/RecordStresser.class'
  259. }
  260. japicmp.enabled = false
  261. }
  262. project('scratchpad') {
  263. sourceSets.main.java.srcDirs = ['../../src/scratchpad/src']
  264. sourceSets.main.resources.srcDirs = ['../../src/resources/scratchpad']
  265. sourceSets.test.java.srcDirs = ['../../src/scratchpad/testcases']
  266. dependencies {
  267. compile project(':main')
  268. // cyclic-dependency here: compile project(':ooxml')
  269. testCompile 'junit:junit:4.12'
  270. testCompile project(path: ':main', configuration: 'tests')
  271. }
  272. jar {
  273. manifest {
  274. attributes 'Automatic-Module-Name': 'org.apache.poi.scratchpad'
  275. }
  276. }
  277. japicmp.baseline = 'org.apache.poi:poi-scratchpad:' + japicmpversion + '@jar'
  278. }