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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 MODULE_NAME = 'org.apache.poi.ooxml.schemas'
  17. final String BEANS_SRC = "${buildDir}/generated-sources"
  18. final String BEANS_RES = "${buildDir}/generated-resources"
  19. sourceSets {
  20. main {
  21. // TypeSystemHolder.class is in the resources
  22. output.dir(BEANS_RES, builtBy: 'generate_beans')
  23. compileClasspath += files(BEANS_RES)
  24. if (jdkVersion > 8) {
  25. output.dir(JAVA9_OUT, builtBy: 'cacheJava9')
  26. }
  27. java {
  28. srcDirs = [BEANS_SRC]
  29. }
  30. }
  31. }
  32. dependencies {
  33. //api "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}"
  34. api files("/Users/pj.fanning/Downloads/xmlbeans-5.1.0.jar")
  35. api "org.apache.logging.log4j:log4j-api:${log4jVersion}"
  36. }
  37. idea {
  38. module {
  39. // Marks the already(!) added srcDir as "generated"
  40. generatedSourceDirs += file(BEANS_SRC)
  41. resourceDirs += file(BEANS_RES)
  42. }
  43. }
  44. final Pattern MODULE_REGEX = ~'\\.jar$'
  45. final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique()
  46. compileJava {
  47. dependsOn 'generate_beans'
  48. options.fork = true
  49. options.forkOptions.jvmArgs << '-Xmx2G'
  50. }
  51. task compileJava9(type: JavaCompile) {
  52. dependsOn 'compileJava'
  53. javaCompiler = javaToolchains.compilerFor {
  54. languageVersion = JavaLanguageVersion.of(jdkVersion)
  55. if (jdkVendor != '') vendor = JvmVendorSpec.matching(jdkVendor)
  56. }
  57. destinationDirectory = file(JAVA9_OUT + VERSIONS9)
  58. source = file(JAVA9_SRC)
  59. classpath = files()
  60. options.compilerArgs = [
  61. '--patch-module', "${MODULE_NAME}=${sourceSets.main.output.asPath}",
  62. '--module-path', files(MAIN_MODULE_PATH).asPath
  63. ]
  64. onlyIf {
  65. jdkVersion > 8
  66. }
  67. }
  68. task cacheJava9(type: Copy) {
  69. dependsOn 'compileJava9'
  70. from(file(JAVA9_OUT + VERSIONS9))
  71. into(JAVA9_SRC)
  72. }
  73. task copy_xsds(type: Copy) {
  74. from ('src/main/xmlschema/org/apache/poi/xdgf')
  75. from ('src/main/xmlschema/org/apache/poi/schemas') {
  76. include 'XAdES*.xsd', '*.xsdconfig', 'xmldsig*.xsd', 'ooxmlSchemas.xsdconfig', 'markup-compatibility.xsd', 'vmlDrawing.xsd'
  77. exclude '*.zip'
  78. }
  79. from ('src/main/xmlschema/org/apache/poi/poifs/crypt') {
  80. include 'signatureInfo.xsd'
  81. }
  82. from (zipTree('src/main/xmlschema/org/apache/poi/schemas/OfficeOpenXML-XMLSchema-Transitional.zip'))
  83. from (zipTree('src/main/xmlschema/org/apache/poi/schemas/OpenPackagingConventions-XMLSchema.zip')) {
  84. include 'opc-digSig.xsd', 'opc-relationships.xsd'
  85. }
  86. into 'build/xsds'
  87. }
  88. task generate_beans(dependsOn: copy_xsds) {
  89. inputs.dir 'build/xsds'
  90. outputs.dir 'build/generated-resources'
  91. doLast {
  92. ant.uptodate(
  93. property: 'xmlbeans_uptodate',
  94. targetfile: 'build/generated-resources/org/apache/poi/schemas/ooxml/system/ooxml/TypeSystemHolder.class'
  95. ) {
  96. srcFiles(dir: 'build/xsds', includes: '*.xsd')
  97. }
  98. ant.taskdef(
  99. name: 'xmlbean',
  100. classname: 'org.apache.xmlbeans.impl.tool.XMLBean',
  101. classpath: sourceSets.main.runtimeClasspath.asPath
  102. )
  103. if (!ant.properties.xmlbeans_uptodate) {
  104. ant.xmlbean(
  105. schema: 'build/xsds',
  106. srcgendir: BEANS_SRC,
  107. classgendir: BEANS_RES,
  108. destfile: 'build/xsds.jar',
  109. srconly: true,
  110. failonerror: true,
  111. fork: true,
  112. memoryMaximumSize: '1536m',
  113. typesystemname: 'ooxml',
  114. repackage: 'org.apache.xmlbeans.metadata:org.apache.poi.schemas.ooxml'
  115. ) {
  116. classpath = sourceSets.main.runtimeClasspath.asPath
  117. }
  118. }
  119. }
  120. }
  121. task sourceJar(type: Jar) {
  122. classifier 'sources'
  123. from sourceSets.main.allJava
  124. }
  125. jar {
  126. dependsOn 'sourceJar'
  127. if (jdkVersion == 8) {
  128. into('META-INF/versions/9') {
  129. from JAVA9_SRC include '*.class'
  130. }
  131. }
  132. manifest {
  133. attributes ('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
  134. }
  135. }
  136. sourcesJar {
  137. metaInf {
  138. from("$projectDir/../legal/LICENSE")
  139. from("$projectDir/../legal/NOTICE")
  140. }
  141. }
  142. publishing {
  143. publications {
  144. POI(MavenPublication) {
  145. pom {
  146. name = 'Apache POI - OOXML schemas (full)'
  147. description =
  148. 'XmlBeans generated from the Ecma supplied xsds (since POI 5.0.0, the 5th edition is used):\n' +
  149. ' https://www.ecma-international.org/publications/standards/Ecma-376.htm'
  150. }
  151. }
  152. }
  153. }
  154. spotbugsTest.enabled = false
  155. spotbugsMain.enabled = false
  156. javadoc.enabled = false
  157. javadocJar.enabled = false