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

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