Skip to content

Commit

Permalink
Add parent ID to module xml
Browse files Browse the repository at this point in the history
  • Loading branch information
mealingr committed Oct 24, 2022
1 parent 6ed2464 commit b0b8e44
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ group=org.sonatype.gradle.plugins
version=2.5.3-SNAPSHOT
release.useAutomaticVersion=true

nexusPlatformApiVersion=4.0.2-01
nexusPlatformApiVersion=4.0.3-01
ossIndexClientVersion=1.8.1
logbackVersion=1.2.11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ Module buildModule(Project project) {
.setBuilderInfo(Module.BI_CLM_TOOL, "gradle")
.setBuilderInfo(Module.BI_CLM_VERSION, PluginVersionUtils.getPluginVersion());

module.setId(getId(project));
if (project.getParent() != null) {
module.setParentId(getId(project.getParent()));
}

return module;
}

String getId(Project project) {
StringBuilder idBuilder = new StringBuilder();
if (StringUtils.isNotBlank(project.getGroup().toString())) {
idBuilder.append(project.getGroup().toString()).append(":");
Expand All @@ -139,9 +148,7 @@ Module buildModule(Project project) {
&& !"unspecified".equals(project.getVersion().toString())) {
idBuilder.append(":").append(project.getVersion().toString());
}
module.setId(idBuilder.toString());

return module;
return idBuilder.toString();
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,13 @@ public void testFindModules_multiModule() {
Module parentModule = modules.get(0);
assertThat(parentModule.getId()).isEqualTo(parentProject.getName());
assertThat(parentModule.getConsumedArtifacts()).isEmpty();
assertThat(parentModule.getParentId()).isNull();

Module childModule = modules.get(1);
assertThat(childModule.getId()).isEqualTo(parentProject.getName() + ":" + childProject.getName());
assertThat(childModule.getConsumedArtifacts()).hasSize(1);
assertThat(childModule.getDependencies()).hasSize(1);
assertThat(childModule.getParentId()).isEqualTo(parentProject.getName());

Dependency dependency = childModule.getDependencies().get(0);
assertThat(dependency.getId()).isEqualTo(COMMONS_COLLECTIONS_DEPENDENCY);
Expand Down

0 comments on commit b0b8e44

Please sign in to comment.