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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  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. import org.w3c.dom.Node
  16. import org.w3c.dom.NodeList
  17. import javax.xml.xpath.XPath
  18. import javax.xml.xpath.XPathConstants
  19. import javax.xml.xpath.XPathFactory
  20. buildscript {
  21. repositories {
  22. maven { url 'https://plugins.gradle.org/m2/' }
  23. mavenCentral()
  24. }
  25. dependencies {
  26. classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3'
  27. classpath 'de.thetaphi:forbiddenapis:3.2'
  28. }
  29. }
  30. plugins {
  31. id 'base'
  32. id "com.dorongold.task-tree" version "2.1.0"
  33. id('org.nosphere.apache.rat') version '0.7.0'
  34. id 'distribution'
  35. id "com.github.spotbugs" version "4.8.0"
  36. }
  37. repositories {
  38. mavenCentral()
  39. }
  40. // Only add the plugin for Sonar if enabled
  41. if (project.hasProperty('enableSonar')) {
  42. println 'Enabling Sonar support'
  43. apply plugin: 'org.sonarqube'
  44. }
  45. boolean isCIBuild = false;
  46. // For help converting an Ant build to a Gradle build, see
  47. // https://docs.gradle.org/current/userguide/ant.html
  48. configurations {
  49. antLibs {
  50. attributes {
  51. attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
  52. }
  53. }
  54. }
  55. dependencies {
  56. antLibs("org.junit.jupiter:junit-jupiter:5.8.2")
  57. antLibs("org.apache.ant:ant-junitlauncher:1.10.12")
  58. }
  59. ant.taskdef(name: "junit",
  60. classname: "org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.JUnitLauncherTask",
  61. classpath: configurations.antLibs.asPath)
  62. wrapper {
  63. // https://stackoverflow.com/a/54741656/2066598
  64. gradleVersion = '7.3.3'
  65. }
  66. task adjustWrapperPropertiesFile {
  67. doLast {
  68. ant.replaceregexp(match:'^#.*', replace:'', flags:'g', byline:true) {
  69. fileset(dir: project.projectDir, includes: 'gradle/wrapper/gradle-wrapper.properties')
  70. }
  71. new File(project.projectDir, 'gradle/wrapper/gradle-wrapper.properties').with { it.text = it.readLines().findAll { it }.sort().join('\n') }
  72. ant.fixcrlf(file: 'gradle/wrapper/gradle-wrapper.properties', eol: 'lf')
  73. }
  74. }
  75. wrapper.finalizedBy adjustWrapperPropertiesFile
  76. /**
  77. Define properties for all projects, including this one
  78. */
  79. allprojects {
  80. // apply plugin: 'eclipse'
  81. apply plugin: 'idea'
  82. }
  83. /**
  84. Define things that are only necessary in sub-projects, but not in the master-project itself
  85. */
  86. subprojects {
  87. //Put instructions for each sub project, but not the master
  88. apply plugin: 'java-library'
  89. apply plugin: 'jacoco'
  90. apply plugin: 'maven-publish'
  91. apply plugin: 'signing'
  92. apply plugin: 'de.thetaphi.forbiddenapis'
  93. apply plugin: 'com.github.spotbugs'
  94. version = '5.2.0-SNAPSHOT'
  95. ext {
  96. bouncyCastleVersion = '1.70'
  97. commonsCodecVersion = '1.15'
  98. commonsCompressVersion = '1.21'
  99. commonsIoVersion = '2.11.0'
  100. commonsMathVersion = '3.6.1'
  101. junitVersion = '5.8.2'
  102. log4jVersion = '2.17.1'
  103. mockitoVersion = '4.2.0'
  104. hamcrestVersion = '2.2'
  105. xmlbeansVersion = '5.0.3'
  106. batikVersion = '1.14'
  107. graphics2dVersion = '0.34'
  108. pdfboxVersion = '2.0.25'
  109. saxonVersion = '10.6'
  110. apiGuardianVersion = '1.1.2'
  111. JAVA9_SRC = 'src/main/java9'
  112. JAVA9_OUT = "${buildDir}/classes/java9/main/"
  113. TEST9_SRC = 'src/test/java9'
  114. TEST9_OUT = "${buildDir}/classes/java9/test/"
  115. VERSIONS9 = 'META-INF/versions/9'
  116. NO_SCRATCHPAD = (findProperty("scratchpad.ignore") == "true")
  117. SAXON_TEST = (findProperty("saxon.test") == "true")
  118. }
  119. configurations {
  120. all {
  121. resolutionStrategy {
  122. force "commons-io:commons-io:${commonsIoVersion}"
  123. force 'org.slf4j:slf4j-api:1.7.32'
  124. force 'com.fasterxml.woodstox:woodstox-core:6.2.7'
  125. }
  126. }
  127. }
  128. tasks.withType(JavaCompile) {
  129. options.encoding = 'UTF-8'
  130. options.compilerArgs << '-Xlint:unchecked'
  131. options.deprecation = true
  132. options.incremental = true
  133. onlyIf {
  134. (name != "compileJava9" && name != "compileTest9") || JavaVersion.current() != JavaVersion.VERSION_1_8
  135. }
  136. }
  137. sourceCompatibility = JavaVersion.VERSION_1_8
  138. targetCompatibility = JavaVersion.VERSION_1_8
  139. repositories {
  140. mavenCentral()
  141. maven {
  142. url 'https://repository.apache.org/content/repositories/releases'
  143. }
  144. }
  145. dependencies {
  146. testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
  147. testImplementation "org.mockito:mockito-core:${mockitoVersion}"
  148. testImplementation "org.hamcrest:hamcrest:${hamcrestVersion}"
  149. testImplementation "org.apache.logging.log4j:log4j-core:${log4jVersion}"
  150. }
  151. task wrapper(type: Wrapper){
  152. // https://stackoverflow.com/a/65701523/2066598
  153. gradleVersion = '7.3.3'
  154. }
  155. java {
  156. withJavadocJar()
  157. withSourcesJar()
  158. }
  159. javadoc {
  160. failOnError = true
  161. maxMemory = "1024M"
  162. doFirst {
  163. options {
  164. if (JavaVersion.current().isJava9Compatible()) {
  165. addBooleanOption('html5', true)
  166. }
  167. addBooleanOption('Xdoclint:all,-missing', true)
  168. links 'https://poi.apache.org/apidocs/dev/'
  169. links 'https://docs.oracle.com/javase/8/docs/api/'
  170. links 'https://xmlbeans.apache.org/docs/5.0.0/'
  171. use = true
  172. splitIndex = true
  173. source = "1.8"
  174. }
  175. }
  176. }
  177. tasks.withType(Jar) {
  178. duplicatesStrategy = 'fail'
  179. destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
  180. doLast {
  181. ant.checksum(file: it.archivePath, algorithm: 'SHA-256', fileext: '.sha256', format: 'MD5SUM')
  182. ant.checksum(file: it.archivePath, algorithm: 'SHA-512', fileext: '.sha512', format: 'MD5SUM')
  183. }
  184. }
  185. jar {
  186. from("../legal") {
  187. include "NOTICE"
  188. include "LICENSE"
  189. }
  190. rename('^(NOTICE|LICENSE)', 'META-INF/$1')
  191. manifest {
  192. attributes(
  193. 'Specification-Title': 'Apache POI',
  194. 'Specification-Version': project.version,
  195. 'Specification-Vendor': 'The Apache Software Foundation',
  196. 'Implementation-Title': 'Apache POI',
  197. 'Implementation-Version': project.version,
  198. 'Implementation-Vendor': 'org.apache.poi',
  199. 'Implementation-Vendor-Id': 'The Apache Software Foundation'
  200. )
  201. }
  202. }
  203. javadocJar {
  204. // if javadocs and binaries are in the same directory, JPMS complaints about duplicated modules
  205. // in the module-path
  206. destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}-javadoc")
  207. }
  208. sourcesJar {
  209. destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
  210. exclude 'META-INF/services/**'
  211. }
  212. test {
  213. // make XML test-results available for Jenkins CI
  214. useJUnitPlatform()
  215. reports {
  216. junitXml.required = true
  217. }
  218. // Exclude some tests that are not actually tests or do not run cleanly on purpose
  219. exclude '**/BaseTestBorderStyle.class'
  220. exclude '**/BaseTestCellUtil.class'
  221. exclude '**/TestUnfixedBugs.class'
  222. exclude '**/TestOneFile.class'
  223. // Exclude Test Suites
  224. exclude '**/All*Tests.class'
  225. exclude '**/HSSFTests.class'
  226. // set heap size for the test JVM(s)
  227. minHeapSize = "128m"
  228. maxHeapSize = "1G"
  229. // Specifying the local via system properties did not work, so we set them this way
  230. jvmArgs << [
  231. '-Djava.io.tmpdir=build',
  232. '-DPOI.testdata.path=../test-data',
  233. '-Djava.awt.headless=true',
  234. '-Djava.locale.providers=JRE,CLDR',
  235. '-Duser.language=en',
  236. '-Duser.country=US',
  237. '-Djavax.xml.stream.XMLInputFactory=com.sun.xml.internal.stream.XMLInputFactoryImpl',
  238. "-Dversion.id=${project.version}",
  239. '-ea',
  240. // -Xjit:verbose={compileStart|compileEnd},vlog=build/jit.log${no.jit.sherlock} ... if ${isIBMVM}
  241. ]
  242. // detect if running on Jenkins/CI
  243. isCIBuild |= Boolean.valueOf(System.getenv("CI_BUILD"));
  244. if (isCIBuild) {
  245. System.out.println("Run with reduced parallelism for CI build");
  246. jvmArgs += [
  247. // Strictly serial
  248. // '-Djunit.jupiter.execution.parallel.enabled=false',
  249. // OR parallel on 2 threads
  250. '-Djunit.jupiter.execution.parallel.config.strategy=fixed',
  251. '-Djunit.jupiter.execution.parallel.config.fixed.parallelism=2'
  252. ]
  253. maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
  254. } else {
  255. jvmArgs += [
  256. '-Djunit.jupiter.execution.parallel.enabled=true',
  257. '-Djunit.jupiter.execution.parallel.config.strategy=dynamic',
  258. // this setting breaks the test builds, do not use it!
  259. //'-Djunit.jupiter.execution.parallel.mode.default=concurrent'
  260. ]
  261. // Explicitly defining the maxParallelForks was always slower than not setting it
  262. // So we leave this to Gradle itself, which seems to be very smart
  263. // maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
  264. // maxParallelForks = Math.max( Runtime.runtime.availableProcessors() - 1, 1 )
  265. }
  266. // show standard out and standard error of the test JVM(s) on the console
  267. //testLogging.showStandardStreams = true
  268. // http://forums.gradle.org/gradle/topics/jacoco_related_failure_in_multiproject_build
  269. systemProperties['user.dir'] = workingDir
  270. systemProperties['POI.testdata.path'] = '../test-data'
  271. // this is necessary for JDK 9+ to keep formatting dates the same way as in previous JDK-versions
  272. systemProperties['java.locale.providers'] = 'JRE,CLDR'
  273. doFirst {
  274. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  275. // some options were removed in JDK 18
  276. if (JavaVersion.current().ordinal() < JavaVersion.VERSION_18.ordinal()) {
  277. jvmArgs += [
  278. '--illegal-access=warn',
  279. ]
  280. } else {
  281. System.out.println("Configuring for JDK 18 or higher")
  282. }
  283. jvmArgs += [
  284. // see https://github.com/java9-modularity/gradle-modules-plugin/issues/97
  285. // opposed to the recommendation there, it doesn't work to add ... to the dependencies
  286. // testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.7.1'
  287. // gradles gradle-worker.jar is still not a JPMS module and thus runs as unnamed module
  288. '--add-exports','org.junit.platform.commons/org.junit.platform.commons.util=org.apache.poi.poi',
  289. '--add-exports','org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED',
  290. '--add-exports','org.junit.platform.commons/org.junit.platform.commons.logging=ALL-UNNAMED',
  291. '-Dsun.reflect.debugModuleAccessChecks=true',
  292. '-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true',
  293. ]
  294. }
  295. }
  296. jacoco {
  297. excludes = [
  298. // this is necessary to make JaCoCo work with JDK 18 for now
  299. 'sun/**',
  300. 'javax/**',
  301. ]
  302. }
  303. }
  304. jacoco {
  305. toolVersion = '0.8.7'
  306. }
  307. jacocoTestReport {
  308. reports {
  309. xml.required = true
  310. }
  311. }
  312. // ensure the build-dir exists
  313. projectDir.mkdirs()
  314. if (project.hasProperty('enableSonar')) {
  315. // See https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/ and
  316. // https://docs.sonarqube.org/display/SONARQUBE52/Analyzing+with+SonarQube+Scanner+for+Gradle
  317. // for documentation of properties.
  318. //
  319. // Some additional properties are currently set in the Jenkins-DSL, see jenksin/create_jobs.groovy
  320. //
  321. sonarqube {
  322. properties {
  323. // as we currently use build/<module>/ as project-basedir, we need to tell Sonar to use
  324. // the root-folder as "basedir" for the projects
  325. property "sonar.projectBaseDir", "$projectDir"
  326. // currently supported providers on Jenkins: "hg,git": property "sonar.scm.provider", "svn"
  327. // the plugin seems to not detect our non-standard build-layout
  328. property "sonar.junit.reportPaths", "$projectDir/build/test-results/test"
  329. // the Gradle run will report an invalid directory for 'ooxml-schema', but it seems to still work fine
  330. property "sonar.coverage.jacoco.xmlReportPaths", "$projectDir/build/reports/jacoco/test/jacocoTestReport.xml"
  331. // somehow the version was not use properly
  332. property "sonar.projectVersion", version
  333. }
  334. }
  335. }
  336. forbiddenApis {
  337. bundledSignatures = [ 'jdk-unsafe', 'jdk-deprecated', 'jdk-internal', 'jdk-non-portable', 'jdk-reflection' ]
  338. signaturesFiles = files('../src/resources/devtools/forbidden-signatures.txt')
  339. ignoreFailures = false
  340. suppressAnnotations = [ 'org.apache.poi.util.SuppressForbidden' ]
  341. // forbiddenapis bundled signatures max supported version is 14
  342. targetCompatibility = (JavaVersion.VERSION_14.isCompatibleWith(JavaVersion.current()) ? JavaVersion.current() : JavaVersion.VERSION_14)
  343. }
  344. forbiddenApisMain {
  345. signaturesFiles += files('../src/resources/devtools/forbidden-signatures-prod.txt')
  346. }
  347. task jenkins
  348. jenkins.dependsOn build
  349. jenkins.dependsOn check
  350. jenkins.dependsOn javadoc
  351. jenkins.dependsOn jacocoTestReport
  352. jenkins.dependsOn rat
  353. publishing {
  354. publications {
  355. POI(MavenPublication) {
  356. groupId 'org.apache.poi'
  357. artifactId project.archivesBaseName
  358. from components.java
  359. pom {
  360. packaging = 'jar'
  361. url = 'https://poi.apache.org/'
  362. name = 'Apache POI'
  363. description = 'Apache POI - Java API To Access Microsoft Format Files'
  364. mailingLists {
  365. mailingList {
  366. name = 'POI Users List'
  367. subscribe = 'user-subscribe@poi.apache.org'
  368. unsubscribe = 'user-unsubscribe@poi.apache.org'
  369. archive = 'http://mail-archives.apache.org/mod_mbox/poi-user/'
  370. }
  371. mailingList {
  372. name = 'POI Developer List'
  373. subscribe = 'dev-subscribe@poi.apache.org'
  374. unsubscribe = 'dev-unsubscribe@poi.apache.org'
  375. archive = 'http://mail-archives.apache.org/mod_mbox/poi-dev/'
  376. }
  377. }
  378. licenses {
  379. license {
  380. name = 'Apache License, Version 2.0'
  381. url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
  382. distribution = 'repo'
  383. }
  384. }
  385. organization {
  386. name = 'Apache Software Foundation'
  387. url = 'http://www.apache.org/'
  388. }
  389. withXml {
  390. def r = asElement()
  391. def doc = r.getOwnerDocument()
  392. def hdr = new File('../legal/HEADER')
  393. if (!hdr.exists()) hdr = new File('legal/HEADER')
  394. def asl = doc.createComment(hdr.text)
  395. // adding ASF header before root node is ignored
  396. // doc.insertBefore(asl, doc.getDocumentElement())
  397. r.insertBefore(asl, r.getFirstChild())
  398. // Replace ooxml-full with ooxml-lite
  399. XPath xpath = XPathFactory.newInstance().newXPath()
  400. NodeList res = (NodeList)xpath.evaluate("//dependency/artifactId[text() = 'poi-ooxml-full']", doc, XPathConstants.NODESET)
  401. for (int i=res.getLength()-1; i>=0; i--) {
  402. res.item(i).setTextContent('poi-ooxml-lite')
  403. }
  404. // remove duplicate entries
  405. res = (NodeList)xpath.evaluate("//dependency[artifactId = ./preceding-sibling::dependency/artifactId]", doc, XPathConstants.NODESET)
  406. for (int i=res.getLength()-1; i>=0; i--) {
  407. Node n = res.item(i)
  408. n.getParentNode().removeChild(n)
  409. }
  410. }
  411. }
  412. }
  413. }
  414. }
  415. generatePomFileForPOIPublication.destination = "../build/dist/maven/${project.archivesBaseName}/${project.archivesBaseName}-${project.version}.pom"
  416. tasks.withType(GenerateModuleMetadata) {
  417. enabled = false
  418. }
  419. signing {
  420. setRequired {
  421. // signing is only required if this is a release version
  422. // and the artifacts are to be published
  423. gradle.taskGraph.allTasks.any { it instanceof PublishToMavenRepository }
  424. }
  425. sign publishing.publications.POI
  426. }
  427. signPOIPublication.dependsOn('generatePomFileForPOIPublication')
  428. spotbugs {
  429. ignoreFailures = true
  430. showStackTraces = false
  431. }
  432. build {
  433. if (project.hasProperty('signing.keyId')) {
  434. dependsOn 'signPOIPublication'
  435. }
  436. }
  437. }
  438. // initial try to provide a combined JavaDoc, grouping is still missing here, though!
  439. task allJavaDoc(type: Javadoc) {
  440. var prj = [ project(':poi'), project(':poi-excelant'), project(':poi-ooxml'), project(':poi-scratchpad') ]
  441. source prj.collect { it.sourceSets.main.allJava }
  442. // for possible settings see https://docs.gradle.org/current/dsl/org.gradle.api.tasks.javadoc.Javadoc.html
  443. classpath = files(subprojects.collect { it.sourceSets.main.compileClasspath })
  444. destinationDir = file("${buildDir}/docs/javadoc")
  445. maxMemory="2048M"
  446. // for possible options see https://docs.gradle.org/current/javadoc/org/gradle/external/javadoc/StandardJavadocDocletOptions.html
  447. options.use = true
  448. options.splitIndex = true
  449. options.addBooleanOption('Xdoclint:all,-missing', true)
  450. title = 'POI API Documentation'
  451. options.bottom = '<![CDATA[<i>Copyright ' + new Date().format('yyyy') + ' The Apache Software Foundation or its licensors, as applicable.</i>]]>'
  452. options.group('DDF - Dreadful Drawing Format', 'org.apache.poi.ddf*')
  453. options.group('HPSF - Horrible Property Set Format', 'org.apache.poi.hpsf*')
  454. options.group('SS - Common Spreadsheet Format', 'org.apache.poi.ss*')
  455. options.group('HSSF - Horrible Spreadsheet Format', 'org.apache.poi.hssf*')
  456. options.group('XSSF - Open Office XML Spreadsheet Format', 'org.apache.poi.xssf*')
  457. options.group('SL - Common Slideshow Format', 'org.apache.poi.sl*')
  458. options.group('HSLF - Horrible Slideshow Format', 'org.apache.poi.hslf*', 'org.apache.poi.hwmf*', 'org.apache.poi.hemf*')
  459. options.group('XSLF - Open Office XML Slideshow Format', 'org.apache.poi.xslf*')
  460. options.group('HWPF - Horrible Word Processor Format', 'org.apache.poi.hwpf*')
  461. options.group('XWPF - Open Office XML Word Processor Format', 'org.apache.poi.xwpf*')
  462. options.group('HDGF - Horrible Diagram Format', 'org.apache.poi.hdgf*')
  463. options.group('XDGF - Open Office XML Diagram Format', 'org.apache.poi.xdgf*')
  464. options.group('HMEF - Transport Neutral Encoding Files (TNEF)', 'org.apache.poi.hmef*')
  465. options.group('HSMF Outlook message file format', 'org.apache.poi.hsmf*')
  466. options.group('HPBF - Publisher Format Files', 'org.apache.poi.hpbf*')
  467. options.group('POIFS - POI File System', 'org.apache.poi.poifs*')
  468. options.group('Utilities', 'org.apache.poi.util*')
  469. options.group('Excelant', 'org.apache.poi.ss.excelant**')
  470. // options.group('Examples', 'org.apache.poi.examples*')
  471. }
  472. task jenkins(dependsOn: ['replaceVersion', subprojects.build, 'binDistZip','binDistTar','srcDistZip','srcDistTar']) {}
  473. clean {
  474. delete "${rootDir}/build/dist"
  475. }
  476. rat {
  477. // Input directory, defaults to '.'
  478. inputDir.set(file("."))
  479. // include all directories which contain files that are included in releases
  480. includes = [
  481. "poi-examples/**",
  482. "poi-excelant/**",
  483. "poi-integration/**",
  484. "legal/**",
  485. "poi/**",
  486. "maven/**",
  487. "poi-ooxml/**",
  488. "poi-ooxml-full/**",
  489. "poi-ooxml-lite/**",
  490. "poi-ooxml-lite-agent/**",
  491. "osgi/**",
  492. "poi-scratchpad/**",
  493. "src/**",
  494. // "sonar/**",
  495. "build.*"
  496. ]
  497. // List of Gradle exclude directives, defaults to ['**/.gradle/**']
  498. //excludes.add("main/java/org/apache/poi/**/*-chart-data.txt")
  499. excludes = [
  500. "build.javacheck.xml",
  501. "**/build/**",
  502. "**/out/**",
  503. "**/*.iml",
  504. "**/*.log",
  505. "**/gradle-wrapper.properties",
  506. "**/main/java/org/apache/poi/**/*-chart-data.txt",
  507. "poi/src/main/resources/org/apache/poi/sl/draw/geom/presetShapeDefinitions.xml",
  508. "poi-ooxml/src/main/resources/org/apache/poi/xslf/usermodel/notesMaster.xml",
  509. "poi-ooxml/src/main/resources/org/apache/poi/xssf/usermodel/presetTableStyles.xml",
  510. "poi-ooxml-full/src/main/xmlschema/org/apache/poi/schemas/XAdES*.xsd",
  511. "poi-ooxml-full/src/main/xmlschema/org/apache/poi/schemas/xmldsig-core-schema.xsd",
  512. "poi-ooxml-full/src/main/xmlschema/org/apache/poi/xdgf/visio.xsd",
  513. "osgi/README.md",
  514. // ignore svn conflict artifacts
  515. "**/module-info.*"
  516. ]
  517. /*
  518. <exclude name="documentation/*.txt" />
  519. <exclude name="documentation/content/xdocs/dtd/" />
  520. <exclude name="documentation/content/xdocs/entity/" />
  521. <exclude name="documentation/resources/images/pb-poi.cdr"/>
  522. */
  523. // Prints the list of files with unapproved licences to the console, defaults to false
  524. verbose.set(true)
  525. }
  526. /*task downloadJarsToLibs() {
  527. def f = new File("$projectDir/../lib/ooxml/xmlbeans-5.0.0.jar")
  528. if (!f.exists()) {
  529. println 'writing file ' + f.getAbsolutePath()
  530. f.getParentFile().mkdirs()
  531. 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 }}
  532. }
  533. }*/
  534. //compileJava.dependsOn 'downloadJarsToLibs'
  535. task replaceVersion() {
  536. outputs.upToDateWhen { false }
  537. var version = subprojects[0].version
  538. var tokens = [
  539. // [ 'sonar', '**/pom.xml', '(packaging>\\n\\s*<version>)[0-9.]+(?:-SNAPSHOT)?', "\\1${version}" ],
  540. // [ 'sonar', '**/pom.xml', '(poi-parent&lt;/artifactId>\\n\\s*<version>)[0-9.]+(?:-SNAPSHOT)?', "\1${version}" ],
  541. [ 'osgi', 'pom.xml', '(packaging>\\n\\s*<version>)[0-9.]+(?:-SNAPSHOT|-RC\\d+)?', "\\1${version}" ]
  542. // [ '.', 'build.gradle', ' version = \'[0-9.]+(?:-SNAPSHOT)?\'', " version = '${version}'" ]
  543. ]
  544. doLast {
  545. tokens.forEach {
  546. var dir = it[0], name = it[1], match = it[2], replace = it[3]
  547. ant.replaceregexp(match: match, replace: replace) {
  548. fileset(dir: dir) {
  549. include(name: name)
  550. }
  551. }
  552. }
  553. }
  554. }
  555. task zipJavadocs(type: Zip, dependsOn: allJavaDoc) {
  556. from('build/docs/javadoc/')
  557. destinationDirectory = file('build/dist')
  558. archiveBaseName = 'poi'
  559. archiveVersion = subprojects[0].version
  560. archiveAppendix = 'javadoc'
  561. archiveExtension = 'jar'
  562. }
  563. tasks.withType(Tar) {
  564. compression = Compression.GZIP
  565. archiveExtension = 'tgz'
  566. }
  567. distributions {
  568. var version = subprojects[0].version
  569. var date = new Date().format('yyyyMMdd')
  570. var poiDep = project(':poi').configurations.getAt('compileClasspath')
  571. var ooxmlImp = project(':poi-ooxml').configurations.getAt('compileClasspath')
  572. bin {
  573. distributionBaseName = "poi-bin-${version}-${date}"
  574. contents {
  575. from('build/dist/maven') {
  576. include "**/*${version}.jar"
  577. exclude "**/*lite-agent*.jar"
  578. exclude "**/*integration*.jar"
  579. }
  580. from('build/dist') { include 'poi-javadoc*.jar'}
  581. from('legal') { exclude 'HEADER' }
  582. from(poiDep) { include "**/*.jar" }
  583. from(ooxmlImp) { include "**/*.jar" }
  584. includeEmptyDirs = false
  585. duplicatesStrategy = DuplicatesStrategy.EXCLUDE
  586. eachFile {
  587. String root = "poi-bin-${version}/"
  588. if (name.startsWith('poi')) {
  589. path = root + name
  590. } else if (poiDep.contains(file)) {
  591. path = root + 'lib/' + name
  592. } else if (name =~ /^(batik|bc|fontbox|graphics|pdfbox|xml-apis|xmlgraphics|xmlsec)/) {
  593. path = root + 'auxiliary/' + name
  594. } else if (ooxmlImp.contains(file)) {
  595. path = root + 'ooxml-lib/' + name
  596. } else {
  597. path = root + name
  598. }
  599. }
  600. }
  601. }
  602. src {
  603. distributionBaseName = "poi-src-${version}-${date}"
  604. contents {
  605. from('.') {
  606. exclude '*/build/**'
  607. exclude 'build/**'
  608. exclude 'dist*/**'
  609. exclude 'lib/**'
  610. exclude 'lib.stored/**'
  611. exclude 'bin/**'
  612. exclude 'out/**'
  613. exclude 'tmp/**'
  614. exclude 'gradle/**'
  615. exclude 'sonar/**/target/**'
  616. exclude 'sonar/*/src/**'
  617. exclude 'compile-lib/**'
  618. exclude 'ooxml-lib/**'
  619. exclude 'ooxml-testlib/**'
  620. exclude 'scripts/**'
  621. exclude '.gradle/**'
  622. exclude '.idea/**'
  623. exclude '.classpath'
  624. exclude '.settings/**'
  625. exclude '.project'
  626. exclude 'TEST*'
  627. exclude 'gradlew'
  628. exclude 'gradlew.bat'
  629. exclude '**/*.iml'
  630. exclude '*.ipr'
  631. exclude '*.iws'
  632. exclude '*.rdf'
  633. exclude '*.png'
  634. exclude '*.gif'
  635. exclude '*.jpg'
  636. exclude '*.jpeg'
  637. exclude '*.swp'
  638. exclude '*.lnk'
  639. exclude '*.log'
  640. exclude '*.launch'
  641. exclude '*.docx'
  642. exclude '*.pptx'
  643. exclude '*.xlsx'
  644. }
  645. from('legal') { exclude 'HEADER' }
  646. }
  647. }
  648. }
  649. binDistZip.dependsOn 'zipJavadocs', ':poi-ooxml-lite:jar'
  650. binDistTar.dependsOn 'zipJavadocs', ':poi-ooxml-lite:jar'
  651. var srcDep = [
  652. ':poi:cacheJava9',
  653. ':poi:cacheTest9',
  654. ':poi-ooxml-full:cacheJava9',
  655. ':poi-ooxml-lite-agent:cacheJava9',
  656. ':poi-ooxml:cacheJava9',
  657. ':poi-ooxml:cacheTest9',
  658. ':poi-scratchpad:cacheJava9',
  659. ':poi-scratchpad:cacheTest9',
  660. ':poi-excelant:cacheJava9',
  661. ':poi-excelant:cacheTest9',
  662. ':poi-examples:cacheJava9',
  663. ':poi-integration:cacheTest9',
  664. ':poi-ooxml-lite:cacheJava9',
  665. ':poi-ooxml-lite:generateModuleInfo'
  666. ]
  667. srcDistTar.dependsOn srcDep
  668. srcDistZip.dependsOn srcDep
  669. rat.dependsOn srcDep
  670. task fixDistDir {
  671. doLast {
  672. ant.mkdir(dir: 'build/dist')
  673. ant.move(todir: 'build/dist') {
  674. fileset(dir: 'build/distributions', includes: '*')
  675. }
  676. }
  677. }
  678. binDistZip.finalizedBy fixDistDir
  679. binDistTar.finalizedBy fixDistDir
  680. srcDistZip.finalizedBy fixDistDir
  681. srcDistTar.finalizedBy fixDistDir