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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. // 2.x fails with "Could not get unknown property 'me'"
  21. classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.1.2'
  22. classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.0"
  23. }
  24. }
  25. repositories {
  26. mavenCentral()
  27. }
  28. // Only add the plugin for Sonar if enabled
  29. if (project.hasProperty('enableSonar')) {
  30. println 'Enabling Sonar support'
  31. apply plugin: "org.sonarqube"
  32. }
  33. // For help converting an Ant build to a Gradle build, see
  34. // https://docs.gradle.org/current/userguide/ant.html
  35. configurations {
  36. antLibs {
  37. attributes {
  38. attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL))
  39. }
  40. }
  41. }
  42. dependencies {
  43. antLibs("org.junit.jupiter:junit-jupiter:5.7.0")
  44. antLibs("org.apache.ant:ant-junitlauncher:1.10.9")
  45. }
  46. ant.taskdef(name: "junit",
  47. classname: "org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.JUnitLauncherTask",
  48. classpath: configurations.antLibs.asPath)
  49. wrapper {
  50. gradleVersion = '6.8'
  51. }
  52. task adjustWrapperPropertiesFile {
  53. doLast {
  54. ant.replaceregexp(match:'^#.*', replace:'', flags:'g', byline:true) {
  55. fileset(dir: project.projectDir, includes: 'gradle/wrapper/gradle-wrapper.properties')
  56. }
  57. new File(project.projectDir, 'gradle/wrapper/gradle-wrapper.properties').with { it.text = it.readLines().findAll { it }.sort().join('\n') }
  58. ant.fixcrlf(file: 'gradle/wrapper/gradle-wrapper.properties', eol: 'lf')
  59. }
  60. }
  61. wrapper.finalizedBy adjustWrapperPropertiesFile
  62. /**
  63. Define properties for all projects, including this one
  64. */
  65. allprojects {
  66. apply plugin: 'eclipse'
  67. }
  68. /**
  69. Define things that are only necessary in sub-projects, but not in the master-project itself
  70. */
  71. subprojects {
  72. //Put instructions for each sub project, but not the master
  73. apply plugin: 'java-library'
  74. apply plugin: 'jacoco'
  75. // See https://github.com/melix/japicmp-gradle-plugin
  76. apply plugin: 'me.champeau.gradle.japicmp'
  77. version = '5.0.1-SNAPSHOT'
  78. ext {
  79. bouncyCastleVersion = '1.68'
  80. commonsCodecVersion = '1.15'
  81. commonsCompressVersion = '1.20'
  82. commonsMathVersion = '3.6.1'
  83. japicmpversion = '5.0.0'
  84. junitVersion = '5.7.0'
  85. log4jVersion = '2.14.0'
  86. mockitoVersion = '3.6.0'
  87. hamcrestVersion = '2.2'
  88. xmlbeansVersion = '5.0.0'
  89. batikVersion = '1.14'
  90. }
  91. tasks.withType(JavaCompile) {
  92. options.encoding = 'UTF-8'
  93. }
  94. sourceCompatibility = 1.8
  95. targetCompatibility = 1.8
  96. repositories {
  97. mavenCentral()
  98. maven {
  99. url 'https://repository.apache.org/content/repositories/releases'
  100. }
  101. }
  102. dependencies {
  103. testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
  104. testImplementation "org.mockito:mockito-core:${mockitoVersion}"
  105. testImplementation "org.hamcrest:hamcrest:${hamcrestVersion}"
  106. testImplementation "org.apache.logging.log4j:log4j-core:${log4jVersion}"
  107. }
  108. jar {
  109. manifest {
  110. attributes 'Implementation-Title': 'Apache POI', 'Implementation-Version': version
  111. }
  112. }
  113. test {
  114. // make XML test-results available for Jenkins CI
  115. useJUnitPlatform()
  116. reports {
  117. junitXml.enabled = true
  118. }
  119. // Exclude some tests that are not actually tests or do not run cleanly on purpose
  120. exclude '**/BaseTestBorderStyle.class'
  121. exclude '**/BaseTestCellUtil.class'
  122. exclude '**/TestUnfixedBugs.class'
  123. exclude '**/TestOneFile.class'
  124. // Exclude Test Suites
  125. exclude '**/All*Tests.class'
  126. exclude '**/HSSFTests.class'
  127. // set heap size for the test JVM(s)
  128. minHeapSize = "128m"
  129. maxHeapSize = "768m"
  130. // Specifying the local via system properties did not work, so we set them this way
  131. jvmArgs '-Duser.language=en -Duser.country=US'
  132. // show standard out and standard error of the test JVM(s) on the console
  133. //testLogging.showStandardStreams = true
  134. // http://forums.gradle.org/gradle/topics/jacoco_related_failure_in_multiproject_build
  135. systemProperties['user.dir'] = workingDir
  136. systemProperties['POI.testdata.path'] = '../test-data'
  137. // this is necessary for JDK 9+ to keep formatting dates the same way as in previous JDK-versions
  138. systemProperties['java.locale.providers'] = 'JRE,CLDR'
  139. systemProperties['junit.jupiter.execution.parallel.enabled'] = 'false'
  140. }
  141. jacoco {
  142. toolVersion = '0.8.6'
  143. }
  144. jacocoTestReport {
  145. reports {
  146. xml.enabled true
  147. }
  148. }
  149. // ensure the build-dir exists
  150. projectDir.mkdirs()
  151. if (project.hasProperty('enableSonar')) {
  152. // See https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/ and
  153. // https://docs.sonarqube.org/display/SONARQUBE52/Analyzing+with+SonarQube+Scanner+for+Gradle
  154. // for documentation of properties.
  155. //
  156. // Some additional properties are currently set in the Jenkins-DSL, see jenksin/create_jobs.groovy
  157. //
  158. sonarqube {
  159. properties {
  160. // as we currently use build/<module>/ as project-basedir, we need to tell Sonar to use
  161. // the root-folder as "basedir" for the projects
  162. property "sonar.projectBaseDir", "$projectDir"
  163. // currently supported providers on Jenkins: "hg,git": property "sonar.scm.provider", "svn"
  164. // the plugin seems to not detect our non-standard build-layout
  165. property "sonar.junit.reportPaths", "$projectDir/build/test-results/test"
  166. property "sonar.coverage.jacoco.xmlReportPaths", "$projectDir/build/reports/jacoco/test/jacocoTestReport.xml"
  167. }
  168. }
  169. }
  170. task(japicmp, type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  171. to = jar.archivePath
  172. onlyModified = true
  173. onlyBinaryIncompatibleModified = true
  174. failOnModification = false
  175. txtOutputFile = file("$buildDir/reports/japi.txt")
  176. htmlOutputFile = file("$buildDir/reports/japi.html")
  177. }
  178. }