Call default behavior of compileJava task when it's been overwritten (Override compileJava task for all Subprojects minus one)

(Alejandro Salas) #1

Hello everyone,

I have a multiproject flat build.

The master build file contains most of the tasks/logic for all subprojects, including an overwritten compileJava task (I’m using delombok + AspectJ).

Today a new project (ProjA) has been added that needs the standard compileJava task, but being a subproject it’s inheriting the overwritten one.

I tried creating a new compileJava task in ProjA so that it worked as a regular one, but when I try setting the task being of type: JavaCompile, I get the error: Could not find property ‘JavaCompile’ on project ‘:ProjA’

I would like if possible to make changes to the build file in ProjA and leave the master build file without specific references to the children. I’m using gradle 1.1.

Thanks in advance for all the help.

(Peter Niederwieser) #2

In Gradle 1.1, the task type is called ‘Compile’. Anyway, it’s almost always better to avoid unwanted work in the first place than to later compensate for it. So I’d either configure ‘subprojects - project(":ProjA")’ to override the task, or I’d move the AspectJ stuff into a separate build script that gets applied in subproject build scripts as necessary.

(Alejandro Salas) #3

Thanks Peter.

I definitely agree with what you say, could you help me led some light in the matter? I’m a bit lost with it. My build contains four projects plus ProjA, all the other four use the overriden compileJava, and I need the regular compile task for ProjA.

Thank you for your help.

(Peter Niederwieser) #4
configure(subprojects - project(":ProjA")) {

For more information, see the “multi-project builds” chapter in the Gradle User Guide.

(Alejandro Salas) #5

I’ve checked the documentation but didn’t know that what you posted was possible. That’s great!.

Thanks a lot for your help! Loving gradle more every day.