Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

build.gradle 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. runtimeClasspath {
  18. exclude group: 'xalan', module: 'xalan'
  19. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  20. exclude group: 'xml-apis', module: 'xml-apis'
  21. }
  22. }
  23. compileClasspath {
  24. exclude group: 'xalan', module: 'xalan'
  25. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  26. exclude group: 'xml-apis', module: 'xml-apis'
  27. }
  28. }
  29. broken
  30. tests
  31. javadocs
  32. }
  33. sourceSets {
  34. main {
  35. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  36. output.dir(JAVA9_OUT, builtBy: 'cacheJava9')
  37. }
  38. }
  39. test {
  40. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  41. output.dir(TEST9_OUT, builtBy: 'cacheTest9')
  42. }
  43. }
  44. }
  45. java {
  46. registerFeature('signing') {
  47. usingSourceSet(sourceSets.main)
  48. }
  49. registerFeature('render') {
  50. usingSourceSet(sourceSets.main)
  51. }
  52. registerFeature('rendersign') {
  53. usingSourceSet(sourceSets.main)
  54. }
  55. }
  56. dependencies {
  57. api project(':poi')
  58. api project(':poi-ooxml-full')
  59. api project(path: ':poi-ooxml-full', configuration: 'archives')
  60. api "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}"
  61. api "org.apache.commons:commons-compress:${commonsCompressVersion}"
  62. api "commons-io:commons-io:${commonsIoVersion}"
  63. api 'com.github.virtuald:curvesapi:1.06'
  64. api "org.apache.logging.log4j:log4j-api:${log4jVersion}"
  65. api 'org.apache.commons:commons-collections4:4.4'
  66. signingImplementation 'org.apache.santuario:xmlsec:2.2.3'
  67. signingImplementation "org.bouncycastle:bcpkix-jdk15on:${bouncyCastleVersion}"
  68. signingImplementation "org.bouncycastle:bcutil-jdk15on:${bouncyCastleVersion}"
  69. rendersignImplementation 'org.apache.santuario:xmlsec:2.2.3'
  70. rendersignImplementation "org.bouncycastle:bcpkix-jdk15on:${bouncyCastleVersion}"
  71. rendersignImplementation "org.bouncycastle:bcutil-jdk15on:${bouncyCastleVersion}"
  72. renderImplementation 'de.rototor.pdfbox:graphics2d:0.32'
  73. renderImplementation "org.apache.xmlgraphics:batik-svggen:${batikVersion}"
  74. renderImplementation("org.apache.xmlgraphics:batik-svgrasterizer:${batikVersion}") {
  75. exclude group: 'xalan', module: 'xalan'
  76. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  77. exclude group: 'xml-apis', module: 'xml-apis'
  78. }
  79. }
  80. renderImplementation("org.apache.xmlgraphics:batik-codec:${batikVersion}") {
  81. exclude group: 'xalan', module: 'xalan'
  82. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  83. exclude group: 'xml-apis', module: 'xml-apis'
  84. }
  85. }
  86. renderImplementation("org.apache.xmlgraphics:batik-bridge:${batikVersion}") {
  87. exclude group: 'xalan', module: 'xalan'
  88. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  89. exclude group: 'xml-apis', module: 'xml-apis'
  90. }
  91. }
  92. rendersignImplementation 'de.rototor.pdfbox:graphics2d:0.32'
  93. rendersignImplementation "org.apache.xmlgraphics:batik-svggen:${batikVersion}"
  94. rendersignImplementation("org.apache.xmlgraphics:batik-svgrasterizer:${batikVersion}") {
  95. exclude group: 'xalan', module: 'xalan'
  96. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  97. exclude group: 'xml-apis', module: 'xml-apis'
  98. }
  99. }
  100. rendersignImplementation("org.apache.xmlgraphics:batik-codec:${batikVersion}") {
  101. exclude group: 'xalan', module: 'xalan'
  102. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  103. exclude group: 'xml-apis', module: 'xml-apis'
  104. }
  105. }
  106. rendersignImplementation("org.apache.xmlgraphics:batik-bridge:${batikVersion}") {
  107. exclude group: 'xalan', module: 'xalan'
  108. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  109. exclude group: 'xml-apis', module: 'xml-apis'
  110. }
  111. }
  112. if (!NO_SCRATCHPAD) {
  113. testImplementation project(':poi-scratchpad')
  114. testImplementation project(path:':poi-scratchpad', configuration:'tests')
  115. }
  116. testImplementation project(path:':poi', configuration:'tests')
  117. testImplementation project(path:':poi-ooxml-lite-agent', configuration: 'archives')
  118. testImplementation 'org.xmlunit:xmlunit-core:2.8.2'
  119. testImplementation 'org.reflections:reflections:0.9.12'
  120. testImplementation 'org.openjdk.jmh:jmh-core:1.32'
  121. testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:1.32'
  122. testImplementation 'com.google.guava:guava:30.1.1-jre'
  123. testImplementation 'org.tukaani:xz:1.9'
  124. // prevent slf4j warnings coming from xmlsec -> slf4j-api 1.7.32 dependency
  125. // see https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/
  126. testImplementation "org.apache.logging.log4j:log4j-slf4j18-impl:${log4jVersion}"
  127. broken("org.apache.xmlgraphics:batik-script:${batikVersion}"){
  128. exclude group: 'xalan', module: 'xalan'
  129. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  130. exclude group: 'xml-apis', module: 'xml-apis'
  131. }
  132. }
  133. javadocs project(':poi')
  134. javadocs project(':poi-scratchpad')
  135. }
  136. final String MODULE_NAME = 'org.apache.poi.ooxml'
  137. final Pattern MODULE_NOT_REGEX = ~'(poi[/\\\\][^/\\\\]+$|batik-script)'
  138. final Pattern MODULE_REGEX = ~'\\.jar$'
  139. final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique()
  140. final List TEST_MODULE_PATH = sourceSets.test.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX && !(it.path =~ MODULE_NOT_REGEX) }.collect{ it.parent }.unique() + files("build/brokenJars")
  141. final String OOXML_LITE_AGENT = "../build/dist/maven/poi-ooxml-lite-agent/poi-ooxml-lite-agent-${project.version}.jar"
  142. final String OOXML_LITE_REPORT = '../build/ooxml-lite-report'
  143. final String OOXML_LITE_INCLUDES = "^(com/microsoft/schemas|org/(etsi|openxmlformats|w3/)|org/apache/poi/schemas)"
  144. compileJava {
  145. dependsOn 'fixBatik'
  146. }
  147. task compileJava9(type: JavaCompile) {
  148. dependsOn 'compileJava', ':poi:jar'
  149. sourceCompatibility = 9
  150. targetCompatibility = 9
  151. destinationDirectory = file(JAVA9_OUT + VERSIONS9)
  152. source = file(JAVA9_SRC)
  153. classpath = files()
  154. options.compilerArgs = [
  155. '--patch-module', "${MODULE_NAME}=${sourceSets.main.output.classesDirs.asPath}",
  156. '--module-path', files(MAIN_MODULE_PATH).asPath
  157. ]
  158. }
  159. task cacheJava9(type: Copy) {
  160. dependsOn 'compileJava9'
  161. from(file(JAVA9_OUT + VERSIONS9))
  162. into(JAVA9_SRC)
  163. }
  164. task compileTest9(type: JavaCompile) {
  165. dependsOn 'compileTestJava', ':poi:testJar'
  166. sourceCompatibility = 9
  167. targetCompatibility = 9
  168. destinationDirectory = file(TEST9_OUT + VERSIONS9)
  169. source = file(TEST9_SRC)
  170. options.compilerArgs = [
  171. '--patch-module', "${MODULE_NAME}=${(sourceSets.main.output.classesDirs + sourceSets.test.output.classesDirs).asPath}",
  172. '--module-path', files(TEST_MODULE_PATH).asPath
  173. ]
  174. classpath = files()
  175. }
  176. task cacheTest9(type: Copy) {
  177. dependsOn 'compileTest9'
  178. from(file(TEST9_OUT + VERSIONS9))
  179. into(TEST9_SRC)
  180. }
  181. jar {
  182. destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
  183. if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
  184. into('META-INF/versions/9') {
  185. from JAVA9_SRC include '*.class'
  186. }
  187. }
  188. manifest {
  189. attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
  190. }
  191. }
  192. // Create a separate jar for test-code to depend on it in other projects
  193. // See http://stackoverflow.com/questions/5144325/gradle-test-dependency
  194. task testJar(type: Jar, dependsOn: testClasses) {
  195. destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}-tests")
  196. classifier 'tests'
  197. // ignore second module-info.class from main
  198. duplicatesStrategy = 'exclude'
  199. if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
  200. into('META-INF/versions/9') {
  201. from TEST9_SRC include '*.class'
  202. }
  203. }
  204. from sourceSets.test.output + sourceSets.main.output
  205. manifest {
  206. attributes('Automatic-Module-Name': MODULE_NAME, 'Multi-Release': 'true')
  207. }
  208. }
  209. // based on https://github.com/moditect/moditect-gradle-plugin/issues/12
  210. task fixBatik(type: Zip) {
  211. ant.mkdir(dir: "${buildDir}/brokenJars")
  212. archiveFileName = "batik-script-${batikVersion}.jar"
  213. destinationDirectory = file("${buildDir}/brokenJars")
  214. from zipTree(configurations.broken.files.find{ f -> f.name.startsWith("batik-script") })
  215. filesMatching("**/org.apache.batik.script.InterpreterFactory") {
  216. it.filter{ it2 -> it2.contains("Rhino") ? "#" + it2 : it2 }
  217. }
  218. }
  219. javadoc {
  220. failOnError = true
  221. doFirst {
  222. options {
  223. if (JavaVersion.current().isJava9Compatible()) {
  224. addBooleanOption('html5', true)
  225. }
  226. links 'https://poi.apache.org/apidocs/dev/'
  227. links 'https://docs.oracle.com/javase/8/docs/api/'
  228. use = true
  229. splitIndex = true
  230. source = "1.8"
  231. classpath += configurations.javadocs.files
  232. }
  233. }
  234. }
  235. artifacts {
  236. tests testJar
  237. }
  238. test {
  239. // for some reason catching the OOM does not work when run from Gradle
  240. exclude '**/MemoryUsage.class'
  241. dependsOn { testJar }
  242. systemProperties['junit.jupiter.execution.parallel.enabled'] = 'true'
  243. if (NO_SCRATCHPAD) {
  244. useJUnitPlatform {
  245. excludeTags 'scratchpad.ignore'
  246. }
  247. }
  248. doFirst {
  249. jvmArgs += [
  250. "-javaagent:${OOXML_LITE_AGENT}=${OOXML_LITE_REPORT}|${OOXML_LITE_INCLUDES}",
  251. ]
  252. if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
  253. jvmArgs += [
  254. '--add-modules', MODULE_NAME,
  255. '--module-path', '../build/dist/maven/poi-ooxml-tests' + File.pathSeparator + files(TEST_MODULE_PATH).asPath,
  256. ]
  257. }
  258. }
  259. }
  260. publishing {
  261. publications {
  262. POI(MavenPublication) {
  263. pom {
  264. name = 'Apache POI - API based on OPC and OOXML schemas'
  265. description = 'Apache POI - Java API To Access Microsoft Format Files'
  266. }
  267. suppressPomMetadataWarningsFor('renderApiElements')
  268. suppressPomMetadataWarningsFor('renderRuntimeElements')
  269. suppressPomMetadataWarningsFor('signingApiElements')
  270. suppressPomMetadataWarningsFor('signingRuntimeElements')
  271. suppressPomMetadataWarningsFor('rendersignApiElements')
  272. suppressPomMetadataWarningsFor('rendersignRuntimeElements')
  273. }
  274. }
  275. }