Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-8299] Fix ordering of phases from custom lifecycles #1802

Merged
merged 1 commit into from
Oct 16, 2024
Merged
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 @@ -204,42 +204,71 @@ public String id() {

@Override
public Collection<Phase> phases() {
return lifecycle.getPhases().stream()
.map(name -> (Phase) new Phase() {
@Override
public String name() {
return name;
List<String> names = lifecycle.getPhases();
List<Phase> phases = new ArrayList<>();
for (int i = 0; i < names.size(); i++) {
String name = names.get(i);
String prev = i > 0 ? names.get(i - 1) : null;
phases.add(new Phase() {
@Override
public String name() {
return name;
}

@Override
public List<Phase> phases() {
return List.of();
}

@Override
public Stream<Phase> allPhases() {
return Stream.concat(
Stream.of(this), phases().stream().flatMap(Lifecycle.Phase::allPhases));
}

@Override
public List<Plugin> plugins() {
Map<String, LifecyclePhase> lfPhases = lifecycle.getDefaultLifecyclePhases();
LifecyclePhase phase = lfPhases != null ? lfPhases.get(name) : null;
if (phase != null) {
Map<String, Plugin> plugins = new LinkedHashMap<>();
DefaultPackagingRegistry.parseLifecyclePhaseDefinitions(plugins, name, phase);
return plugins.values().stream().toList();
}
return List.of();
}

@Override
public List<Phase> phases() {
@Override
public Collection<Link> links() {
if (prev == null) {
return List.of();
} else {
return List.of(new Link() {
@Override
public Kind kind() {
return Kind.AFTER;
}

@Override
public Pointer pointer() {
return new Pointer() {
@Override
public String phase() {
return prev;
}

@Override
public Type type() {
return Type.PROJECT;
}
};
}
});
}

@Override
public Stream<Phase> allPhases() {
return Stream.concat(
Stream.of(this), phases().stream().flatMap(Lifecycle.Phase::allPhases));
}

@Override
public List<Plugin> plugins() {
Map<String, LifecyclePhase> lfPhases = lifecycle.getDefaultLifecyclePhases();
LifecyclePhase phase = lfPhases != null ? lfPhases.get(name) : null;
if (phase != null) {
Map<String, Plugin> plugins = new LinkedHashMap<>();
DefaultPackagingRegistry.parseLifecyclePhaseDefinitions(plugins, name, phase);
return plugins.values().stream().toList();
}
return List.of();
}

@Override
public Collection<Link> links() {
return List.of();
}
})
.toList();
}
});
}
return phases;
}

@Override
Expand Down