Uploaded image for project: 'Gradle'
  1. Gradle
  2. GRADLE-1859

overwrite of compileJava task breaks java task ordering for multi-project builds

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Won't Fix
    • Affects Version/s: 1.0-milestone-1, 1.0-milestone-2, 1.0-milestone-3
    • Fix Version/s: None

      Description

      I have a reproducible test case showing that when the "compileJava" task is overwritten then the normal Java task dependencies for multi-project builds is broken. For example, if project "Child" depends on code produced by project "Parent," then project "Child" needs the jar produced by project "Parent" to be present before project "Child" is compiled. When the "compileJava" task is NOT overwritten, then you see the standard order of tasks for java-based multi-project dependencies:

      :project-parent:compileJava
      :project-parent:processResources
      :project-parent:classes
      :project-parent:jar
      :project-child:compileJava

      However, if you overwrite the "compileJava" task (real world use case for this is needing to use an aspectj compiler instead), then the ordering is broken as compilation of project "Child" occurs before the jar is built for project "Parent".

      :project-child:processResources
      :project-child:compileJava
      :project-child:classes
      :project-child:jar
      :project-child:assemble
      :project-parent:processResources
      :project-parent:compileJava
      :project-parent:classes
      :project-parent:jar

      Now obviously this will break a real compilation event when the overwritten "compileJava" task actually performs compilation instead of being stubbed out as in my test case. Regardless of what the contents of the overwritten "compileJava" task is, the order of multi-project Java dependencies should not change. I've added a zip of this test case to demonstrate. And I've pasted in the key files below...

        1. /settings.gradle

      include 'project-child', 'project-parent'

        1. /build.gradle

      subprojects

      { apply from: '<your_path>/override.gradle' }

      dependsOnChildren()

        1. /override.gradle

      apply plugin: 'java'

      task compileJava(dependsOn: JavaPlugin.PROCESS_RESOURCES_TASK_NAME, overwrite: true, description: 'Compile Override') {

      }

        1. /project-child/build.gradle

      dependencies

      { compile project(":project-parent") }
        1. /project-parent/build.gradle

      <no content>

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            botbanky Scott Yancey
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: