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

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