Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What command does Intellij Gradle project refresh execute

Intellij hides which gradle command it runs whenver you press a button to do something with gradle. That makes it extremely difficult to find out what goes wrong. I am clicking "refresh" (NOT REFRESH DEPENDENCIES), and it seems to trigger all my sibling projects AND my project to build which is wrong. It is definitely not running "gradle build" because if it did, it would not trigger all the sibling projects in my multi-project build.

like image 955
Calicoder Avatar asked Sep 13 '25 11:09

Calicoder


1 Answers

Clicking "refresh" in gradle shows a log like this:

2019-10-17 14:58:10,391 [9949323]   INFO - xecution.GradleExecutionHelper - Passing command-line args to Gradle Tooling API: -Didea.sync.active=true -Didea.resolveSourceSetDependencies=true --init-script /tmp/ijinit.gradle

Here IDEA is using the Gradle Tooling API and using a gradle init script (in /tmp/ijinit.gradle on my machine). The file shows more:

$ cat /tmp/ijinit.gradle

...imports etc...

initscript {
  dependencies {
    classpath files([...list of IDEA jars...])
  }
}

apply plugin: JetGradlePlugin

class JetGradlePlugin implements Plugin<Gradle> {
  void apply(Gradle gradle) {
    def processor = new RegistryProcessor()
    gradle.addProjectEvaluationListener(processor)
    def projectEvaluationIsNotCalledForIncludedBuilds = GradleVersion.current() >= GradleVersion.version("3.1") &&
                                                        GradleVersion.current() < GradleVersion.version("4.0")
    if (projectEvaluationIsNotCalledForIncludedBuilds) {
      gradle.rootProject {
        it.afterEvaluate {
          gradle.includedBuilds.each { included ->
            // included builds should be configured by now, so calling `configuredBuild` should be safe
            def toolingRegistry = (ToolingModelBuilderRegistry)included.configuredBuild.services.get(ToolingModelBuilderRegistry.class)
            processor.process(toolingRegistry)
          }
        }
      }
    }
  }
}
...other overrides...

As others mentioned the included builds can be excluded in the IDEA Gradle tab but hopefully this answers the specific title question.

like image 72
neilyalowitz Avatar answered Sep 15 '25 08:09

neilyalowitz