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

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