Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

build.gradle 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import java.util.function.Function
  2. import java.util.regex.Pattern
  3. import java.util.stream.Collectors
  4. /* ====================================================================
  5. Licensed to the Apache Software Foundation (ASF) under one or more
  6. contributor license agreements. See the NOTICE file distributed with
  7. this work for additional information regarding copyright ownership.
  8. The ASF licenses this file to You under the Apache License, Version 2.0
  9. (the "License"); you may not use this file except in compliance with
  10. the License. You may obtain a copy of the License at
  11. http://www.apache.org/licenses/LICENSE-2.0
  12. Unless required by applicable law or agreed to in writing, software
  13. distributed under the License is distributed on an "AS IS" BASIS,
  14. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. See the License for the specific language governing permissions and
  16. limitations under the License.
  17. ==================================================================== */
  18. plugins {
  19. id 'java'
  20. id 'maven-publish'
  21. id 'java-library'
  22. }
  23. final String JAVA9_SRC = 'src/main/java9'
  24. final String JAVA9_OUT = "${buildDir}/classes/java9/main/"
  25. final String VERSIONS9 = 'META-INF/versions/9'
  26. sourceSets {
  27. main {
  28. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  29. output.dir(JAVA9_OUT, builtBy: 'cacheJava9')
  30. }
  31. resources {
  32. srcDirs += project(':poi-ooxml-full').sourceSets.main.output.findAll{it =~ /.*(classes\/java\/main|generated-resources)$/}
  33. }
  34. }
  35. }
  36. dependencies {
  37. api "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}"
  38. implementation project(':poi-ooxml-full')
  39. implementation project(path:':poi-integration', configuration:'tests')
  40. }
  41. final MODULE_NAME = 'org.apache.poi.ooxml.schemas'
  42. final Pattern MODULE_REGEX = ~'\\.jar$'
  43. final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique()
  44. final String OOXML_LITE_REPORT = '../build/ooxml-lite-report'
  45. task compileOoxmlLite() {
  46. dependsOn ':poi-ooxml:build', ':poi-integration:build', ':poi-excelant:build'
  47. File fileIn = file("${OOXML_LITE_REPORT}.clazz")
  48. File fileOut = file("src/main/java9/module-info.java")
  49. outputs.upToDateWhen{
  50. ant.uptodate(property: "ooxmlLiteUnchanged", srcfile: fileIn.path, targetfile: fileOut.path)
  51. ant.properties.ooxmlLiteUnchanged
  52. }
  53. doLast {
  54. String header = fileOut.collect().findAll { !(it =~ /exports|}/) }.join('\n')
  55. // generate module-info based on exported classes
  56. String exports = fileIn.
  57. collect { " exports ${it.replaceAll('[/\\\\][^/\\\\]+$', '').replaceAll('[/\\\\]', '.')};" }.
  58. findAll { !(it =~ /\.impl;$/) }.unique().sort().join('\n')
  59. String content = header + '\n' + exports + '\n}'
  60. if (fileOut.text != content) {
  61. fileOut.write content
  62. }
  63. }
  64. }
  65. java {
  66. sourceCompatibility = JavaVersion.VERSION_1_8
  67. targetCompatibility = JavaVersion.VERSION_1_8
  68. }
  69. compileJava.dependsOn 'compileOoxmlLite'
  70. task compileJava9(type: JavaCompile, dependsOn: 'compileJava') {
  71. sourceCompatibility = 9
  72. targetCompatibility = 9
  73. destinationDirectory = file(JAVA9_OUT + VERSIONS9)
  74. source = file(JAVA9_SRC)
  75. classpath = files()
  76. doFirst {
  77. options.compilerArgs = [
  78. '--patch-module', "${MODULE_NAME}=${project(':poi-ooxml-full').sourceSets.main.output.asPath}",
  79. '--module-path', files(MAIN_MODULE_PATH).asPath
  80. ]
  81. }
  82. }
  83. task cacheJava9(type: Copy, dependsOn: 'compileJava9') {
  84. from(file(JAVA9_OUT + VERSIONS9))
  85. into(JAVA9_SRC)
  86. }
  87. jar {
  88. File clazzFile = file("${OOXML_LITE_REPORT}.clazz")
  89. File xsbsFile = file("${OOXML_LITE_REPORT}.xsb")
  90. if (clazzFile.exists() && xsbsFile.exists()) {
  91. List clazz = clazzFile.collect { "${it}.class" }
  92. List clazzInner = clazzFile.collect { "${it}\$*.class" }
  93. List xsbs = xsbsFile.collect { "org/apache/poi/schemas/ooxml/system/ooxml/${it}.xsb" }
  94. includes = clazz + clazzInner + xsbs + ['META-INF/versions/**', 'org/apache/poi/schemas/ooxml/element/**']
  95. }
  96. destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
  97. if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
  98. into('META-INF/versions/9') {
  99. from JAVA9_SRC include '*.class'
  100. }
  101. }
  102. // ignore second module-info.class from poi-ooxml-full
  103. // duplicatesStrategy = 'exclude'
  104. includeEmptyDirs = false
  105. manifest {
  106. attributes('Automatic-Module-Name' : MODULE_NAME, 'Multi-Release': 'true')
  107. }
  108. }