mirror of
https://gitee.com/dcren/cloud-native-app-initializer.git
synced 2025-04-05 17:38:04 +08:00
Prioritize the use of dependModules when both dependModules and main are satisfied
Closes gh-24
This commit is contained in:
parent
5ed1758a1c
commit
c606401f88
@ -153,22 +153,22 @@ public class MulitModuleMavenBuildProjectContributor extends MavenBuildProjectCo
|
||||
}
|
||||
|
||||
} else {
|
||||
List<String> dependModules
|
||||
= module.getDependModules() == null ? Collections.emptyList() : module.getDependModules().stream()
|
||||
.distinct().map(this::toFinalArtifactId).toList();
|
||||
if (module.isMain()) {
|
||||
// main module depend all other submodules
|
||||
List<Module> subModules = arch.getSubModules();
|
||||
for (Module subModule : subModules) {
|
||||
if (subModule == module) {
|
||||
continue;
|
||||
}
|
||||
addModuleDependency(toFinalArtifactId(subModule.getName()));
|
||||
if (dependModules.isEmpty()) {
|
||||
// main module depend all other submodules
|
||||
List<String> subModules = arch.getSubModules().stream().distinct()
|
||||
.filter(subModule -> subModule != module)
|
||||
.map(subModule -> toFinalArtifactId(subModule.getName()))
|
||||
.toList();
|
||||
addModuleDependencies(subModules);
|
||||
} else {
|
||||
addModuleDependencies(dependModules);
|
||||
}
|
||||
} else {
|
||||
List<String> dependModules
|
||||
= module.getDependModules() == null ? Collections.emptyList() : module.getDependModules().stream()
|
||||
.distinct().map(dependModule -> toFinalArtifactId(dependModule)).collect(Collectors.toUnmodifiableList());
|
||||
for (String dependModule : dependModules) {
|
||||
addModuleDependency(dependModule);
|
||||
}
|
||||
addModuleDependencies(dependModules);
|
||||
}
|
||||
|
||||
// remove all dependencymanager
|
||||
@ -206,6 +206,12 @@ public class MulitModuleMavenBuildProjectContributor extends MavenBuildProjectCo
|
||||
}
|
||||
}
|
||||
|
||||
private void addModuleDependencies(List<String> dependModules) {
|
||||
for (String dependModule : dependModules) {
|
||||
addModuleDependency(dependModule);
|
||||
}
|
||||
}
|
||||
|
||||
private void addModuleDependency(String subModule) {
|
||||
this.build.dependencies().add(subModule, Dependency.withCoordinates(description.getGroupId(), subModule));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user