0

When I try to declare the task "build" depends on another task like this:

task("build").dependsOn(
    gradle.includedBuild("splain").task("publishToMavenLocal")
)

I got the following error:

FAILURE: Build failed with an exception.

* Where:
Build file '/home/peng/git/shapesafe/build.gradle.kts' line: 35

* What went wrong:
Cannot add task 'build' as a task with that name already exists.

How to fix it?

UPDATE 1: this also doesn't work:

    tasks {
        build.dependsOn(

            gradle.includedBuild("splain").publishToMavenLocal
        )
    }

e: /home/peng/git/shapesafe/build.gradle.kts:92:15: Unresolved reference: dependsOn

UPDATE 2 the following compiles successfully, but gives a different error:


    tasks.build{
        dependsOn(
            gradle.includedBuild("splain").task("publishToMavenLocal")
        )
    }


FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':core:compileTestScala'.
> Could not resolve all task dependencies for configuration ':core:scalaCompilerPlugins'.
   > Could not resolve io.tryp:splain_2.13.8:1.1.0-SNAPSHOT.
     Required by:
         project :core
      > Could not resolve io.tryp:splain_2.13.8:1.1.0-SNAPSHOT.
         > Unable to load Maven meta-data from https://dl.bintray.com/kotlin/kotlin-dev/io/tryp/splain_2.13.8/1.1.0-SNAPSHOT/maven-metadata.xml.
            > Could not GET 'https://dl.bintray.com/kotlin/kotlin-dev/io/tryp/splain_2.13.8/1.1.0-SNAPSHOT/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

This is problematic as io.tryp:splain_2.13.8:1.1.0-SNAPSHOT should already be published to maven local, the gradle task sequence log further confirmed this view:

:splain:buildSrc:compileKotlin
:splain:buildSrc:compileJava
:splain:buildSrc:compileGroovy
:splain:buildSrc:pluginDescriptors
:splain:buildSrc:processResources
:splain:buildSrc:classes
:splain:buildSrc:inspectClassesForKotlinIC
:splain:buildSrc:jar
:splain:buildSrc:assemble
:splain:buildSrc:compileTestKotlin
:splain:buildSrc:pluginUnderTestMetadata
:splain:buildSrc:compileTestJava
:splain:buildSrc:compileTestGroovy
:splain:buildSrc:processTestResources
:splain:buildSrc:testClasses
:splain:buildSrc:test
:splain:buildSrc:validatePlugins
:splain:buildSrc:check
:splain:buildSrc:build
(no publishToMavenLocal!)

So I just need to trigger it

tribbloid
  • 4,026
  • 14
  • 64
  • 103

1 Answers1

0

According to the Gradle document at https://docs.gradle.org/current/userguide/composite_builds.html#included_build_task_dependencies, the task name you are using is missing the colon :. It should be:

tasks.findByPath(":configuration")?.dependsOn( gradle.includedBuild("splain").task(":publishToMavenLocal"))

Edit: the depending task should be :configuration task

minh tri Vo
  • 524
  • 4
  • 11
  • Oops, doesn't work.It appears that the ":configuration" task precedes "build", it won't trigger the publishing, but will detect the missing package – tribbloid Jun 17 '22 at 20:02
  • @tribbloid, I think what you need is to make the configuration task depend on the publishToMaven task instead: `tasks.findByPath(":configuration")?.dependsOn( gradle.includedBuild("splain").task(":publishToMavenLocal"))` – minh tri Vo Jun 18 '22 at 03:55