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 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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 = '3.4.1'
  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. systemProperties = System.properties
  83. // set heap size for the test JVM(s)
  84. minHeapSize = "128m"
  85. maxHeapSize = "768m"
  86. // show standard out and standard error of the test JVM(s) on the console
  87. //testLogging.showStandardStreams = true
  88. // http://forums.gradle.org/gradle/topics/jacoco_related_failure_in_multiproject_build
  89. systemProperties['user.dir'] = workingDir
  90. systemProperties['POI.testdata.path'] = '../../test-data'
  91. //systemProperties['user.language'] = 'en'
  92. //systemProperties['user.country'] = 'US'
  93. }
  94. test.beforeSuite { TestDescriptor suite ->
  95. System.setProperty('user.language', 'en')
  96. System.setProperty('user.country', 'US')
  97. }
  98. jacoco {
  99. toolVersion = '0.7.9'
  100. }
  101. // ensure the build-dir exists
  102. projectDir.mkdirs()
  103. if (project.hasProperty('enableSonar')) {
  104. sonarqube {
  105. properties {
  106. // as we currently use build/<module>/ as project-basedir, we need to tell Sonar to use
  107. // the root-folder as "basedir" for the projects
  108. property "sonar.projectBaseDir", "$projectDir/../.."
  109. }
  110. }
  111. }
  112. }
  113. project('main') {
  114. sourceSets.main.java.srcDirs = ['../../src/java']
  115. sourceSets.main.resources.srcDirs = ['../../src/resources/main']
  116. sourceSets.test.java.srcDirs = ['../../src/testcases']
  117. dependencies {
  118. compile 'commons-codec:commons-codec:1.11'
  119. compile 'commons-logging:commons-logging:1.2'
  120. compile 'org.apache.commons:commons-collections4:4.1'
  121. compile 'org.apache.commons:commons-math3:3.6.1'
  122. testCompile 'junit:junit:4.12'
  123. }
  124. // Create a separate jar for test-code to depend on it in other projects
  125. // See http://stackoverflow.com/questions/5144325/gradle-test-dependency
  126. task testJar(type: Jar, dependsOn: testClasses) {
  127. baseName = "test-${project.archivesBaseName}"
  128. from sourceSets.test.output
  129. }
  130. configurations {
  131. tests
  132. }
  133. artifacts {
  134. tests testJar
  135. }
  136. // TOOD: we should not duplicate this task in each project, but I did not figure out how to inject the artifactId for each project
  137. task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  138. baseline = 'org.apache.poi:poi:' + japicmpversion + '@jar'
  139. to = jar.archivePath
  140. onlyModified = true
  141. onlyBinaryIncompatibleModified = true
  142. failOnModification = false
  143. txtOutputFile = file("$buildDir/reports/japi.txt")
  144. htmlOutputFile = file("$buildDir/reports/japi.html")
  145. }
  146. }
  147. project('ooxml') {
  148. sourceSets.main.java.srcDirs = ['../../src/ooxml/java']
  149. sourceSets.main.resources.srcDirs = ['../../src/ooxml/resources', '../../src/resources/ooxml']
  150. sourceSets.test.java.srcDirs = ['../../src/ooxml/testcases']
  151. // for now import the ant-task for building the jars from build.xml
  152. // we need to rename the tasks as e.g. task "jar" conflicts with :ooxml:jar
  153. ant.importBuild('../../build.xml') { antTargetName ->
  154. 'ant-' + antTargetName
  155. }
  156. compileJava.dependsOn 'ant-compile-ooxml-xsds'
  157. dependencies {
  158. compile 'org.apache.xmlbeans:xmlbeans:2.6.0'
  159. compile 'org.apache.commons:commons-collections4:4.1'
  160. compile 'org.apache.commons:commons-math3:3.6.1'
  161. compile 'org.apache.santuario:xmlsec:2.1.0'
  162. compile 'org.bouncycastle:bcpkix-jdk15on:1.58'
  163. compile 'com.github.virtuald:curvesapi:1.05'
  164. // for ooxml-lite, should we move this somewhere else?
  165. compile 'junit:junit:4.12'
  166. compile project(':main')
  167. compile project(':scratchpad') // TODO: get rid of this dependency!
  168. compile files('../../ooxml-lib/ooxml-schemas-1.4.jar')
  169. compile files('../../ooxml-lib/ooxml-security-1.1.jar')
  170. testCompile 'junit:junit:4.12'
  171. testCompile project(path: ':main', configuration: 'tests')
  172. testCompile 'org.openjdk.jmh:jmh-core:1.19'
  173. testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.19'
  174. }
  175. // TOOD: we should not duplicate this task in each project, but I did not figure out how to inject the artifactId for each project
  176. task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  177. baseline = 'org.apache.poi:poi-ooxml:' + japicmpversion + '@jar'
  178. to = jar.archivePath
  179. onlyModified = true
  180. onlyBinaryIncompatibleModified = true
  181. failOnModification = false
  182. txtOutputFile = file("$buildDir/reports/japi.txt")
  183. htmlOutputFile = file("$buildDir/reports/japi.html")
  184. }
  185. }
  186. project('examples') {
  187. sourceSets.main.java.srcDirs = ['../../src/examples/src']
  188. dependencies {
  189. compile project(':main')
  190. compile project(':ooxml')
  191. }
  192. }
  193. project('excelant') {
  194. sourceSets.main.java.srcDirs = ['../../src/excelant/java']
  195. sourceSets.main.resources.srcDirs = ['../../src/excelant/resources']
  196. sourceSets.test.java.srcDirs = ['../../src/excelant/testcases']
  197. dependencies {
  198. compile 'org.apache.ant:ant:1.10.1'
  199. compile project(':main')
  200. compile project(':ooxml')
  201. testCompile project(path: ':main', configuration: 'tests')
  202. }
  203. // TOOD: we should not duplicate this task in each project, but I did not figure out how to inject the artifactId for each project
  204. task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  205. baseline = 'org.apache.poi:poi-excelant:' + japicmpversion + '@jar'
  206. to = jar.archivePath
  207. onlyModified = true
  208. onlyBinaryIncompatibleModified = true
  209. failOnModification = false
  210. txtOutputFile = file("$buildDir/reports/japi.txt")
  211. htmlOutputFile = file("$buildDir/reports/japi.html")
  212. }
  213. }
  214. project('integrationtest') {
  215. sourceSets.test.java.srcDirs = ['../../src/integrationtest']
  216. dependencies {
  217. compile 'org.apache.ant:ant:1.10.1'
  218. compile project(':main')
  219. compile project(':ooxml')
  220. compile project(':scratchpad')
  221. compile project(':examples')
  222. testCompile 'junit:junit:4.12'
  223. }
  224. test {
  225. // exclude these from the normal test-run
  226. exclude '**/TestAllFiles.class'
  227. exclude '**/*FileHandler.class'
  228. exclude '**/RecordsStresser.class'
  229. }
  230. task integrationTest(type: Test) {
  231. // these are just tests used during development of more test-code
  232. exclude '**/*FileHandler.class'
  233. exclude '**/RecordStresser.class'
  234. }
  235. }
  236. project('scratchpad') {
  237. sourceSets.main.java.srcDirs = ['../../src/scratchpad/src']
  238. sourceSets.main.resources.srcDirs = ['../../src/resources/scratchpad']
  239. sourceSets.test.java.srcDirs = ['../../src/scratchpad/testcases']
  240. dependencies {
  241. compile project(':main')
  242. // cyclic-dependency here: compile project(':ooxml')
  243. testCompile 'junit:junit:4.12'
  244. testCompile project(path: ':main', configuration: 'tests')
  245. }
  246. // TOOD: we should not duplicate this task in each project, but I did not figure out how to inject the artifactId for each project
  247. task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  248. baseline = 'org.apache.poi:poi-scratchpad:' + japicmpversion + '@jar'
  249. to = jar.archivePath
  250. onlyModified = true
  251. onlyBinaryIncompatibleModified = true
  252. failOnModification = false
  253. txtOutputFile = file("$buildDir/reports/japi.txt")
  254. htmlOutputFile = file("$buildDir/reports/japi.html")
  255. }
  256. }