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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. // Only add the plugin for Sonar if enabled
  25. if (project.hasProperty('enableSonar')) {
  26. println 'Enabling Sonar support'
  27. apply plugin: "org.sonarqube"
  28. }
  29. // For help converting an Ant build to a Gradle build, see
  30. // https://docs.gradle.org/current/userguide/ant.html
  31. ant.importBuild 'build.xml'
  32. /**
  33. Define properties for all projects, including this one
  34. */
  35. allprojects {
  36. apply plugin: 'eclipse'
  37. task wrapper(type: Wrapper) {
  38. gradleVersion = '4.6'
  39. }
  40. task adjustWrapperPropertiesFile {
  41. doLast {
  42. ant.replaceregexp(match:'^#.*', replace:'', flags:'g', byline:true) {
  43. fileset(dir: project.projectDir, includes: 'gradle/wrapper/gradle-wrapper.properties')
  44. }
  45. new File(project.projectDir, 'gradle/wrapper/gradle-wrapper.properties').with { it.text = it.readLines().findAll { it }.sort().join('\n') }
  46. ant.fixcrlf(file: 'gradle/wrapper/gradle-wrapper.properties', eol: 'lf')
  47. }
  48. }
  49. wrapper.finalizedBy adjustWrapperPropertiesFile
  50. }
  51. /**
  52. Define things that are only necessary in sub-projects, but not in the master-project itself
  53. */
  54. subprojects {
  55. //Put instructions for each sub project, but not the master
  56. apply plugin: 'java'
  57. apply plugin: 'jacoco'
  58. // See https://github.com/melix/japicmp-gradle-plugin
  59. apply plugin: 'me.champeau.gradle.japicmp'
  60. version = '4.0.0-SNAPSHOT'
  61. ext {
  62. japicmpversion = '3.17'
  63. }
  64. tasks.withType(JavaCompile) {
  65. options.encoding = 'UTF-8'
  66. }
  67. sourceCompatibility = 1.8
  68. repositories {
  69. mavenCentral()
  70. }
  71. jar {
  72. manifest {
  73. attributes 'Implementation-Title': 'Apache POI', 'Implementation-Version': version
  74. }
  75. }
  76. test {
  77. // Exclude some tests that are not actually tests or do not run cleanly on purpose
  78. exclude '**/BaseTestBorderStyle.class'
  79. exclude '**/BaseTestCellUtil.class'
  80. exclude '**/TestUnfixedBugs.class'
  81. exclude '**/TestOneFile.class'
  82. // set heap size for the test JVM(s)
  83. minHeapSize = "128m"
  84. maxHeapSize = "768m"
  85. // Specifying the local via system properties did not work, so we set them this way
  86. jvmArgs '-Duser.language=en -Duser.country=US'
  87. // show standard out and standard error of the test JVM(s) on the console
  88. //testLogging.showStandardStreams = true
  89. // http://forums.gradle.org/gradle/topics/jacoco_related_failure_in_multiproject_build
  90. systemProperties['user.dir'] = workingDir
  91. systemProperties['POI.testdata.path'] = '../../test-data'
  92. }
  93. jacoco {
  94. toolVersion = '0.7.9'
  95. }
  96. // ensure the build-dir exists
  97. projectDir.mkdirs()
  98. if (project.hasProperty('enableSonar')) {
  99. sonarqube {
  100. properties {
  101. // as we currently use build/<module>/ as project-basedir, we need to tell Sonar to use
  102. // the root-folder as "basedir" for the projects
  103. property "sonar.projectBaseDir", "$projectDir/../.."
  104. }
  105. }
  106. }
  107. }
  108. project('main') {
  109. sourceSets.main.java.srcDirs = ['../../src/java']
  110. sourceSets.main.resources.srcDirs = ['../../src/resources/main']
  111. sourceSets.test.java.srcDirs = ['../../src/testcases']
  112. dependencies {
  113. compile 'commons-codec:commons-codec:1.11'
  114. compile 'commons-logging:commons-logging:1.2'
  115. compile 'org.apache.commons:commons-collections4:4.1'
  116. compile 'org.apache.commons:commons-math3:3.6.1'
  117. testCompile 'junit:junit:4.12'
  118. }
  119. // Create a separate jar for test-code to depend on it in other projects
  120. // See http://stackoverflow.com/questions/5144325/gradle-test-dependency
  121. task testJar(type: Jar, dependsOn: testClasses) {
  122. baseName = "test-${project.archivesBaseName}"
  123. from sourceSets.test.output
  124. }
  125. configurations {
  126. tests
  127. }
  128. artifacts {
  129. tests testJar
  130. }
  131. // TOOD: we should not duplicate this task in each project, but I did not figure out how to inject the artifactId for each project
  132. task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  133. baseline = 'org.apache.poi:poi:' + japicmpversion + '@jar'
  134. to = jar.archivePath
  135. onlyModified = true
  136. onlyBinaryIncompatibleModified = true
  137. failOnModification = false
  138. txtOutputFile = file("$buildDir/reports/japi.txt")
  139. htmlOutputFile = file("$buildDir/reports/japi.html")
  140. }
  141. }
  142. project('ooxml') {
  143. sourceSets.main.java.srcDirs = ['../../src/ooxml/java']
  144. sourceSets.main.resources.srcDirs = ['../../src/ooxml/resources', '../../src/resources/ooxml']
  145. sourceSets.test.java.srcDirs = ['../../src/ooxml/testcases']
  146. // for now import the ant-task for building the jars from build.xml
  147. // we need to rename the tasks as e.g. task "jar" conflicts with :ooxml:jar
  148. ant.importBuild('../../build.xml') { antTargetName ->
  149. 'ant-' + antTargetName
  150. }
  151. compileJava.dependsOn 'ant-compile-ooxml-xsds'
  152. dependencies {
  153. compile 'org.apache.xmlbeans:xmlbeans:2.6.0'
  154. compile 'org.apache.commons:commons-collections4:4.1'
  155. compile 'org.apache.commons:commons-math3:3.6.1'
  156. compile 'org.apache.commons:commons-compress:1.17'
  157. compile 'org.apache.santuario:xmlsec:2.1.0'
  158. compile 'org.bouncycastle:bcpkix-jdk15on:1.59'
  159. compile 'com.github.virtuald:curvesapi:1.05'
  160. // for ooxml-lite, should we move this somewhere else?
  161. compile 'junit:junit:4.12'
  162. compile project(':main')
  163. compile project(':scratchpad') // TODO: get rid of this dependency!
  164. compile files('../../ooxml-lib/ooxml-schemas-1.4.jar')
  165. compile files('../../ooxml-lib/ooxml-security-1.1.jar')
  166. testCompile 'junit:junit:4.12'
  167. testCompile 'org.mockito:mockito-core:2.13.0'
  168. testCompile 'org.xmlunit:xmlunit-core:2.5.1'
  169. testCompile project(path: ':main', configuration: 'tests')
  170. testCompile 'org.openjdk.jmh:jmh-core:1.19'
  171. testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.19'
  172. }
  173. // TODO: we should not duplicate this task in each project, but I did not figure out how to inject the artifactId for each project
  174. task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  175. baseline = 'org.apache.poi:poi-ooxml:' + japicmpversion + '@jar'
  176. to = jar.archivePath
  177. onlyModified = true
  178. onlyBinaryIncompatibleModified = true
  179. failOnModification = false
  180. txtOutputFile = file("$buildDir/reports/japi.txt")
  181. htmlOutputFile = file("$buildDir/reports/japi.html")
  182. }
  183. }
  184. project('examples') {
  185. sourceSets.main.java.srcDirs = ['../../src/examples/src']
  186. dependencies {
  187. compile project(':main')
  188. compile project(':ooxml')
  189. }
  190. }
  191. project('excelant') {
  192. sourceSets.main.java.srcDirs = ['../../src/excelant/java']
  193. sourceSets.main.resources.srcDirs = ['../../src/excelant/resources']
  194. sourceSets.test.java.srcDirs = ['../../src/excelant/testcases']
  195. dependencies {
  196. compile 'org.apache.ant:ant:1.10.1'
  197. compile project(':main')
  198. compile project(':ooxml')
  199. testCompile project(path: ':main', configuration: 'tests')
  200. }
  201. // TOOD: we should not duplicate this task in each project, but I did not figure out how to inject the artifactId for each project
  202. task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  203. baseline = 'org.apache.poi:poi-excelant:' + japicmpversion + '@jar'
  204. to = jar.archivePath
  205. onlyModified = true
  206. onlyBinaryIncompatibleModified = true
  207. failOnModification = false
  208. txtOutputFile = file("$buildDir/reports/japi.txt")
  209. htmlOutputFile = file("$buildDir/reports/japi.html")
  210. }
  211. }
  212. project('integrationtest') {
  213. sourceSets.test.java.srcDirs = ['../../src/integrationtest']
  214. dependencies {
  215. compile 'org.apache.ant:ant:1.10.1'
  216. compile project(':main')
  217. compile project(':ooxml')
  218. compile project(':scratchpad')
  219. compile project(':examples')
  220. testCompile 'junit:junit:4.12'
  221. }
  222. test {
  223. // exclude these from the normal test-run
  224. exclude '**/TestAllFiles.class'
  225. exclude '**/*FileHandler.class'
  226. exclude '**/RecordsStresser.class'
  227. }
  228. task integrationTest(type: Test) {
  229. // these are just tests used during development of more test-code
  230. exclude '**/*FileHandler.class'
  231. exclude '**/RecordStresser.class'
  232. }
  233. }
  234. project('scratchpad') {
  235. sourceSets.main.java.srcDirs = ['../../src/scratchpad/src']
  236. sourceSets.main.resources.srcDirs = ['../../src/resources/scratchpad']
  237. sourceSets.test.java.srcDirs = ['../../src/scratchpad/testcases']
  238. dependencies {
  239. compile project(':main')
  240. // cyclic-dependency here: compile project(':ooxml')
  241. testCompile 'junit:junit:4.12'
  242. testCompile project(path: ':main', configuration: 'tests')
  243. }
  244. // TOOD: we should not duplicate this task in each project, but I did not figure out how to inject the artifactId for each project
  245. task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  246. baseline = 'org.apache.poi:poi-scratchpad:' + japicmpversion + '@jar'
  247. to = jar.archivePath
  248. onlyModified = true
  249. onlyBinaryIncompatibleModified = true
  250. failOnModification = false
  251. txtOutputFile = file("$buildDir/reports/japi.txt")
  252. htmlOutputFile = file("$buildDir/reports/japi.html")
  253. }
  254. }