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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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'
  21. classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2.1"
  22. }
  23. }
  24. // Only add the plugin for Sonar if enabled as it requires Java 8
  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 = '3.16-beta3'
  61. ext {
  62. japicmpversion = '3.15'
  63. }
  64. tasks.withType(JavaCompile) {
  65. options.encoding = 'UTF-8'
  66. }
  67. sourceCompatibility = 1.6
  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.8'
  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.10'
  119. compile 'commons-logging:commons-logging:1.2'
  120. compile 'org.apache.commons:commons-collections4:4.1'
  121. testCompile 'junit:junit:4.12'
  122. }
  123. // Create a separate jar for test-code to depend on it in other projects
  124. // See http://stackoverflow.com/questions/5144325/gradle-test-dependency
  125. task testJar(type: Jar, dependsOn: testClasses) {
  126. baseName = "test-${project.archivesBaseName}"
  127. from sourceSets.test.output
  128. }
  129. configurations {
  130. tests
  131. }
  132. artifacts {
  133. tests testJar
  134. }
  135. // TOOD: we should not duplicate this task in each project, but I did not figure out how to inject the artifactId for each project
  136. task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  137. baseline = 'org.apache.poi:poi:' + japicmpversion + '@jar'
  138. to = jar.archivePath
  139. onlyModified = true
  140. onlyBinaryIncompatibleModified = true
  141. failOnModification = false
  142. txtOutputFile = file("$buildDir/reports/japi.txt")
  143. htmlOutputFile = file("$buildDir/reports/japi.html")
  144. }
  145. }
  146. project('ooxml') {
  147. sourceSets.main.java.srcDirs = ['../../src/ooxml/java']
  148. sourceSets.main.resources.srcDirs = ['../../src/ooxml/resources', '../../src/resources/ooxml']
  149. sourceSets.test.java.srcDirs = ['../../src/ooxml/testcases']
  150. // for now import the ant-task for building the jars from build.xml
  151. // we need to rename the tasks as e.g. task "jar" conflicts with :ooxml:jar
  152. ant.importBuild('../../build.xml') { antTargetName ->
  153. 'ant-' + antTargetName
  154. }
  155. compileJava.dependsOn 'ant-compile-ooxml-xsds'
  156. dependencies {
  157. compile 'org.apache.xmlbeans:xmlbeans:2.6.0'
  158. compile 'org.apache.commons:commons-collections4:4.1'
  159. compile 'org.apache.santuario:xmlsec:2.0.6'
  160. compile 'org.bouncycastle:bcpkix-jdk15on:1.54'
  161. compile 'com.github.virtuald:curvesapi:1.04'
  162. // for ooxml-lite, should we move this somewhere else?
  163. compile 'junit:junit:4.12'
  164. compile project(':main')
  165. compile project(':scratchpad') // TODO: get rid of this dependency!
  166. compile files('../../ooxml-lib/ooxml-schemas-1.3.jar')
  167. compile files('../../ooxml-lib/ooxml-security-1.1.jar')
  168. testCompile 'junit:junit:4.12'
  169. testCompile project(path: ':main', configuration: 'tests')
  170. }
  171. // TOOD: we should not duplicate this task in each project, but I did not figure out how to inject the artifactId for each project
  172. task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  173. baseline = 'org.apache.poi:poi-ooxml:' + japicmpversion + '@jar'
  174. to = jar.archivePath
  175. onlyModified = true
  176. onlyBinaryIncompatibleModified = true
  177. failOnModification = false
  178. txtOutputFile = file("$buildDir/reports/japi.txt")
  179. htmlOutputFile = file("$buildDir/reports/japi.html")
  180. }
  181. }
  182. project('examples') {
  183. sourceSets.main.java.srcDirs = ['../../src/examples/src']
  184. dependencies {
  185. compile project(':main')
  186. compile project(':ooxml')
  187. }
  188. }
  189. project('excelant') {
  190. sourceSets.main.java.srcDirs = ['../../src/excelant/java']
  191. sourceSets.main.resources.srcDirs = ['../../src/excelant/resources']
  192. sourceSets.test.java.srcDirs = ['../../src/excelant/testcases']
  193. dependencies {
  194. compile 'org.apache.ant:ant:1.9.4'
  195. compile project(':main')
  196. compile project(':ooxml')
  197. testCompile project(path: ':main', configuration: 'tests')
  198. }
  199. // TOOD: we should not duplicate this task in each project, but I did not figure out how to inject the artifactId for each project
  200. task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  201. baseline = 'org.apache.poi:poi-excelant:' + japicmpversion + '@jar'
  202. to = jar.archivePath
  203. onlyModified = true
  204. onlyBinaryIncompatibleModified = true
  205. failOnModification = false
  206. txtOutputFile = file("$buildDir/reports/japi.txt")
  207. htmlOutputFile = file("$buildDir/reports/japi.html")
  208. }
  209. }
  210. project('integrationtest') {
  211. sourceSets.test.java.srcDirs = ['../../src/integrationtest']
  212. dependencies {
  213. compile 'org.apache.ant:ant:1.9.4'
  214. compile project(':main')
  215. compile project(':ooxml')
  216. compile project(':scratchpad')
  217. compile project(':examples')
  218. testCompile 'junit:junit:4.12'
  219. }
  220. test {
  221. // exclude these from the normal test-run
  222. exclude '**/TestAllFiles.class'
  223. exclude '**/*FileHandler.class'
  224. exclude '**/RecordsStresser.class'
  225. }
  226. task integrationTest(type: Test) {
  227. // these are just tests used during development of more test-code
  228. exclude '**/*FileHandler.class'
  229. exclude '**/RecordStresser.class'
  230. }
  231. }
  232. project('scratchpad') {
  233. sourceSets.main.java.srcDirs = ['../../src/scratchpad/src']
  234. sourceSets.main.resources.srcDirs = ['../../src/resources/scratchpad']
  235. sourceSets.test.java.srcDirs = ['../../src/scratchpad/testcases']
  236. dependencies {
  237. compile project(':main')
  238. // cyclic-dependency here: compile project(':ooxml')
  239. testCompile 'junit:junit:4.12'
  240. testCompile project(path: ':main', configuration: 'tests')
  241. }
  242. // TOOD: we should not duplicate this task in each project, but I did not figure out how to inject the artifactId for each project
  243. task japicmp(type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  244. baseline = 'org.apache.poi:poi-scratchpad:' + japicmpversion + '@jar'
  245. to = jar.archivePath
  246. onlyModified = true
  247. onlyBinaryIncompatibleModified = true
  248. failOnModification = false
  249. txtOutputFile = file("$buildDir/reports/japi.txt")
  250. htmlOutputFile = file("$buildDir/reports/japi.html")
  251. }
  252. }