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

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