You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2022/06/09 09:14:16 UTC
[lucene] branch main updated: Try to fix the gradle compilation in idea (#945)
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/main by this push:
new 54c67db10dd Try to fix the gradle compilation in idea (#945)
54c67db10dd is described below
commit 54c67db10dda52155444b5f28ecc734acad424f5
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Thu Jun 9 11:14:10 2022 +0200
Try to fix the gradle compilation in idea (#945)
* Try to fix the gradle compilation in idea
* Try to detect sync and build phases within intellij and act accordingly to support both modes of compilation (gradle and intellij).
---
gradle/ide/intellij-idea.gradle | 45 +++++++++++++++++++++++++++++++----------
gradle/java/modules.gradle | 4 ++--
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/gradle/ide/intellij-idea.gradle b/gradle/ide/intellij-idea.gradle
index 589aaec3562..f9e7d1d456e 100644
--- a/gradle/ide/intellij-idea.gradle
+++ b/gradle/ide/intellij-idea.gradle
@@ -15,23 +15,46 @@
* limitations under the License.
*/
-// Try to detect IntelliJ model loader ("reimport") early.
-rootProject.ext.isIdea = System.getProperty("idea.active") != null ||
- gradle.startParameter.taskNames.contains('idea') ||
- gradle.startParameter.taskNames.contains('cleanIdea')
+// Try to detect IntelliJ model loader project structure "sync"
+//
+rootProject.ext.isIdea = Boolean.parseBoolean(System.getProperty("idea.active", "false"))
+rootProject.ext.isIdeaSync = Boolean.parseBoolean(System.getProperty("idea.sync.active", "false"))
+rootProject.ext.isIdeaBuild = (isIdea && !isIdeaSync)
if (isIdea) {
logger.warn("IntelliJ Idea IDE detected.")
+
+ allprojects {
+ apply plugin: 'idea'
+
+ idea {
+ module {
+ outputDir file('build/idea/classes/main')
+ testOutputDir file('build/idea/classes/test')
+ downloadSources = true
+ }
+ }
+ }
}
-allprojects {
- apply plugin: 'idea'
+if (isIdeaBuild) {
+ // Skip certain long tasks that are dependencies
+ // of 'assemble' if we're building from within IntelliJ.
+ gradle.taskGraph.whenReady { taskGraph ->
+ def tasks = taskGraph.getAllTasks()
+
+ def skipTasks = [
+ // Skip site javadoc rendering
+ ".*:(renderSiteJavadoc)",
+ ]
- idea {
- module {
- outputDir file('build/idea/classes/main')
- testOutputDir file('build/idea/classes/test')
- downloadSources = true
+ logger.lifecycle("Skipping certain tasks on IntelliJ builds")
+ tasks.each { task ->
+ def taskPath = task.path
+ if (skipTasks.any { pattern -> taskPath ==~ pattern }) {
+ logger.debug("Skipping task on IntelliJ: " + taskPath)
+ task.enabled = false
+ }
}
}
}
diff --git a/gradle/java/modules.gradle b/gradle/java/modules.gradle
index 768bf1a4635..f9ebac3d345 100644
--- a/gradle/java/modules.gradle
+++ b/gradle/java/modules.gradle
@@ -76,7 +76,7 @@ allprojects {
// LUCENE-10304: if we modify the classpath here, IntelliJ no longer sees the dependencies as compile-time
// dependencies, don't know why.
- if (!rootProject.ext.isIdea) {
+ if (!rootProject.ext.isIdeaSync) {
task.classpath = modularPaths.compilationClasspath
}
@@ -119,7 +119,7 @@ allprojects {
// LUCENE-10304: if we modify the classpath here, IntelliJ no longer sees the dependencies as compile-time
// dependencies, don't know why.
- if (!rootProject.ext.isIdea) {
+ if (!rootProject.ext.isIdeaSync) {
def jarTask = project.tasks.getByName(mainSourceSet.getJarTaskName())
def testJarTask = project.tasks.getByName(testSourceSet.getJarTaskName())