Too many tasks executed on jib build
See original GitHub issueDescription of the issue: While using the jib gradle task (jib) the Plugin configures the jib tasks to depend on ALL assemble tasks on all upstream projects in a multi project build. This causes lots of unecessary artifacts being build even if only the jar (default dependency) of any upstream project is used.
Expected behavior: If the plugin is applied only the default dependency should be used, which in fact is already evaluated for the build of the project (jar/classes). So there should be no need at all to depend on anything on the parent projects. If specific artifacts are needed by a specific project the project should configure this dependency itself, it should not be hard coded within the Jib Plugin itself.
Steps to reproduce:
Its in the original code: ` COPIED FROM JibPlugin.java:
// Find project dependencies and add a dependency to their assemble task. We make sure
// to only add the dependency after BasePlugin is evaluated as otherwise the assemble
// task may not be available yet.
List<Project> computedDependencies = getProjectDependencies(projectAfterEvaluation);
for (Project dependencyProject : computedDependencies) {
dependencyProject
.getPlugins()
.withType(
BasePlugin.class,
unused -> {
TaskProvider<Task> assembleTask =
dependencyProject.getTasks().named(BasePlugin.ASSEMBLE_TASK_NAME);
buildImageTask.configure(task -> task.dependsOn(assembleTask));
buildDockerTask.configure(task -> task.dependsOn(assembleTask));
buildTarTask.configure(task -> task.dependsOn(assembleTask));
});
}
` If some kind of dependency is really required, there should be a minimal dependency setup from any required project. Normally this should only be the “default” gradle artifact - including the classpath.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (7 by maintainers)
Top GitHub Comments
@bs-git we’ve released Jib 2.1.0 with the fix.
@seanabraham thanks for your great contribution!
@loosebazooka I took a shot at it and put it up at https://github.com/GoogleContainerTools/jib/pull/2247. I think public apis give you enough actually to get it done pretty cleanly as long as you depend on the FileCollection and let Gradle do the rest (FileCollections maintain mappings of which tasks produce which artifacts).