i'm currently working on configuring a remote buil...
# gradle
d
i'm currently working on configuring a remote build cache for our gradle build. it seems like when I run
./gradlew test
from a command line, i see the cache being used for everything including tests, but if I use intellij to run the same gradle task the cache is not respected, is that something others have come across
v
Are you running the Gradle task, or are you running the test with delegation to Gradle enabled?
d
i'm running the task
s
I am not sure if it is still the case but I have previously observed that IDEA pulls down new dependencies again even after running on the commandline first so I think it runs a gradle in a separate environment somehow
v
Shouldn't be the case. Except maybe if you use a different Java version.
Which could actually also the problem of OP
d
so i've noticed that non-test tasks are hitting the cache in intellij; but it seems like the test tasks themselves are not
v
Probably because of this init script applied when you run a task from IntelliJ:
Copy code
String[] ijTestIncludes = ['*']

Class abstractTestTaskClass = null
try {
  abstractTestTaskClass = Class.forName("org.gradle.api.tasks.testing.AbstractTestTask")
} catch (ClassNotFoundException ex) {
 // ignore, class not available
}

gradle.taskGraph.whenReady { taskGraph ->
  taskGraph.allTasks.each { Task task ->
    if (task instanceof Test || (abstractTestTaskClass != null && abstractTestTaskClass.isAssignableFrom(task.class))) {
      try {
        task.outputs.upToDateWhen { false }
        String[] strings = ['*']
        if(ijTestIncludes != strings) {
          def filter = task.getFilter()
          filter.setIncludePatterns(new String[0])
          ijTestIncludes.each(){ filter.includeTestsMatching "${it}" }
        }
      }
      catch (all) {
        logger.error("", all)
      }
    }
  }
}
d
that makes total sense; did you already know that was there or did you find it? either way thanks so much
v
I knew there were init scripts that they use like most tool integrations do. I just looked up what exactly is in there.