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)

1 Like

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

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

1 Like

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

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

“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.