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

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