選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

build.gradle 24KB

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