選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

build.gradle 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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. buildscript {
  16. repositories {
  17. maven { url "https://plugins.gradle.org/m2/" }
  18. }
  19. dependencies {
  20. classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.1.2' // 2.x requires Gradle >=4
  21. classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5"
  22. }
  23. }
  24. repositories {
  25. mavenCentral()
  26. }
  27. // Only add the plugin for Sonar if enabled
  28. if (project.hasProperty('enableSonar')) {
  29. println 'Enabling Sonar support'
  30. apply plugin: "org.sonarqube"
  31. }
  32. // For help converting an Ant build to a Gradle build, see
  33. // https://docs.gradle.org/current/userguide/ant.html
  34. configurations {
  35. antLibs
  36. }
  37. dependencies {
  38. antLibs("junit:junit:4.12")
  39. antLibs("org.apache.ant:ant-junit:1.10.4")
  40. antLibs("org.apache.ant:ant-junit4:1.10.4")
  41. }
  42. ant.taskdef(name: "junit",
  43. classname: "org.apache.tools.ant.taskdefs.optional.junit.JUnitTask",
  44. classpath: configurations.antLibs.asPath)
  45. ant.importBuild 'build.xml'
  46. /**
  47. Define properties for all projects, including this one
  48. */
  49. allprojects {
  50. apply plugin: 'eclipse'
  51. task wrapper(type: Wrapper) {
  52. gradleVersion = '4.6'
  53. }
  54. task adjustWrapperPropertiesFile {
  55. doLast {
  56. ant.replaceregexp(match:'^#.*', replace:'', flags:'g', byline:true) {
  57. fileset(dir: project.projectDir, includes: 'gradle/wrapper/gradle-wrapper.properties')
  58. }
  59. new File(project.projectDir, 'gradle/wrapper/gradle-wrapper.properties').with { it.text = it.readLines().findAll { it }.sort().join('\n') }
  60. ant.fixcrlf(file: 'gradle/wrapper/gradle-wrapper.properties', eol: 'lf')
  61. }
  62. }
  63. wrapper.finalizedBy adjustWrapperPropertiesFile
  64. }
  65. /**
  66. Define things that are only necessary in sub-projects, but not in the master-project itself
  67. */
  68. subprojects {
  69. //Put instructions for each sub project, but not the master
  70. apply plugin: 'java'
  71. apply plugin: 'jacoco'
  72. // See https://github.com/melix/japicmp-gradle-plugin
  73. apply plugin: 'me.champeau.gradle.japicmp'
  74. version = '4.0.0-SNAPSHOT'
  75. ext {
  76. japicmpversion = '3.17'
  77. }
  78. tasks.withType(JavaCompile) {
  79. options.encoding = 'UTF-8'
  80. }
  81. sourceCompatibility = 1.8
  82. repositories {
  83. mavenCentral()
  84. }
  85. jar {
  86. manifest {
  87. attributes 'Implementation-Title': 'Apache POI', 'Implementation-Version': version
  88. }
  89. }
  90. test {
  91. // Exclude some tests that are not actually tests or do not run cleanly on purpose
  92. exclude '**/BaseTestBorderStyle.class'
  93. exclude '**/BaseTestCellUtil.class'
  94. exclude '**/TestUnfixedBugs.class'
  95. exclude '**/TestOneFile.class'
  96. // set heap size for the test JVM(s)
  97. minHeapSize = "128m"
  98. maxHeapSize = "768m"
  99. // Specifying the local via system properties did not work, so we set them this way
  100. jvmArgs '-Duser.language=en -Duser.country=US'
  101. // show standard out and standard error of the test JVM(s) on the console
  102. //testLogging.showStandardStreams = true
  103. // http://forums.gradle.org/gradle/topics/jacoco_related_failure_in_multiproject_build
  104. systemProperties['user.dir'] = workingDir
  105. systemProperties['POI.testdata.path'] = '../../test-data'
  106. }
  107. jacoco {
  108. toolVersion = '0.7.9'
  109. }
  110. // ensure the build-dir exists
  111. projectDir.mkdirs()
  112. if (project.hasProperty('enableSonar')) {
  113. sonarqube {
  114. properties {
  115. // as we currently use build/<module>/ as project-basedir, we need to tell Sonar to use
  116. // the root-folder as "basedir" for the projects
  117. property "sonar.projectBaseDir", "$projectDir/../.."
  118. }
  119. }
  120. }
  121. // japicmp will fail with "Could not load" because we moved some classes out of the root-package
  122. // for Java 9 compatibility in 4.0.0
  123. task(japicmp, type: me.champeau.gradle.ArtifactJapicmpTask, dependsOn: jar) {
  124. to = jar.archivePath
  125. onlyModified = true
  126. onlyBinaryIncompatibleModified = true
  127. failOnModification = false
  128. txtOutputFile = file("$buildDir/reports/japi.txt")
  129. htmlOutputFile = file("$buildDir/reports/japi.html")
  130. }
  131. }
  132. project('main') {
  133. sourceSets.main.java.srcDirs = ['../../src/java']
  134. sourceSets.main.resources.srcDirs = ['../../src/resources/main']
  135. sourceSets.test.java.srcDirs = ['../../src/testcases']
  136. dependencies {
  137. compile 'commons-codec:commons-codec:1.11'
  138. compile 'commons-logging:commons-logging:1.2'
  139. compile 'org.apache.commons:commons-collections4:4.2'
  140. compile 'org.apache.commons:commons-math3:3.6.1'
  141. testCompile 'junit:junit:4.12'
  142. }
  143. jar {
  144. manifest {
  145. attributes 'Automatic-Module-Name': 'org.apache.poi.main'
  146. }
  147. }
  148. // Create a separate jar for test-code to depend on it in other projects
  149. // See http://stackoverflow.com/questions/5144325/gradle-test-dependency
  150. task testJar(type: Jar, dependsOn: testClasses) {
  151. baseName = "test-${project.archivesBaseName}"
  152. from sourceSets.test.output
  153. }
  154. configurations {
  155. tests
  156. }
  157. artifacts {
  158. tests testJar
  159. }
  160. japicmp.baseline = 'org.apache.poi:poi:' + japicmpversion + '@jar'
  161. }
  162. project('ooxml') {
  163. sourceSets.main.java.srcDirs = ['../../src/ooxml/java']
  164. sourceSets.main.resources.srcDirs = ['../../src/ooxml/resources', '../../src/resources/ooxml']
  165. sourceSets.test.java.srcDirs = ['../../src/ooxml/testcases']
  166. // for now import the ant-task for building the jars from build.xml
  167. // we need to rename the tasks as e.g. task "jar" conflicts with :ooxml:jar
  168. ant.importBuild('../../build.xml') { antTargetName ->
  169. 'ant-' + antTargetName
  170. }
  171. compileJava.dependsOn 'ant-compile-ooxml-xsds'
  172. dependencies {
  173. compile 'org.apache.xmlbeans:xmlbeans:3.0.0'
  174. compile 'org.apache.commons:commons-collections4:4.2'
  175. compile 'org.apache.commons:commons-math3:3.6.1'
  176. compile 'org.apache.commons:commons-compress:1.17'
  177. compile 'org.apache.santuario:xmlsec:2.1.0'
  178. compile 'org.bouncycastle:bcpkix-jdk15on:1.59'
  179. compile 'com.github.virtuald:curvesapi:1.05'
  180. // for ooxml-lite, should we move this somewhere else?
  181. compile 'junit:junit:4.12'
  182. compile project(':main')
  183. compile project(':scratchpad') // TODO: get rid of this dependency!
  184. compile files('../../ooxml-lib/ooxml-schemas-1.4.jar')
  185. compile files('../../ooxml-lib/ooxml-security-1.1.jar')
  186. testCompile 'junit:junit:4.12'
  187. testCompile 'org.mockito:mockito-core:2.13.0'
  188. testCompile 'org.xmlunit:xmlunit-core:2.5.1'
  189. testCompile project(path: ':main', configuration: 'tests')
  190. testCompile 'org.openjdk.jmh:jmh-core:1.19'
  191. testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.19'
  192. }
  193. jar {
  194. manifest {
  195. attributes 'Automatic-Module-Name': 'org.apache.poi.ooxml'
  196. }
  197. }
  198. japicmp.baseline = 'org.apache.poi:poi-ooxml:' + japicmpversion + '@jar'
  199. }
  200. project('examples') {
  201. sourceSets.main.java.srcDirs = ['../../src/examples/src']
  202. dependencies {
  203. compile project(':main')
  204. compile project(':ooxml')
  205. }
  206. japicmp.enabled = false
  207. }
  208. project('excelant') {
  209. sourceSets.main.java.srcDirs = ['../../src/excelant/java']
  210. sourceSets.main.resources.srcDirs = ['../../src/excelant/resources']
  211. sourceSets.test.java.srcDirs = ['../../src/excelant/testcases']
  212. dependencies {
  213. compile 'org.apache.ant:ant:1.10.4'
  214. compile project(':main')
  215. compile project(':ooxml')
  216. testCompile project(path: ':main', configuration: 'tests')
  217. }
  218. jar {
  219. manifest {
  220. attributes 'Automatic-Module-Name': 'org.apache.poi.excelant'
  221. }
  222. }
  223. japicmp.baseline = 'org.apache.poi:poi-excelant:' + japicmpversion + '@jar'
  224. }
  225. project('integrationtest') {
  226. sourceSets.test.java.srcDirs = ['../../src/integrationtest']
  227. dependencies {
  228. compile 'org.apache.ant:ant:1.10.4'
  229. compile project(':main')
  230. compile project(':ooxml')
  231. compile project(':scratchpad')
  232. compile project(':examples')
  233. testCompile 'junit:junit:4.12'
  234. }
  235. jar {
  236. manifest {
  237. attributes 'Automatic-Module-Name': 'org.apache.poi.integrationtest'
  238. }
  239. }
  240. test {
  241. // exclude these from the normal test-run
  242. exclude '**/TestAllFiles.class'
  243. exclude '**/*FileHandler.class'
  244. exclude '**/RecordsStresser.class'
  245. }
  246. task integrationTest(type: Test) {
  247. // these are just tests used during development of more test-code
  248. exclude '**/*FileHandler.class'
  249. exclude '**/RecordStresser.class'
  250. }
  251. japicmp.enabled = false
  252. }
  253. project('scratchpad') {
  254. sourceSets.main.java.srcDirs = ['../../src/scratchpad/src']
  255. sourceSets.main.resources.srcDirs = ['../../src/resources/scratchpad']
  256. sourceSets.test.java.srcDirs = ['../../src/scratchpad/testcases']
  257. dependencies {
  258. compile project(':main')
  259. // cyclic-dependency here: compile project(':ooxml')
  260. testCompile 'junit:junit:4.12'
  261. testCompile project(path: ':main', configuration: 'tests')
  262. }
  263. jar {
  264. manifest {
  265. attributes 'Automatic-Module-Name': 'org.apache.poi.scratchpad'
  266. }
  267. }
  268. japicmp.baseline = 'org.apache.poi:poi-scratchpad:' + japicmpversion + '@jar'
  269. }