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

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