diff --git a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysisMojo.java b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysisMojo.java index 9bf5b1041d..9120332d60 100644 --- a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysisMojo.java +++ b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysisMojo.java @@ -308,7 +308,7 @@ private Collection getBaselineBundles() throws MojoFailureException { long start = System.currentTimeMillis(); Collection baselineBundles; try { - Collection targetEnvironments = projectManager.getTargetEnvironments(project); + Collection targetEnvironments = getBaselineEnvironments(); Optional artifactKey = projectManager.getArtifactKey(project); getLog().info("Resolve API baseline for " + project.getId() + " with " + targetEnvironments.stream().map(String::valueOf).collect(Collectors.joining(", "))); @@ -324,6 +324,26 @@ private Collection getBaselineBundles() throws MojoFailureException { return baselineBundles; } + /** + * THis method selected the a Target environment bes 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 getBaselineEnvironments() { + Collection 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) {