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

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