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

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