gradle / gradle

Adaptable, fast automation for all
https://gradle.org
Apache License 2.0
16.82k stars 4.71k forks source link

Nested composites with cyclic dependencies cause an error #6147

Closed nddipiazza closed 4 years ago

nddipiazza commented 6 years ago

Version: 4.10.nightly

Let's say you have the following dependencies between composite builds:

    projectA --compile--> 
      projectB --testcompile--> 
        projectC --compile--> 
          projectA

This does not create a cycle due to the testcompile dependency between projectB and projectC.

Now let's say each of these projects is connected with composite build includedBuild such that

projectA
   includeBuild '../projectB'
projectB
   includeBuild '../projectC'
projectC
   includeBuild '../projectA'

Now if you try to build cd projectA; ./gradlew build

This will cause the error:

Included build in /Users/nicholasdipiazza/projectA has the same root project name 'projectA' as the main build.

This is because you are building root project projectA but then projectC includes projectA.

This should just realize that you already included that build and ignore it.

The work around is to build this project from a different project root, then it works fine.

calvertdw commented 6 years ago

This should just realize that you already included that build and ignore it.

I agree and that is what we do in our plugin. (not recommending use, just to show that we're doing it)

   val transitiveIncludedBuilds = TreeSet<IHMCBuildProperties>()
   ...
   transitiveIncludedBuilds.add(propertiesFromKebabCasedName(artifactName))

https://github.com/ihmcrobotics/ihmc-build/blob/8d038dd477043862ae50ccaf44987afc7616e15e/src/main/kotlin/us/ihmc/build/IHMCCompositeBuildAssembler.kt#L27

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

stale[bot] commented 4 years ago

This issue has been automatically closed due to inactivity. If you can reproduce this on a recent version of Gradle or if you have a good use case for this feature, please feel free to reopen the issue with steps to reproduce, a quick explanation of your use case or a high-quality pull request.

sirinath commented 4 years ago

With the new composite script plugins, there is always a chance to double including a plugin which needs to be handled.

aamielsan commented 3 years ago

Any plans to support this in the near future?

calvertdw commented 3 years ago

This would be a nice feature to have!