From 120566991b1dbd19726473cbd68516eb818eb753 Mon Sep 17 00:00:00 2001 From: Marius Volkhart Date: Sun, 14 Mar 2021 20:43:43 +0000 Subject: [PATCH] Change Gradle to use java-library plugin This plugin is specifically built for libraries. The major difference to the regular java plugin is that is allows defining dependencies as part of the api or implementation. Both are used by the project at compile/runtime, but only api dependencies are made available to dependent projects. In our current setup, this doesn't matter much. We deploy to maven central using pre-built POMs. It's more of a future-proofing, and it makes it a little bit clearer which gradle projects actually require which dependencies. git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1887650 13f79535-47bb-0310-9956-ffa450edef68 --- build.gradle | 122 +++++++++++++++++++++------------------------------ 1 file changed, 49 insertions(+), 73 deletions(-) diff --git a/build.gradle b/build.gradle index 6363e71ff5..8d0823c60a 100644 --- a/build.gradle +++ b/build.gradle @@ -85,7 +85,7 @@ allprojects { */ subprojects { //Put instructions for each sub project, but not the master - apply plugin: 'java' + apply plugin: 'java-library' apply plugin: 'jacoco' // See https://github.com/melix/japicmp-gradle-plugin @@ -121,10 +121,10 @@ subprojects { } dependencies { - testCompile "org.junit.jupiter:junit-jupiter:${junitVersion}" - testCompile "org.mockito:mockito-core:${mockitoVersion}" - testCompile "org.hamcrest:hamcrest:${hamcrestVersion}" - testCompile "org.apache.logging.log4j:log4j-core:${log4jVersion}" + testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}" + testImplementation "org.mockito:mockito-core:${mockitoVersion}" + testImplementation "org.hamcrest:hamcrest:${hamcrestVersion}" + testImplementation "org.apache.logging.log4j:log4j-core:${log4jVersion}" } jar { @@ -222,14 +222,14 @@ project('main') { sourceSets.test.resources.srcDirs = ['../../src/resources/test'] dependencies { - compile "commons-codec:commons-codec:${commonsCodecVersion}" - compile 'org.apache.commons:commons-collections4:4.4' - compile "org.apache.commons:commons-math3:${commonsMathVersion}" - compile "org.apache.logging.log4j:log4j-api:${log4jVersion}" - compile 'javax.activation:activation:1.1.1' - compile 'com.zaxxer:SparseBitSet:1.2' + implementation "commons-codec:commons-codec:${commonsCodecVersion}" + implementation 'org.apache.commons:commons-collections4:4.4' + implementation "org.apache.commons:commons-math3:${commonsMathVersion}" + implementation "org.apache.logging.log4j:log4j-api:${log4jVersion}" + implementation 'javax.activation:activation:1.1.1' + api 'com.zaxxer:SparseBitSet:1.2' - testCompile 'org.reflections:reflections:0.9.12' + testImplementation 'org.reflections:reflections:0.9.12' } jar { @@ -298,42 +298,32 @@ project('ooxml') { compileJava.dependsOn 'downloadJarsToLibs' dependencies { - compile "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}" - compile 'org.apache.commons:commons-collections4:4.4' - compile "org.apache.commons:commons-math3:${commonsMathVersion}" - compile "org.apache.commons:commons-compress:${commonsCompressVersion}" - compile 'org.apache.santuario:xmlsec:2.2.1' - compile "org.bouncycastle:bcpkix-jdk15on:${bouncyCastleVersion}" - compile 'com.github.virtuald:curvesapi:1.06' - compile 'com.zaxxer:SparseBitSet:1.2' - compile "org.apache.logging.log4j:log4j-api:${log4jVersion}" - - // compile only, don't add it to our dist as it blows up the size - compile "org.apache.xmlgraphics:batik-svggen:${batikVersion}" - compile("org.apache.xmlgraphics:batik-bridge:${batikVersion}") { + api "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}" + implementation 'org.apache.commons:commons-collections4:4.4' + api "org.apache.commons:commons-compress:${commonsCompressVersion}" + api 'org.apache.santuario:xmlsec:2.2.1' + api "org.bouncycastle:bcpkix-jdk15on:${bouncyCastleVersion}" + api 'com.github.virtuald:curvesapi:1.06' + implementation "org.apache.logging.log4j:log4j-api:${log4jVersion}" + + api "org.apache.xmlgraphics:batik-svggen:${batikVersion}" + implementation("org.apache.xmlgraphics:batik-bridge:${batikVersion}") { exclude group: 'org.apache.xmlgraphics', module: 'batik-script' } - compile "org.apache.xmlgraphics:batik-codec:${batikVersion}" - compile 'xml-apis:xml-apis-ext:1.3.04' - compile 'org.apache.xmlgraphics:xmlgraphics-commons:2.4' + implementation "org.apache.xmlgraphics:batik-codec:${batikVersion}" - compile 'org.apache.pdfbox:pdfbox:2.0.22' - compile 'org.apache.pdfbox:fontbox:2.0.22' - compile 'de.rototor.pdfbox:graphics2d:0.30' + api 'de.rototor.pdfbox:graphics2d:0.30' - // for ooxml-lite, should we move this somewhere else? - compile "org.junit.jupiter:junit-jupiter:${junitVersion}" + api project(':main') + api files("../../build/dist/maven/poi-ooxml-full/poi-ooxml-full-${version}.jar") - compile project(':main') - compile project(':scratchpad') // TODO: get rid of this dependency! - compile files("../../build/dist/maven/poi-ooxml-full/poi-ooxml-full-${version}.jar") - - testCompile 'org.xmlunit:xmlunit-core:2.8.0' - testCompile 'org.reflections:reflections:0.9.12' - testCompile project(path: ':main', configuration: 'tests') - testCompile 'org.openjdk.jmh:jmh-core:1.26' - testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.26' - testCompile 'com.google.guava:guava:30.0-jre' + testRuntime project(':scratchpad') + testImplementation 'org.xmlunit:xmlunit-core:2.8.0' + testImplementation 'org.reflections:reflections:0.9.12' + testImplementation project(path: ':main', configuration: 'tests') + testImplementation 'org.openjdk.jmh:jmh-core:1.26' + testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:1.26' + testImplementation 'com.google.guava:guava:30.0-jre' } jar { @@ -354,16 +344,10 @@ project('examples') { sourceSets.main.java.srcDirs = ['../../src/examples/src'] dependencies { - compile project(':main') - compile project(':ooxml') - compile project(':scratchpad') - - //compile "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}" - compile files("../../lib/ooxml/xmlbeans-${xmlbeansVersion}.jar") - compile "org.apache.logging.log4j:log4j-core:${log4jVersion}" + implementation project(':ooxml') + implementation project(':scratchpad') - compile files("../../build/dist/maven/poi-ooxml-full/poi-ooxml-full-${version}.jar") - compile "org.apache.commons:commons-compress:${commonsCompressVersion}" + implementation "org.apache.logging.log4j:log4j-core:${log4jVersion}" } japicmp.enabled = false @@ -377,12 +361,11 @@ project('excelant') { sourceSets.test.resources.srcDirs = ['../../src/resources/test'] dependencies { - compile 'org.apache.ant:ant:1.10.9' + api 'org.apache.ant:ant:1.10.9' - compile project(':main') - compile project(':ooxml') + api project(':ooxml') - testCompile project(path: ':main', configuration: 'tests') + testImplementation project(path: ':main', configuration: 'tests') } jar { @@ -399,18 +382,13 @@ project('integrationtest') { sourceSets.test.resources.srcDirs = ['../../src/resources/integrationtest'] dependencies { - compile 'org.apache.ant:ant:1.10.9' + testImplementation 'org.apache.ant:ant:1.10.9' - compile project(':main') - compile project(':ooxml') - compile project(':scratchpad') - compile project(':examples') + testImplementation project(':ooxml') + testImplementation project(':scratchpad') + testImplementation project(':examples') - //testCompile "org.apache.xmlbeans:xmlbeans:${xmlbeansVersion}" - testCompile files("../../lib/ooxml/xmlbeans-${xmlbeansVersion}.jar") - - testCompile files("../../build/dist/maven/poi-ooxml-full/poi-ooxml-full-${version}.jar") - testCompile files(this.project(':ooxml').sourceSets.test.runtimeClasspath) + testImplementation files(this.project(':ooxml').sourceSets.test.runtimeClasspath) } jar { @@ -435,14 +413,12 @@ project('scratchpad') { sourceSets.test.resources.srcDirs = ['../../src/resources/test'] dependencies { - compile project(':main') - compile "commons-codec:commons-codec:${commonsCodecVersion}" - compile "org.apache.commons:commons-math3:${commonsMathVersion}" - compile "org.apache.logging.log4j:log4j-api:${log4jVersion}" - - // cyclic-dependency here: compile project(':ooxml') + api project(':main') + implementation "commons-codec:commons-codec:${commonsCodecVersion}" + implementation "org.apache.commons:commons-math3:${commonsMathVersion}" + implementation "org.apache.logging.log4j:log4j-api:${log4jVersion}" - testCompile project(path: ':main', configuration: 'tests') + testImplementation project(path: ':main', configuration: 'tests') } jar { -- 2.39.5