diff --git a/build.gradle b/build.gradle index 882df1b6b4..0d4a19df6d 100644 --- a/build.gradle +++ b/build.gradle @@ -59,6 +59,7 @@ ant.taskdef(name: "junit", classname: "org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.JUnitLauncherTask", classpath: configurations.antLibs.asPath) + wrapper { // https://stackoverflow.com/a/54741656/2066598 gradleVersion = '6.8' @@ -79,8 +80,8 @@ wrapper.finalizedBy adjustWrapperPropertiesFile Define properties for all projects, including this one */ allprojects { - apply plugin: 'eclipse' -// apply plugin: 'idea' +// apply plugin: 'eclipse' + apply plugin: 'idea' } /** @@ -133,6 +134,11 @@ subprojects { testImplementation "org.apache.logging.log4j:log4j-core:${log4jVersion}" } + task wrapper(type: Wrapper){ + // https://stackoverflow.com/a/65701523/2066598 + gradleVersion = '6.8' + } + jar { manifest { attributes 'Implementation-Title': 'Apache POI', 'Implementation-Version': project.version diff --git a/poi-ooxml-full/build.gradle b/poi-ooxml-full/build.gradle index b1fd44de93..d79da73deb 100644 --- a/poi-ooxml-full/build.gradle +++ b/poi-ooxml-full/build.gradle @@ -51,6 +51,14 @@ dependencies { 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 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) { ant.xmlbean( schema: 'build/xsds', - srcgendir: 'build/generated-sources', - classgendir: 'build/generated-resources', + srcgendir: BEANS_SRC, + classgendir: BEANS_RES, destfile: 'build/xsds.jar', srconly: true, failonerror: true, diff --git a/poi-ooxml-lite/build.gradle b/poi-ooxml-lite/build.gradle index da40c6d1e8..8dd452f5eb 100644 --- a/poi-ooxml-lite/build.gradle +++ b/poi-ooxml-lite/build.gradle @@ -28,14 +28,20 @@ plugins { final String JAVA9_SRC = 'src/main/java9' final String JAVA9_OUT = "${buildDir}/classes/java9/main/" final String VERSIONS9 = 'META-INF/versions/9' +final String BEANS_SRC = "${buildDir}/generated-sources" +final String BEANS_RES = "${buildDir}/generated-resources" sourceSets { main { if (JavaVersion.current() != JavaVersion.VERSION_1_8) { output.dir(JAVA9_OUT, builtBy: 'cacheJava9') } + compileClasspath += files(BEANS_RES) + java { + srcDirs += BEANS_SRC + } 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 String OOXML_LITE_REPORT = '../build/ooxml-lite-report' -task compileOoxmlLite() { + +task compileOoxmlLite(type: Copy) { dependsOn ':poi-ooxml:build', ':poi-integration:build', ':poi-excelant:build' File fileIn = file("${OOXML_LITE_REPORT}.clazz") @@ -62,6 +69,14 @@ task compileOoxmlLite() { 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 { String header = fileOut.collect().findAll { !(it =~ /exports|}/) }.join('\n')