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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 java.util.regex.Pattern
  16. configurations {
  17. tests
  18. javadocs
  19. }
  20. sourceSets {
  21. main {
  22. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  23. output.dir(JAVA9_OUT, builtBy: 'cacheJava9')
  24. }
  25. }
  26. test {
  27. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  28. output.dir(TEST9_OUT, builtBy: 'cacheTest9')
  29. }
  30. }
  31. }
  32. dependencies {
  33. api "commons-codec:commons-codec:${commonsCodecVersion}"
  34. api 'org.apache.commons:commons-collections4:4.4'
  35. api "org.apache.commons:commons-math3:${commonsMathVersion}"
  36. api "commons-io:commons-io:${commonsIoVersion}"
  37. api 'com.zaxxer:SparseBitSet:1.2'
  38. implementation "org.apache.logging.log4j:log4j-api:${log4jVersion}"
  39. implementation 'javax.activation:activation:1.1.1'
  40. testImplementation 'org.reflections:reflections:0.9.12'
  41. testImplementation 'org.apache.ant:ant:1.10.11'
  42. testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
  43. testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
  44. // needed for locating the external references
  45. javadocs project(':poi-ooxml')
  46. javadocs project(':poi-scratchpad')
  47. }
  48. final String MODULE_NAME = 'org.apache.poi.poi'
  49. final Pattern MODULE_NOT_REGEX = ~'(poi[/\\\\][^/\\\\]+$|batik-script)'
  50. final Pattern MODULE_REGEX = ~'\\.jar$'
  51. final List MODULE_PATH = sourceSets.test.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX && !(it.path =~ MODULE_NOT_REGEX) }.collect{ it.parent }.unique()
  52. task compileJava9(type: JavaCompile) {
  53. dependsOn 'compileJava'
  54. sourceCompatibility = 9
  55. targetCompatibility = 9
  56. destinationDirectory = file(JAVA9_OUT + VERSIONS9)
  57. source = file(JAVA9_SRC)
  58. classpath = files()
  59. options.compilerArgs = [
  60. '--patch-module', "${MODULE_NAME}=${sourceSets.main.output.classesDirs.asPath}",
  61. '--module-path', sourceSets.main.compileClasspath.asPath
  62. ]
  63. }
  64. task cacheJava9(type: Copy) {
  65. dependsOn 'compileJava9'
  66. from(file(JAVA9_OUT + VERSIONS9))
  67. into(JAVA9_SRC)
  68. }
  69. task compileTest9(type: JavaCompile) {
  70. dependsOn 'compileTestJava'
  71. sourceCompatibility = 9
  72. targetCompatibility = 9
  73. destinationDirectory = file(TEST9_OUT + VERSIONS9)
  74. source = file(TEST9_SRC)
  75. options.compilerArgs = [
  76. '--patch-module', "${MODULE_NAME}=${(sourceSets.main.output.classesDirs + sourceSets.test.output.classesDirs).asPath}",
  77. '--module-path', files(MODULE_PATH).asPath
  78. ]
  79. classpath = files()
  80. }
  81. task cacheTest9(type: Copy) {
  82. dependsOn 'compileTest9'
  83. from(file(TEST9_OUT + VERSIONS9))
  84. into(TEST9_SRC)
  85. }
  86. jar {
  87. dependsOn cacheJava9
  88. if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
  89. into('META-INF/versions/9') {
  90. from JAVA9_SRC include '*.class'
  91. }
  92. }
  93. manifest {
  94. attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
  95. }
  96. }
  97. // Create a separate jar for test-code to depend on it in other projects
  98. // See http://stackoverflow.com/questions/5144325/gradle-test-dependency
  99. task testJar(type: Jar, dependsOn: [ testClasses, cacheTest9 ]) {
  100. destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}-tests")
  101. classifier 'tests'
  102. // ignore second module-info.class from main
  103. duplicatesStrategy = 'exclude'
  104. if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
  105. into('META-INF/versions/9') {
  106. from TEST9_SRC include '*.class'
  107. }
  108. }
  109. from sourceSets.test.output + sourceSets.main.output
  110. manifest {
  111. attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
  112. }
  113. }
  114. javadoc {
  115. dependsOn configurations.javadocs.dependencies.collect{ ':' + it.dependencyProject.name + ':compileJava' }
  116. doFirst {
  117. options {
  118. classpath += files(configurations.javadocs.dependencies.collect{ it.dependencyProject.sourceSets.main.output.classesDirs })
  119. }
  120. }
  121. }
  122. artifacts {
  123. tests testJar
  124. }
  125. test {
  126. dependsOn { testJar }
  127. systemProperties['junit.jupiter.execution.parallel.enabled'] = 'true'
  128. doFirst {
  129. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  130. jvmArgs << [
  131. '--add-modules', MODULE_NAME,
  132. '--module-path', '../build/dist/maven/poi-tests' + File.pathSeparator + files(MODULE_PATH).asPath,
  133. ]
  134. }
  135. }
  136. }
  137. publishing {
  138. publications {
  139. POI(MavenPublication) {
  140. pom {
  141. name = 'Apache POI - Common'
  142. description = 'Apache POI - Java API To Access Microsoft Format Files'
  143. }
  144. }
  145. }
  146. }