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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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. // 2.x fails with "Could not get unknown property 'me'"
  21. classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.1.2'
  22. classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.8"
  23. }
  24. }
  25. repositories {
  26. mavenCentral()
  27. }
  28. // Only add the plugin for Sonar if enabled
  29. if (project.hasProperty('enableSonar')) {
  30. println 'Enabling Sonar support'
  31. apply plugin: "org.sonarqube"
  32. }
  33. // For help converting an Ant build to a Gradle build, see
  34. // https://docs.gradle.org/current/userguide/ant.html
  35. configurations {
  36. antLibs
  37. }
  38. dependencies {
  39. antLibs("junit:junit:4.12")
  40. antLibs("org.apache.ant:ant-junit:1.10.4")
  41. antLibs("org.apache.ant:ant-junit4:1.10.4")
  42. }
  43. ant.taskdef(name: "junit",
  44. classname: "org.apache.tools.ant.taskdefs.optional.junit.JUnitTask",
  45. classpath: configurations.antLibs.asPath)
  46. wrapper {
  47. gradleVersion = '6.0.1'
  48. }
  49. task adjustWrapperPropertiesFile {
  50. doLast {
  51. ant.replaceregexp(match:'^#.*', replace:'', flags:'g', byline:true) {
  52. fileset(dir: project.projectDir, includes: 'gradle/wrapper/gradle-wrapper.properties')
  53. }
  54. new File(project.projectDir, 'gradle/wrapper/gradle-wrapper.properties').with { it.text = it.readLines().findAll { it }.sort().join('\n') }
  55. ant.fixcrlf(file: 'gradle/wrapper/gradle-wrapper.properties', eol: 'lf')
  56. }
  57. }
  58. wrapper.finalizedBy adjustWrapperPropertiesFile
  59. /**
  60. Define properties for all projects, including this one
  61. */
  62. allprojects {
  63. apply plugin: 'eclipse'
  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.1.3-SNAPSHOT'
  75. ext {
  76. japicmpversion = '4.1.2'
  77. }
  78. tasks.withType(JavaCompile) {
  79. options.encoding = 'UTF-8'
  80. }
  81. sourceCompatibility = 1.8
  82. repositories {
  83. mavenCentral()
  84. maven {
  85. url 'https://repository.apache.org/content/repositories/releases'
  86. }
  87. }
  88. jar {
  89. manifest {
  90. attributes 'Implementation-Title': 'Apache POI', 'Implementation-Version': version
  91. }
  92. }
  93. test {
  94. // Exclude some tests that are not actually tests or do not run cleanly on purpose
  95. exclude '**/BaseTestBorderStyle.class'
  96. exclude '**/BaseTestCellUtil.class'
  97. exclude '**/TestUnfixedBugs.class'
  98. exclude '**/TestOneFile.class'
  99. // Exclude Test Suites
  100. exclude '**/All*Tests.class'
  101. exclude '**/HSSFTests.class'
  102. // set heap size for the test JVM(s)
  103. minHeapSize = "128m"
  104. maxHeapSize = "768m"
  105. // Specifying the local via system properties did not work, so we set them this way
  106. jvmArgs '-Duser.language=en -Duser.country=US'
  107. // show standard out and standard error of the test JVM(s) on the console
  108. //testLogging.showStandardStreams = true
  109. // http://forums.gradle.org/gradle/topics/jacoco_related_failure_in_multiproject_build
  110. systemProperties['user.dir'] = workingDir
  111. systemProperties['POI.testdata.path'] = '../../test-data'
  112. // this is necessary for JDK 9+ to keep formatting dates the same way as in previous JDK-versions
  113. systemProperties['java.locale.providers'] = 'JRE,CLDR'
  114. }
  115. jacoco {
  116. toolVersion = '0.8.5'
  117. }
  118. // ensure the build-dir exists
  119. projectDir.mkdirs()
  120. if (project.hasProperty('enableSonar')) {
  121. sonarqube {
  122. properties {
  123. // as we currently use build/<module>/ as project-basedir, we need to tell Sonar to use
  124. // the root-folder as "basedir" for the projects
  125. property "sonar.projectBaseDir", "$projectDir/../.."
  126. }
  127. }
  128. }
  129. task(japicmp, type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  130. to = jar.archivePath
  131. onlyModified = true
  132. onlyBinaryIncompatibleModified = true
  133. failOnModification = false
  134. txtOutputFile = file("$buildDir/reports/japi.txt")
  135. htmlOutputFile = file("$buildDir/reports/japi.html")
  136. }
  137. }
  138. project('main') {
  139. sourceSets.main.java.srcDirs = ['../../src/java']
  140. sourceSets.main.resources.srcDirs = ['../../src/resources/main']
  141. sourceSets.test.java.srcDirs = ['../../src/testcases']
  142. dependencies {
  143. compile 'commons-codec:commons-codec:1.13'
  144. compile 'commons-logging:commons-logging:1.2'
  145. compile 'org.apache.commons:commons-collections4:4.4'
  146. compile 'org.apache.commons:commons-math3:3.6.1'
  147. compile 'javax.xml.bind:jaxb-api:2.3.1'
  148. compile 'com.sun.xml.bind:jaxb-impl:2.3.2'
  149. compile 'com.sun.xml.bind:jaxb-core:2.3.0.1'
  150. compile 'javax.activation:activation:1.1.1'
  151. compile 'com.zaxxer:SparseBitSet:1.2'
  152. testCompile 'junit:junit:4.12'
  153. testCompile 'org.mockito:mockito-core:3.0.0'
  154. testCompile 'org.reflections:reflections:0.9.11'
  155. }
  156. jar {
  157. manifest {
  158. attributes 'Automatic-Module-Name': 'org.apache.poi.main'
  159. }
  160. }
  161. // Create a separate jar for test-code to depend on it in other projects
  162. // See http://stackoverflow.com/questions/5144325/gradle-test-dependency
  163. task testJar(type: Jar, dependsOn: testClasses) {
  164. baseName = "test-${project.archivesBaseName}"
  165. from sourceSets.test.output
  166. }
  167. configurations {
  168. tests
  169. }
  170. artifacts {
  171. tests testJar
  172. }
  173. japicmp.baseline = 'org.apache.poi:poi:' + japicmpversion + '@jar'
  174. }
  175. project('ooxml') {
  176. sourceSets.main.java.srcDirs = ['../../src/ooxml/java']
  177. sourceSets.main.resources.srcDirs = ['../../src/ooxml/resources', '../../src/resources/ooxml']
  178. sourceSets.test.java.srcDirs = ['../../src/ooxml/testcases']
  179. // for now import the ant-task for building the jars from build.xml
  180. // we need to rename the tasks as e.g. task "jar" conflicts with :ooxml:jar
  181. ant.importBuild('../../build.xml') { antTargetName ->
  182. 'ant-' + antTargetName
  183. }
  184. compileJava.dependsOn 'ant-compile-ooxml-xsds'
  185. dependencies {
  186. compile 'org.apache.xmlbeans:xmlbeans:3.1.0'
  187. compile 'org.apache.commons:commons-collections4:4.4'
  188. compile 'org.apache.commons:commons-math3:3.6.1'
  189. compile 'org.apache.commons:commons-compress:1.19'
  190. compile 'org.apache.santuario:xmlsec:2.1.2'
  191. compile 'org.bouncycastle:bcpkix-jdk15on:1.62'
  192. compile 'com.github.virtuald:curvesapi:1.06'
  193. compile 'com.zaxxer:SparseBitSet:1.2'
  194. // compile only, don't add it to our dist as it blows up the size
  195. compile 'org.apache.xmlgraphics:batik-all:1.11'
  196. compile 'xml-apis:xml-apis-ext:1.3.04'
  197. compile 'org.apache.xmlgraphics:xmlgraphics-commons:2.3'
  198. // for ooxml-lite, should we move this somewhere else?
  199. compile 'junit:junit:4.12'
  200. compile project(':main')
  201. compile project(':scratchpad') // TODO: get rid of this dependency!
  202. compile files('../../ooxml-lib/ooxml-schemas-1.4.jar')
  203. compile files('../../ooxml-lib/ooxml-security-1.1.jar')
  204. testCompile 'junit:junit:4.12'
  205. testCompile 'org.mockito:mockito-core:3.0.0'
  206. testCompile 'org.xmlunit:xmlunit-core:2.5.1'
  207. testCompile 'org.reflections:reflections:0.9.11'
  208. testCompile project(path: ':main', configuration: 'tests')
  209. testCompile 'org.openjdk.jmh:jmh-core:1.19'
  210. testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.19'
  211. }
  212. jar {
  213. manifest {
  214. attributes 'Automatic-Module-Name': 'org.apache.poi.ooxml'
  215. }
  216. }
  217. japicmp.baseline = 'org.apache.poi:poi-ooxml:' + japicmpversion + '@jar'
  218. }
  219. project('examples') {
  220. sourceSets.main.java.srcDirs = ['../../src/examples/src']
  221. dependencies {
  222. compile project(':main')
  223. compile project(':ooxml')
  224. }
  225. japicmp.enabled = false
  226. }
  227. project('excelant') {
  228. sourceSets.main.java.srcDirs = ['../../src/excelant/java']
  229. sourceSets.main.resources.srcDirs = ['../../src/excelant/resources']
  230. sourceSets.test.java.srcDirs = ['../../src/excelant/testcases']
  231. dependencies {
  232. compile 'org.apache.ant:ant:1.10.4'
  233. compile project(':main')
  234. compile project(':ooxml')
  235. testCompile project(path: ':main', configuration: 'tests')
  236. }
  237. jar {
  238. manifest {
  239. attributes 'Automatic-Module-Name': 'org.apache.poi.excelant'
  240. }
  241. }
  242. japicmp.baseline = 'org.apache.poi:poi-excelant:' + japicmpversion + '@jar'
  243. }
  244. project('integrationtest') {
  245. sourceSets.test.java.srcDirs = ['../../src/integrationtest']
  246. dependencies {
  247. compile 'org.apache.ant:ant:1.10.4'
  248. compile project(':main')
  249. compile project(':ooxml')
  250. compile project(':scratchpad')
  251. compile project(':examples')
  252. testCompile 'junit:junit:4.12'
  253. }
  254. jar {
  255. manifest {
  256. attributes 'Automatic-Module-Name': 'org.apache.poi.integrationtest'
  257. }
  258. }
  259. test {
  260. // exclude these from the normal test-run
  261. exclude '**/TestAllFiles.class'
  262. exclude '**/*FileHandler.class'
  263. exclude '**/RecordsStresser.class'
  264. }
  265. task integrationTest(type: Test) {
  266. // these are just tests used during development of more test-code
  267. exclude '**/*FileHandler.class'
  268. exclude '**/RecordStresser.class'
  269. }
  270. japicmp.enabled = false
  271. }
  272. project('scratchpad') {
  273. sourceSets.main.java.srcDirs = ['../../src/scratchpad/src']
  274. sourceSets.main.resources.srcDirs = ['../../src/resources/scratchpad']
  275. sourceSets.test.java.srcDirs = ['../../src/scratchpad/testcases']
  276. dependencies {
  277. compile project(':main')
  278. // cyclic-dependency here: compile project(':ooxml')
  279. testCompile 'junit:junit:4.12'
  280. testCompile project(path: ':main', configuration: 'tests')
  281. }
  282. jar {
  283. manifest {
  284. attributes 'Automatic-Module-Name': 'org.apache.poi.scratchpad'
  285. }
  286. }
  287. japicmp.baseline = 'org.apache.poi:poi-scratchpad:' + japicmpversion + '@jar'
  288. }