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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. buildscript {
  16. repositories {
  17. maven { url "https://plugins.gradle.org/m2/" }
  18. }
  19. dependencies {
  20. classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.0"
  21. }
  22. }
  23. plugins {
  24. id("org.nosphere.apache.rat") version "0.7.0"
  25. }
  26. repositories {
  27. mavenCentral()
  28. }
  29. // Only add the plugin for Sonar if enabled
  30. if (project.hasProperty('enableSonar')) {
  31. println 'Enabling Sonar support'
  32. apply plugin: "org.sonarqube"
  33. }
  34. // For help converting an Ant build to a Gradle build, see
  35. // https://docs.gradle.org/current/userguide/ant.html
  36. configurations {
  37. antLibs {
  38. attributes {
  39. attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
  40. }
  41. }
  42. }
  43. dependencies {
  44. antLibs("org.junit.jupiter:junit-jupiter:5.7.0")
  45. antLibs("org.apache.ant:ant-junitlauncher:1.10.9")
  46. }
  47. ant.taskdef(name: "junit",
  48. classname: "org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.JUnitLauncherTask",
  49. classpath: configurations.antLibs.asPath)
  50. wrapper {
  51. gradleVersion = '6.8'
  52. }
  53. task adjustWrapperPropertiesFile {
  54. doLast {
  55. ant.replaceregexp(match:'^#.*', replace:'', flags:'g', byline:true) {
  56. fileset(dir: project.projectDir, includes: 'gradle/wrapper/gradle-wrapper.properties')
  57. }
  58. new File(project.projectDir, 'gradle/wrapper/gradle-wrapper.properties').with { it.text = it.readLines().findAll { it }.sort().join('\n') }
  59. ant.fixcrlf(file: 'gradle/wrapper/gradle-wrapper.properties', eol: 'lf')
  60. }
  61. }
  62. wrapper.finalizedBy adjustWrapperPropertiesFile
  63. /**
  64. Define properties for all projects, including this one
  65. */
  66. allprojects {
  67. apply plugin: 'eclipse'
  68. }
  69. /**
  70. Define things that are only necessary in sub-projects, but not in the master-project itself
  71. */
  72. subprojects {
  73. //Put instructions for each sub project, but not the master
  74. apply plugin: 'java-library'
  75. apply plugin: 'jacoco'
  76. version = '5.0.1-SNAPSHOT'
  77. ext {
  78. bouncyCastleVersion = '1.68'
  79. commonsCodecVersion = '1.15'
  80. commonsCompressVersion = '1.20'
  81. commonsMathVersion = '3.6.1'
  82. junitVersion = '5.7.0'
  83. log4jVersion = '2.14.0'
  84. mockitoVersion = '3.6.0'
  85. hamcrestVersion = '2.2'
  86. xmlbeansVersion = '5.0.0'
  87. batikVersion = '1.14'
  88. }
  89. tasks.withType(JavaCompile) {
  90. options.encoding = 'UTF-8'
  91. }
  92. sourceCompatibility = 1.8
  93. targetCompatibility = 1.8
  94. repositories {
  95. mavenCentral()
  96. maven {
  97. url 'https://repository.apache.org/content/repositories/releases'
  98. }
  99. }
  100. dependencies {
  101. testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
  102. testImplementation "org.mockito:mockito-core:${mockitoVersion}"
  103. testImplementation "org.hamcrest:hamcrest:${hamcrestVersion}"
  104. testImplementation "org.apache.logging.log4j:log4j-core:${log4jVersion}"
  105. }
  106. jar {
  107. manifest {
  108. attributes 'Implementation-Title': 'Apache POI', 'Implementation-Version': version
  109. }
  110. }
  111. test {
  112. // make XML test-results available for Jenkins CI
  113. useJUnitPlatform()
  114. reports {
  115. junitXml.enabled = true
  116. }
  117. // Exclude some tests that are not actually tests or do not run cleanly on purpose
  118. exclude '**/BaseTestBorderStyle.class'
  119. exclude '**/BaseTestCellUtil.class'
  120. exclude '**/TestUnfixedBugs.class'
  121. exclude '**/TestOneFile.class'
  122. // Exclude Test Suites
  123. exclude '**/All*Tests.class'
  124. exclude '**/HSSFTests.class'
  125. // set heap size for the test JVM(s)
  126. minHeapSize = "128m"
  127. maxHeapSize = "768m"
  128. // Specifying the local via system properties did not work, so we set them this way
  129. jvmArgs '-Duser.language=en -Duser.country=US'
  130. // show standard out and standard error of the test JVM(s) on the console
  131. //testLogging.showStandardStreams = true
  132. // http://forums.gradle.org/gradle/topics/jacoco_related_failure_in_multiproject_build
  133. systemProperties['user.dir'] = workingDir
  134. systemProperties['POI.testdata.path'] = '../test-data'
  135. // this is necessary for JDK 9+ to keep formatting dates the same way as in previous JDK-versions
  136. systemProperties['java.locale.providers'] = 'JRE,CLDR'
  137. systemProperties['junit.jupiter.execution.parallel.enabled'] = 'false'
  138. }
  139. jacoco {
  140. toolVersion = '0.8.6'
  141. }
  142. jacocoTestReport {
  143. reports {
  144. xml.enabled true
  145. }
  146. }
  147. // ensure the build-dir exists
  148. projectDir.mkdirs()
  149. if (project.hasProperty('enableSonar')) {
  150. // See https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/ and
  151. // https://docs.sonarqube.org/display/SONARQUBE52/Analyzing+with+SonarQube+Scanner+for+Gradle
  152. // for documentation of properties.
  153. //
  154. // Some additional properties are currently set in the Jenkins-DSL, see jenksin/create_jobs.groovy
  155. //
  156. sonarqube {
  157. properties {
  158. // as we currently use build/<module>/ as project-basedir, we need to tell Sonar to use
  159. // the root-folder as "basedir" for the projects
  160. property "sonar.projectBaseDir", "$projectDir"
  161. // currently supported providers on Jenkins: "hg,git": property "sonar.scm.provider", "svn"
  162. // the plugin seems to not detect our non-standard build-layout
  163. property "sonar.junit.reportPaths", "$projectDir/build/test-results/test"
  164. property "sonar.coverage.jacoco.xmlReportPaths", "$projectDir/build/reports/jacoco/test/jacocoTestReport.xml"
  165. }
  166. }
  167. }
  168. task jenkins
  169. jenkins.dependsOn build
  170. jenkins.dependsOn check
  171. jenkins.dependsOn javadoc
  172. jenkins.dependsOn jacocoTestReport
  173. jenkins.dependsOn rat
  174. }
  175. rat {
  176. // Input directory, defaults to '.'
  177. inputDir.set(file("."))
  178. // include all directories which contain files that are included in releases
  179. includes.add("examples/**")
  180. includes.add("excelant/**")
  181. includes.add("integrationtest/**")
  182. includes.add("legal/**")
  183. includes.add("main/**")
  184. includes.add("maven/**")
  185. includes.add("ooxml/**")
  186. includes.add("ooxml-schema/**")
  187. //includes.add("osgi/**")
  188. includes.add("scratchpad/**")
  189. includes.add("src/**")
  190. //includes.add("sonar/**")
  191. includes.add("build.*")
  192. // List of Gradle exclude directives, defaults to ['**/.gradle/**']
  193. //excludes.add("main/java/org/apache/poi/**/*-chart-data.txt")
  194. excludes.add("**/build/**")
  195. excludes.add("**/out/**")
  196. excludes.add("**/*.iml")
  197. excludes.add("**/*.log")
  198. excludes.add("**/main/java/org/apache/poi/**/*-chart-data.txt")
  199. excludes.add("main/src/main/resources/org/apache/poi/sl/draw/geom/presetShapeDefinitions.xml")
  200. excludes.add("ooxml/src/main/resources/org/apache/poi/xslf/usermodel/notesMaster.xml")
  201. excludes.add("ooxml/src/main/resources/org/apache/poi/xssf/usermodel/presetTableStyles.xml")
  202. excludes.add("ooxml-schema/src/main/xmlschema/org/apache/poi/schemas/XAdES*.xsd")
  203. excludes.add("ooxml-schema/src/main/xmlschema/org/apache/poi/schemas/xmldsig-core-schema.xsd")
  204. excludes.add("ooxml-schema/src/main/xmlschema/org/apache/poi/xdgf/visio.xsd")
  205. /*
  206. <exclude name="documentation/*.txt" />
  207. <exclude name="documentation/content/xdocs/dtd/" />
  208. <exclude name="documentation/content/xdocs/entity/" />
  209. <exclude name="documentation/resources/images/pb-poi.cdr"/>
  210. */
  211. // Prints the list of files with unapproved licences to the console, defaults to false
  212. verbose.set(true)
  213. }