Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

build.gradle 29KB

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