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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.9'
  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. if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
  88. into('META-INF/versions/9') {
  89. from JAVA9_SRC include '*.class'
  90. }
  91. }
  92. manifest {
  93. attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
  94. }
  95. }
  96. // Create a separate jar for test-code to depend on it in other projects
  97. // See http://stackoverflow.com/questions/5144325/gradle-test-dependency
  98. task testJar(type: Jar, dependsOn: testClasses) {
  99. destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}-tests")
  100. classifier 'tests'
  101. // ignore second module-info.class from main
  102. duplicatesStrategy = 'exclude'
  103. if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
  104. into('META-INF/versions/9') {
  105. from TEST9_SRC include '*.class'
  106. }
  107. }
  108. from sourceSets.test.output + sourceSets.main.output
  109. manifest {
  110. attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
  111. }
  112. }
  113. javadoc {
  114. dependsOn configurations.javadocs.dependencies.collect{ ':' + it.dependencyProject.name + ':compileJava' }
  115. doFirst {
  116. options {
  117. classpath += files(configurations.javadocs.dependencies.collect{ it.dependencyProject.sourceSets.main.output.classesDirs })
  118. }
  119. }
  120. }
  121. artifacts {
  122. tests testJar
  123. }
  124. test {
  125. dependsOn { testJar }
  126. doFirst {
  127. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  128. jvmArgs << [
  129. '--add-modules', MODULE_NAME,
  130. '--module-path', '../build/dist/maven/poi-tests:' + files(MODULE_PATH).asPath,
  131. ]
  132. }
  133. }
  134. }
  135. publishing {
  136. publications {
  137. POI(MavenPublication) {
  138. pom {
  139. name = 'Apache POI - Common'
  140. description = 'Apache POI - Java API To Access Microsoft Format Files'
  141. }
  142. }
  143. }
  144. }