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

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