You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.gradle 31KB

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