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

build.gradle 30KB

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