]> source.dussan.org Git - poi.git/commitdiff
fix gradle builds to better comply with IntelliJ
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 18 Apr 2021 22:11:26 +0000 (22:11 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 18 Apr 2021 22:11:26 +0000 (22:11 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1888936 13f79535-47bb-0310-9956-ffa450edef68

build.gradle
poi-ooxml-full/build.gradle
poi-ooxml-lite/build.gradle

index 882df1b6b4146e9accc16b4aa9b04e4665f1cc7e..0d4a19df6d27fd9e95e1343bbe277181e6ad5364 100644 (file)
@@ -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
index b1fd44de939623c9f7d5497cacc9f5c7899f0aab..d79da73deb36a1833a0af2638bee27c73372c3ef 100644 (file)
@@ -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,
index da40c6d1e8d56479ee797884c2ab12633fb1acee..8dd452f5eb82fd4eb4d522c762f24833fdedb77c 100644 (file)
@@ -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')