fix gradle builds to better comply with IntelliJ

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1888936 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2021-04-18 22:11:26 +00:00
parent 9392b464e3
commit 27e0842bcc
3 changed files with 35 additions and 6 deletions

View File

@ -59,6 +59,7 @@ ant.taskdef(name: "junit",
classname: "org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.JUnitLauncherTask", classname: "org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.JUnitLauncherTask",
classpath: configurations.antLibs.asPath) classpath: configurations.antLibs.asPath)
wrapper { wrapper {
// https://stackoverflow.com/a/54741656/2066598 // https://stackoverflow.com/a/54741656/2066598
gradleVersion = '6.8' gradleVersion = '6.8'
@ -79,8 +80,8 @@ wrapper.finalizedBy adjustWrapperPropertiesFile
Define properties for all projects, including this one Define properties for all projects, including this one
*/ */
allprojects { allprojects {
apply plugin: 'eclipse' // apply plugin: 'eclipse'
// apply plugin: 'idea' apply plugin: 'idea'
} }
/** /**
@ -133,6 +134,11 @@ subprojects {
testImplementation "org.apache.logging.log4j:log4j-core:${log4jVersion}" testImplementation "org.apache.logging.log4j:log4j-core:${log4jVersion}"
} }
task wrapper(type: Wrapper){
// https://stackoverflow.com/a/65701523/2066598
gradleVersion = '6.8'
}
jar { jar {
manifest { manifest {
attributes 'Implementation-Title': 'Apache POI', 'Implementation-Version': project.version attributes 'Implementation-Title': 'Apache POI', 'Implementation-Version': project.version

View File

@ -51,6 +51,14 @@ dependencies {
runtimeOnly "org.apache.logging.log4j:log4j-core:${log4jVersion}" runtimeOnly "org.apache.logging.log4j:log4j-core:${log4jVersion}"
} }
idea {
module {
// Marks the already(!) added srcDir as "generated"
generatedSourceDirs += file(BEANS_SRC)
resourceDirs += file(BEANS_RES)
}
}
final Pattern MODULE_REGEX = ~'\\.jar$' final Pattern MODULE_REGEX = ~'\\.jar$'
final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique() final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique()
@ -119,8 +127,8 @@ task generate_beans(dependsOn: copy_xsds) {
if (!ant.properties.xmlbeans_uptodate) { if (!ant.properties.xmlbeans_uptodate) {
ant.xmlbean( ant.xmlbean(
schema: 'build/xsds', schema: 'build/xsds',
srcgendir: 'build/generated-sources', srcgendir: BEANS_SRC,
classgendir: 'build/generated-resources', classgendir: BEANS_RES,
destfile: 'build/xsds.jar', destfile: 'build/xsds.jar',
srconly: true, srconly: true,
failonerror: true, failonerror: true,

View File

@ -28,14 +28,20 @@ plugins {
final String JAVA9_SRC = 'src/main/java9' final String JAVA9_SRC = 'src/main/java9'
final String JAVA9_OUT = "${buildDir}/classes/java9/main/" final String JAVA9_OUT = "${buildDir}/classes/java9/main/"
final String VERSIONS9 = 'META-INF/versions/9' final String VERSIONS9 = 'META-INF/versions/9'
final String BEANS_SRC = "${buildDir}/generated-sources"
final String BEANS_RES = "${buildDir}/generated-resources"
sourceSets { sourceSets {
main { main {
if (JavaVersion.current() != JavaVersion.VERSION_1_8) { if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
output.dir(JAVA9_OUT, builtBy: 'cacheJava9') output.dir(JAVA9_OUT, builtBy: 'cacheJava9')
} }
compileClasspath += files(BEANS_RES)
java {
srcDirs += BEANS_SRC
}
resources { resources {
srcDirs += project(':poi-ooxml-full').sourceSets.main.output.findAll{it =~ /.*(classes\/java\/main|generated-resources)$/} srcDirs += BEANS_RES
} }
} }
} }
@ -51,7 +57,8 @@ final Pattern MODULE_REGEX = ~'\\.jar$'
final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique() final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique()
final String OOXML_LITE_REPORT = '../build/ooxml-lite-report' final String OOXML_LITE_REPORT = '../build/ooxml-lite-report'
task compileOoxmlLite() {
task compileOoxmlLite(type: Copy) {
dependsOn ':poi-ooxml:build', ':poi-integration:build', ':poi-excelant:build' dependsOn ':poi-ooxml:build', ':poi-integration:build', ':poi-excelant:build'
File fileIn = file("${OOXML_LITE_REPORT}.clazz") File fileIn = file("${OOXML_LITE_REPORT}.clazz")
@ -62,6 +69,14 @@ task compileOoxmlLite() {
ant.properties.ooxmlLiteUnchanged ant.properties.ooxmlLiteUnchanged
} }
// copy re-/sources to modules own directory to pacify IntelliJ, which doesn't like the same source dir in multiple modules
from(project(':poi-ooxml-full').buildDir) {
include 'generated-sources/**'
include 'generated-resources/**'
include 'classes/java/main/**'
}
into(buildDir)
doLast { doLast {
String header = fileOut.collect().findAll { !(it =~ /exports|}/) }.join('\n') String header = fileOut.collect().findAll { !(it =~ /exports|}/) }.join('\n')