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

Use the running environment if possible in API analysis #3484

Merged
merged 1 commit into from
Feb 7, 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 @@ -308,7 +308,7 @@ private Collection<Path> getBaselineBundles() throws MojoFailureException {
long start = System.currentTimeMillis();
Collection<Path> baselineBundles;
try {
Collection<TargetEnvironment> targetEnvironments = projectManager.getTargetEnvironments(project);
Collection<TargetEnvironment> targetEnvironments = getBaselineEnvironments();
Optional<ArtifactKey> artifactKey = projectManager.getArtifactKey(project);
getLog().info("Resolve API baseline for " + project.getId() + " with "
+ targetEnvironments.stream().map(String::valueOf).collect(Collectors.joining(", ")));
Expand All @@ -324,6 +324,26 @@ private Collection<Path> getBaselineBundles() throws MojoFailureException {
return baselineBundles;
}

/**
* This method selected the a target environment best suited for the current
* baseline, if it is a valid choice the running target is used (e.g. linux on
* linux host, windows on windows hosts and so on), if such environment is not
* available it is using the configured ones form the project as is.
*
* @return the chosen {@link TargetEnvironment}s
*/
private Collection<TargetEnvironment> getBaselineEnvironments() {
Collection<TargetEnvironment> targetEnvironments = projectManager.getTargetEnvironments(project);
TargetEnvironment runningEnvironment = TargetEnvironment.getRunningEnvironment();
for (TargetEnvironment targetEnvironment : targetEnvironments) {
if (targetEnvironment.equals(runningEnvironment)) {
return List.of(targetEnvironment);
}
}
return targetEnvironments;
}


private String time(long start) {
long ms = System.currentTimeMillis() - start;
if (ms < 1000) {
Expand Down
Loading