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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import java.util.regex.Pattern
  2. /* ====================================================================
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. ==================================================================== */
  16. final String TEST9_SRC = 'src/test/java9'
  17. final String TEST9_OUT = "${buildDir}/classes/java9/test/"
  18. final String VERSIONS9 = 'META-INF/versions/9'
  19. final boolean IBMVM = System.getProperty("java.vendor").contains("IBM")
  20. configurations {
  21. tests
  22. misc
  23. }
  24. sourceSets {
  25. test {
  26. output.dir(TEST9_OUT, builtBy: 'compileTest9')
  27. if (IBMVM) {
  28. java {
  29. exclude '**/HeapDump**'
  30. }
  31. }
  32. }
  33. }
  34. dependencies {
  35. testImplementation 'org.apache.ant:ant:1.10.12'
  36. testImplementation 'org.apache.commons:commons-collections4:4.4'
  37. testImplementation 'com.google.guava:guava:31.1-jre'
  38. misc(project(':poi-ooxml')) {
  39. capabilities {
  40. requireCapability("${project.group}:poi-ooxml-rendersign")
  41. }
  42. if (NO_SCRATCHPAD) {
  43. exclude group: 'org.apache.poi', module: 'poi-scratchpad'
  44. }
  45. }
  46. if (NO_SCRATCHPAD) {
  47. testCompileOnly project(':poi-scratchpad')
  48. testCompileOnly project(path:':poi-scratchpad', configuration:'tests')
  49. } else {
  50. testImplementation project(':poi-scratchpad')
  51. testImplementation project(path:':poi-scratchpad', configuration:'tests')
  52. }
  53. testImplementation(project(':poi-examples')) {
  54. if (NO_SCRATCHPAD) {
  55. exclude group: 'org.apache.poi', module: 'poi-scratchpad'
  56. }
  57. }
  58. testImplementation(project(path:':poi-examples', configuration:'archives')) {
  59. if (NO_SCRATCHPAD) {
  60. exclude group: 'org.apache.poi', module: 'poi-scratchpad'
  61. }
  62. }
  63. testImplementation project(path:':poi', configuration:'tests')
  64. testImplementation(project(path:':poi-ooxml', configuration:'tests')) {
  65. if (NO_SCRATCHPAD) {
  66. exclude group: 'org.apache.poi', module: 'poi-scratchpad'
  67. }
  68. }
  69. testImplementation project(path: ':poi-ooxml-lite-agent', configuration: 'archives')
  70. testImplementation "org.apache.logging.log4j:log4j-slf4j2-impl:${log4jVersion}"
  71. testImplementation 'org.slf4j:slf4j-simple:2.0.6'
  72. testRuntimeOnly "org.apiguardian:apiguardian-api:${apiGuardianVersion}"
  73. }
  74. final String MODULE_NAME = 'org.apache.poi.stress'
  75. final Pattern MODULE_NOT_REGEX = ~'((poi|poi-scratchpad|poi-ooxml)[/\\\\][^/\\\\]+$|batik-script)'
  76. final Pattern MODULE_REGEX = ~'\\.jar$'
  77. final List MODULE_COMPILE_PATH = (sourceSets.test.compileClasspath + configurations.misc.files).findAll{ it.path =~ MODULE_REGEX && !(it.path =~ MODULE_NOT_REGEX) }.collect{ it.parent }.unique()
  78. final List MODULE_RUNTIME_PATH = (sourceSets.test.runtimeClasspath + configurations.misc.files).findAll{ it.path =~ MODULE_REGEX && !(it.path =~ MODULE_NOT_REGEX) }.collect{ it.parent }.unique()
  79. final String OOXML_LITE_AGENT = "../build/dist/maven/poi-ooxml-lite-agent/poi-ooxml-lite-agent-${project.version}.jar"
  80. final String OOXML_LITE_REPORT = '../src/resources/ooxml-lite-report'
  81. final String OOXML_LITE_INCLUDES = "^(com/microsoft/schemas|org/(etsi|openxmlformats|w3/)|org/apache/poi/schemas)"
  82. java {
  83. toolchain {
  84. languageVersion.set(JavaLanguageVersion.of(jdkVersion))
  85. if (jdkVendor != '') vendor.set(JvmVendorSpec.matching(jdkVendor))
  86. }
  87. }
  88. task compileTest9(type: JavaCompile) {
  89. dependsOn 'compileTestJava', ':poi-ooxml:testJar', ':poi-scratchpad:testJar', ':poi-examples:jar'
  90. javaCompiler = javaToolchains.compilerFor {
  91. languageVersion = JavaLanguageVersion.of(Math.max(11, jdkVersion))
  92. }
  93. sourceCompatibility = 1.9
  94. targetCompatibility = 1.9
  95. destinationDirectory = file(TEST9_OUT + VERSIONS9)
  96. source = file(TEST9_SRC)
  97. options.compilerArgs = [
  98. '--patch-module', "${MODULE_NAME}=${(sourceSets.main.output.classesDirs + sourceSets.test.output.classesDirs).asPath}",
  99. '--module-path', files(MODULE_COMPILE_PATH).asPath
  100. ]
  101. classpath = files()
  102. }
  103. jar {
  104. destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
  105. manifest {
  106. attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
  107. }
  108. }
  109. // Create a separate jar for test-code to depend on it in other projects
  110. // See http://stackoverflow.com/questions/5144325/gradle-test-dependency
  111. task testJar(type: Jar, dependsOn: [ testClasses, compileTest9 ] ) {
  112. destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}-tests")
  113. classifier 'tests'
  114. // ignore second module-info.class from main
  115. duplicatesStrategy = 'exclude'
  116. from sourceSets.test.output + sourceSets.main.output
  117. manifest {
  118. attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
  119. }
  120. }
  121. artifacts {
  122. tests testJar
  123. }
  124. test {
  125. // exclude these from the normal test-run
  126. exclude '**/*FileHandler.class'
  127. dependsOn { testJar }
  128. systemProperties['junit.jupiter.execution.parallel.enabled'] = 'true'
  129. doFirst {
  130. jvmArgs += [
  131. "-javaagent:${OOXML_LITE_AGENT}=${OOXML_LITE_REPORT}|${OOXML_LITE_INCLUDES}",
  132. ]
  133. if (jdkVersion > 8) {
  134. jvmArgs += [
  135. '--add-modules', MODULE_NAME,
  136. '--module-path', '../build/dist/maven/poi-integration-tests' + File.pathSeparator + files(MODULE_RUNTIME_PATH).asPath,
  137. ]
  138. }
  139. if (NO_SCRATCHPAD) {
  140. systemProperty 'scratchpad.ignore', 'true'
  141. }
  142. }
  143. }
  144. javadoc { enabled(false) }
  145. sourcesJar { enabled(false) }
  146. generateMetadataFileForPOIPublication.enabled = false
  147. publishPOIPublicationToMavenLocal.enabled = false