gradle-scripts icon indicating copy to clipboard operation
gradle-scripts copied to clipboard

Evaluates dependencies for bom after configure other gradle scripts

Open imasahiro opened this issue 3 years ago • 2 comments

Motivations:

  • Sometimes a user wants to overwrite project's property (for example, group name) of subprojects but since bom.gradle is evaluated before evaluating gradle scripts under subprojects. As a result, it causes inconsistency between group name of published artifact and group name in bom file

Changes:

  • Evaluates bom's dependencies after configuring Java projects

Results:

  • Less inconsistency between bom file and published artifacts

Example:

// project tree
- module1
      |- build.gradle # Let's say build-1.gradle
- module2
     |- build.gradle # Let's say build-2.gradle
- build.gradle # Let's say build-root.gradle
- gradle.properties
# gradle.properties
group=a.b.c.root
// build-1.gradle
subprojects {
   group 'a.b.c.module1'
}
// build-2.gradle
subprojects {
   group 'a.b.c.module2'
}
<!-- bom.xml AS-IS -->
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>a.b.c.root</groupId> <!-- We expect this group name should be `a.b.c.module1` but `a.b.c.root` -->
        <artifactId>module1</artifactId>
        <version>1.0.0-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>a.b.c.root</groupId> <!-- We expect this group name should be `a.b.c.module2` but `a.b.c.root` -->
        <artifactId>module2</artifactId>
        <version>1.0.0-SNAPSHOT</version>
      </dependency>
  </dependencyManagement>

<!-- bom.xml TO-BE -->
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>a.b.c.module1</groupId>
        <artifactId>module1</artifactId>
        <version>1.0.0-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>a.b.c.module2</groupId>
        <artifactId>module2</artifactId>
        <version>1.0.0-SNAPSHOT</version>
      </dependency>
  </dependencyManagement>
...

imasahiro avatar Jul 21 '22 08:07 imasahiro

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jul 21 '22 08:07 CLAassistant

We noticed a regression and was resolved by https://github.com/line/gradle-scripts/pull/124/commits/f474532b698858467dcb1034c06428148eb607e6 I would like to say thanks to @noda-sin to address the issue

imasahiro avatar Jul 29 '22 08:07 imasahiro

Thanks @imasahiro for taking care of this. 🙇‍♂️

ikhoon avatar Sep 26 '22 11:09 ikhoon