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

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