Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

build.gradle 15KB

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