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

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