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.

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