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

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