Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -611,28 +611,68 @@ public void mergeRepositories(Model model, boolean replace) {
// Infer inner reactor dependencies version
//
Model transformFileToRaw(Model model) {
if (model.getDependencies().isEmpty()) {
return model;
}
List<Dependency> newDeps = new ArrayList<>(model.getDependencies().size());
boolean changed = false;
for (Dependency dep : model.getDependencies()) {
Dependency newDep = null;
if (dep.getVersion() == null) {
newDep = inferDependencyVersion(model, dep);
if (newDep != null) {
changed = true;

List<Dependency> newDeps = null;
if (!model.getDependencies().isEmpty()) {
newDeps = new ArrayList<>(model.getDependencies().size());
for (Dependency dep : model.getDependencies()) {
Dependency newDep = null;
if (dep.getVersion() == null) {
newDep = inferDependencyVersion(model, dep);
if (newDep != null) {
changed = true;
}
} else if (dep.getGroupId() == null) {
// Handle missing groupId when version is present
newDep = inferDependencyGroupId(model, dep);
if (newDep != null) {
changed = true;
}
}
} else if (dep.getGroupId() == null) {
// Handle missing groupId when version is present
newDep = inferDependencyGroupId(model, dep);
if (newDep != null) {
changed = true;
newDeps.add(newDep == null ? dep : newDep);
}
}

DependencyManagement newMgmt = null;
if (model.getDependencyManagement() != null
&& !model.getDependencyManagement().getDependencies().isEmpty()) {
List<Dependency> newMgmtDeps = new ArrayList<>(
model.getDependencyManagement().getDependencies().size());
boolean mgmtChanged = false;
for (Dependency dep : model.getDependencyManagement().getDependencies()) {
Dependency newDep = null;
if (dep.getVersion() == null) {
newDep = inferDependencyVersion(model, dep);
if (newDep != null) {
mgmtChanged = true;
}
} else if (dep.getGroupId() == null) {
// Handle missing groupId when version is present
newDep = inferDependencyGroupId(model, dep);
if (newDep != null) {
mgmtChanged = true;
}
}
newMgmtDeps.add(newDep == null ? dep : newDep);
}
if (mgmtChanged) {
newMgmt = model.getDependencyManagement().withDependencies(newMgmtDeps);
changed = true;
}
}

if (changed) {
Model.Builder builder = Model.newBuilder(model);
if (newDeps != null) {
builder.dependencies(newDeps);
}
newDeps.add(newDep == null ? dep : newDep);
if (newMgmt != null) {
builder.dependencyManagement(newMgmt);
}
return builder.build();
}
return changed ? model.withDependencies(newDeps) : model;
return model;
}

private Dependency inferDependencyVersion(Model model, Dependency dep) {
Expand Down