Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

build.gradle 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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:3.0"
  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.13.1")
  40. antLibs("org.apache.ant:ant-junit:1.10.9")
  41. antLibs("org.apache.ant:ant-junit4:1.10.9")
  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.5'
  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. // helper method to download a jar file manually from an URL, e.g. XMLBeans 4.0.0
  60. def urlFile = { url, name ->
  61. File file = new File("$buildDir/download/${name}.jar")
  62. file.parentFile.mkdirs()
  63. if (!file.exists()) {
  64. new URL(url).withInputStream { downloadStream ->
  65. file.withOutputStream { fileOut ->
  66. fileOut << downloadStream
  67. }
  68. }
  69. }
  70. files(file.absolutePath)
  71. }
  72. /**
  73. Define properties for all projects, including this one
  74. */
  75. allprojects {
  76. apply plugin: 'eclipse'
  77. }
  78. /**
  79. Define things that are only necessary in sub-projects, but not in the master-project itself
  80. */
  81. subprojects {
  82. //Put instructions for each sub project, but not the master
  83. apply plugin: 'java'
  84. apply plugin: 'jacoco'
  85. // See https://github.com/melix/japicmp-gradle-plugin
  86. apply plugin: 'me.champeau.gradle.japicmp'
  87. version = '5.0.0-SNAPSHOT'
  88. ext {
  89. bouncyCastleVersion = '1.67'
  90. commonsCodecVersion = '1.15'
  91. commonsCompressVersion = '1.20'
  92. commonsMathVersion = '3.6.1'
  93. japicmpversion = '4.1.2'
  94. junitVersion = '4.13.1'
  95. mockitoVersion = '3.6.0'
  96. xmlbeansVersion = '4.0.0'
  97. }
  98. tasks.withType(JavaCompile) {
  99. options.encoding = 'UTF-8'
  100. }
  101. sourceCompatibility = 1.8
  102. repositories {
  103. mavenCentral()
  104. maven {
  105. url 'https://repository.apache.org/content/repositories/releases'
  106. }
  107. }
  108. jar {
  109. manifest {
  110. attributes 'Implementation-Title': 'Apache POI', 'Implementation-Version': version
  111. }
  112. }
  113. test {
  114. // Exclude some tests that are not actually tests or do not run cleanly on purpose
  115. exclude '**/BaseTestBorderStyle.class'
  116. exclude '**/BaseTestCellUtil.class'
  117. exclude '**/TestUnfixedBugs.class'
  118. exclude '**/TestOneFile.class'
  119. // Exclude Test Suites
  120. exclude '**/All*Tests.class'
  121. exclude '**/HSSFTests.class'
  122. // set heap size for the test JVM(s)
  123. minHeapSize = "128m"
  124. maxHeapSize = "768m"
  125. // Specifying the local via system properties did not work, so we set them this way
  126. jvmArgs '-Duser.language=en -Duser.country=US'
  127. // show standard out and standard error of the test JVM(s) on the console
  128. //testLogging.showStandardStreams = true
  129. // http://forums.gradle.org/gradle/topics/jacoco_related_failure_in_multiproject_build
  130. systemProperties['user.dir'] = workingDir
  131. systemProperties['POI.testdata.path'] = '../../test-data'
  132. // this is necessary for JDK 9+ to keep formatting dates the same way as in previous JDK-versions
  133. systemProperties['java.locale.providers'] = 'JRE,CLDR'
  134. }
  135. jacoco {
  136. toolVersion = '0.8.6'
  137. }
  138. jacocoTestReport {
  139. reports {
  140. xml.enabled true
  141. }
  142. }
  143. // ensure the build-dir exists
  144. projectDir.mkdirs()
  145. if (project.hasProperty('enableSonar')) {
  146. // See https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/ and
  147. // https://docs.sonarqube.org/display/SONARQUBE52/Analyzing+with+SonarQube+Scanner+for+Gradle
  148. // for documentation of properties.
  149. //
  150. // Some additional properties are currently set in the Jenkins-DSL, see jenksin/create_jobs.groovy
  151. //
  152. sonarqube {
  153. properties {
  154. // as we currently use build/<module>/ as project-basedir, we need to tell Sonar to use
  155. // the root-folder as "basedir" for the projects
  156. property "sonar.projectBaseDir", "$projectDir/../.."
  157. // currently supported providers on Jenkins: "hg,git": property "sonar.scm.provider", "svn"
  158. // the plugin seems to not detect our non-standard build-layout
  159. property "sonar.junit.reportPaths", "$projectDir/build/test-results/test"
  160. property "sonar.coverage.jacoco.xmlReportPaths", "$projectDir/build/reports/jacoco/test/jacocoTestReport.xml"
  161. }
  162. }
  163. }
  164. task(japicmp, type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  165. to = jar.archivePath
  166. onlyModified = true
  167. onlyBinaryIncompatibleModified = true
  168. failOnModification = false
  169. txtOutputFile = file("$buildDir/reports/japi.txt")
  170. htmlOutputFile = file("$buildDir/reports/japi.html")
  171. }
  172. }
  173. project('main') {
  174. sourceSets.main.java.srcDirs = ['../../src/java']
  175. sourceSets.main.resources.srcDirs = ['../../src/resources/main']
  176. sourceSets.test.java.srcDirs = ['../../src/testcases']
  177. dependencies {
  178. compile "commons-codec:commons-codec:${commonsCodecVersion}"
  179. compile 'commons-logging:commons-logging:1.2'
  180. compile 'org.apache.commons:commons-collections4:4.4'
  181. compile "org.apache.commons:commons-math3:${commonsMathVersion}"
  182. compile 'javax.activation:activation:1.1.1'
  183. compile 'com.zaxxer:SparseBitSet:1.2'
  184. testCompile "junit:junit:${junitVersion}"
  185. testCompile "org.mockito:mockito-core:${mockitoVersion}"
  186. testCompile 'org.reflections:reflections:0.9.12'
  187. }
  188. jar {
  189. manifest {
  190. attributes 'Automatic-Module-Name': 'org.apache.poi.main'
  191. }
  192. }
  193. // Create a separate jar for test-code to depend on it in other projects
  194. // See http://stackoverflow.com/questions/5144325/gradle-test-dependency
  195. task testJar(type: Jar, dependsOn: testClasses) {
  196. baseName = "test-${project.archivesBaseName}"
  197. from sourceSets.test.output
  198. }
  199. configurations {
  200. tests
  201. }
  202. artifacts {
  203. tests testJar
  204. }
  205. japicmp.baseline = "org.apache.poi:poi:${japicmpversion}@jar"
  206. }
  207. project('ooxml') {
  208. sourceSets.main.java.srcDirs = ['../../src/ooxml/java']
  209. sourceSets.main.resources.srcDirs = ['../../src/ooxml/resources', '../../src/resources/ooxml']
  210. sourceSets.test.java.srcDirs = ['../../src/ooxml/testcases']
  211. configurations {
  212. antdep
  213. }
  214. dependencies {
  215. antdep 'org.apache.ant:ant:1.10.9'
  216. }
  217. // we need to ensure that the custom ant tasks are compiled before we import the build.xml file
  218. ant.mkdir(dir: "../../build/poi-ant-contrib")
  219. ant.javac(srcdir: "../../src/excelant/poi-ant-contrib", destdir: "../../build/poi-ant-contrib",
  220. classpath: configurations.antdep.asPath)
  221. // for now import the ant-task for building the jars from build.xml
  222. // we need to rename the tasks as e.g. task "jar" conflicts with :ooxml:jar
  223. ant.importBuild('../../build.xml') { antTargetName ->
  224. 'ant-' + antTargetName
  225. }
  226. compileJava.dependsOn 'ant-compile-ooxml-xsds'
  227. dependencies {
  228. compile "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}"
  229. compile 'org.apache.commons:commons-collections4:4.4'
  230. compile "org.apache.commons:commons-math3:${commonsMathVersion}"
  231. compile "org.apache.commons:commons-compress:${commonsCompressVersion}"
  232. compile 'org.apache.santuario:xmlsec:2.2.0'
  233. compile "org.bouncycastle:bcpkix-jdk15on:${bouncyCastleVersion}"
  234. compile 'com.github.virtuald:curvesapi:1.06'
  235. compile 'com.zaxxer:SparseBitSet:1.2'
  236. // compile only, don't add it to our dist as it blows up the size
  237. compile 'org.apache.xmlgraphics:batik-all:1.13'
  238. compile 'xml-apis:xml-apis-ext:1.3.04'
  239. compile 'org.apache.xmlgraphics:xmlgraphics-commons:2.4'
  240. compile 'org.apache.pdfbox:pdfbox:2.0.21'
  241. compile 'org.apache.pdfbox:fontbox:2.0.21'
  242. compile 'de.rototor.pdfbox:graphics2d:0.29'
  243. // for ooxml-lite, should we move this somewhere else?
  244. compile "junit:junit:${junitVersion}"
  245. compile project(':main')
  246. compile project(':scratchpad') // TODO: get rid of this dependency!
  247. compile files('../../build/dist/maven/poi-ooxml-full/poi-ooxml-full-${version}.jar')
  248. testCompile "junit:junit:${junitVersion}"
  249. testCompile "org.mockito:mockito-core:${mockitoVersion}"
  250. testCompile 'org.xmlunit:xmlunit-core:2.8.0'
  251. testCompile 'org.reflections:reflections:0.9.12'
  252. testCompile project(path: ':main', configuration: 'tests')
  253. testCompile 'org.openjdk.jmh:jmh-core:1.26'
  254. testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.26'
  255. testCompile 'com.google.guava:guava:30.0-jre'
  256. }
  257. jar {
  258. manifest {
  259. attributes 'Automatic-Module-Name': 'org.apache.poi.ooxml'
  260. }
  261. }
  262. japicmp.baseline = "org.apache.poi:poi:${japicmpversion}@jar"
  263. test {
  264. // for some reason catching the OOM does not work when run from Gradle
  265. exclude '**/MemoryUsage.class'
  266. }
  267. }
  268. project('examples') {
  269. sourceSets.main.java.srcDirs = ['../../src/examples/src']
  270. dependencies {
  271. compile project(':main')
  272. compile project(':ooxml')
  273. compile project(':scratchpad')
  274. compile "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}"
  275. compile files('../../build/dist/maven/poi-ooxml-full/poi-ooxml-full-${version}.jar')
  276. compile "org.apache.commons:commons-compress:${commonsCompressVersion}"
  277. }
  278. japicmp.enabled = false
  279. }
  280. project('excelant') {
  281. sourceSets.main.java.srcDirs = ['../../src/excelant/java']
  282. sourceSets.main.resources.srcDirs = ['../../src/excelant/resources']
  283. sourceSets.test.java.srcDirs = ['../../src/excelant/testcases']
  284. dependencies {
  285. compile 'org.apache.ant:ant:1.10.9'
  286. compile project(':main')
  287. compile project(':ooxml')
  288. testCompile project(path: ':main', configuration: 'tests')
  289. testCompile "junit:junit:${junitVersion}"
  290. }
  291. jar {
  292. manifest {
  293. attributes 'Automatic-Module-Name': 'org.apache.poi.excelant'
  294. }
  295. }
  296. japicmp.baseline = "org.apache.poi:poi-excelant:${japicmpversion}@jar"
  297. }
  298. project('integrationtest') {
  299. sourceSets.test.java.srcDirs = ['../../src/integrationtest']
  300. dependencies {
  301. compile 'org.apache.ant:ant:1.10.9'
  302. compile project(':main')
  303. compile project(':ooxml')
  304. compile project(':scratchpad')
  305. compile project(':examples')
  306. testCompile "junit:junit:${junitVersion}"
  307. testCompile "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}"
  308. testCompile files('../../build/dist/maven/poi-ooxml-full/poi-ooxml-full-${version}.jar')
  309. testCompile files(this.project(':ooxml').sourceSets.test.runtimeClasspath)
  310. }
  311. jar {
  312. manifest {
  313. attributes 'Automatic-Module-Name': 'org.apache.poi.integrationtest'
  314. }
  315. }
  316. test {
  317. // exclude these from the normal test-run
  318. exclude '**/TestAllFiles.class'
  319. exclude '**/*FileHandler.class'
  320. exclude '**/RecordsStresser.class'
  321. }
  322. task integrationTest(type: Test) {
  323. // these are just tests used during development of more test-code
  324. exclude '**/*FileHandler.class'
  325. exclude '**/RecordStresser.class'
  326. }
  327. japicmp.enabled = false
  328. }
  329. project('scratchpad') {
  330. sourceSets.main.java.srcDirs = ['../../src/scratchpad/src']
  331. sourceSets.main.resources.srcDirs = ['../../src/resources/scratchpad']
  332. sourceSets.test.java.srcDirs = ['../../src/scratchpad/testcases']
  333. dependencies {
  334. compile project(':main')
  335. compile "commons-codec:commons-codec:${commonsCodecVersion}"
  336. compile "org.apache.commons:commons-math3:${commonsMathVersion}"
  337. // cyclic-dependency here: compile project(':ooxml')
  338. testCompile "junit:junit:${junitVersion}"
  339. testCompile "org.mockito:mockito-core:${mockitoVersion}"
  340. testCompile project(path: ':main', configuration: 'tests')
  341. }
  342. jar {
  343. manifest {
  344. attributes 'Automatic-Module-Name': 'org.apache.poi.scratchpad'
  345. }
  346. }
  347. japicmp.baseline = "org.apache.poi:poi:${japicmpversion}@jar"
  348. }