spring-boot: bootRepackage depends on EAR plugin task causing circular dependencies between tasks

Build configured to run tasks in the following order war->bootRepackage->ear.

Relevant gradle build configuration:

war {
............
}

bootRepackage {
    withJarTask war
}

dependencies {
    deploy files(bootRepackage)
}

ear {
    deploymentDescriptor {
        displayName = project.name
        webModule(war.archiveName, '/service')
    }

}

The issue happens in such configuration due to circular dependencies between bootRepackage and EAR tasks.

The next code snippet registers archive task deps as default dependencies:

https://github.com/spring-projects/spring-boot/blob/master/spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/repackage/RepackagePluginFeatures.java

TaskDependency runtimeProjectDependencyJarTasks = runtimeConfiguration
                .getTaskDependencyFromProjectDependency(true, JavaPlugin.JAR_TASK_NAME);
        task.dependsOn(
                project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION)
                        .getAllArtifacts().getBuildDependencies(),
                runtimeProjectDependencyJarTasks);

The above code causes bootRepackage to depend on the next tasks:

bootRepackage task deps [task 'distZip', task ':distTar', task ':ear', task ':war']

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 17 (6 by maintainers)

Commits related to this issue

Most upvoted comments

For all fighting this, snippet from my workaround:

      //if you need to do sth like this:
         project.artifacts {
            myConf myTaskDependantOnBootRepackage
        }
     //you can remove then bootRepackage dependencies to Archives like this:
        project.tasks.matching {it.name == "bootRepackage"}.each {
            Set<Object> deps =  it.taskDependencies.values
            def toBeeRemoved = deps.find {
                it.class.name.startsWith("org.gradle.api.internal.artifacts.DefaultPublishArtifactSet")
            }
            deps.removeAll(toBeeRemoved)
        }

Potentially makes sense to give freedom to select on what tasks bootRepackage task depends on.