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

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