How to run a Gradle Tasks before building an Intellij Idea Project



I want that a task get executed before the project get build

I’ve now done this:

compileJava.dependsOn generateSomeResourcesTask

All works fine when I run gradle from cmd but when I build the project inside Idea then the generateSomeResourcesTask doesn’t get executed.

(It already works when the generateSomeResourcesTask get executed manually before building the project)

(Dimitar Dimitrov) #2

Right-click the task in IDEAs Gradle view and choose “before zzz”


Is it possible to define this in the build.gradle?

(Andrew Eleneski) #4

Were you able to resolve this in the build.gradle?

(Georg Thomassen) #5

Still no way to do this?


This should be that way to go.

It should be possible to edit the xml from idea that way to set this by default.
But this would only work when doing gradle idea

(Chanjin Park) #7

“Intellij build” is IDE function, not Gradle. so you cannot define any action with it in build.gradle.

Have you tried this?

with this option, Intellij runs gradle ‘build’ task before it builds the project and add gradle build path to classpath when it run the project.