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 29KB

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