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

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