From e3d7619402e0dae80d35bda62866380253f30b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Thu, 9 Nov 2023 10:00:23 +0100 Subject: [PATCH] Consider the classpath file as an alternative for build output Actually each source. should have a corresponding output. but there are some cases where this is not true... lets cheat and look at the classpath instead... Fix https://github.com/eclipse-tycho/tycho/issues/3019 --- .../eclipse/tycho/apitools/ApiAnalysis.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysis.java b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysis.java index 942b500a44..4f5aebd540 100644 --- a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysis.java +++ b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysis.java @@ -273,6 +273,32 @@ private Map computeOutputJars(IProject project) throws CoreExcep for (String token : entry.getTokens()) { outputJars.put(token, key); } + } else if (name.startsWith(IBuildEntry.JAR_PREFIX)) { + // Actually each source. should have a corresponding output. but there + // are some cases where this is not true... lets cheat and look at the + // classpath instead... + String key = name.substring(IBuildEntry.JAR_PREFIX.length()); + IJavaProject javaProject = JavaCore.create(project); + if (javaProject != null) { + IClasspathEntry[] rawClasspath = javaProject.getRawClasspath(); + for (String token : entry.getTokens()) { + IPath srcPath = project.getFolder(token).getFullPath(); + for (IClasspathEntry classpathEntry : rawClasspath) { + if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { + IPath path = classpathEntry.getPath(); + if (srcPath.equals(path)) { + IPath outputLocation = classpathEntry.getOutputLocation(); + if (outputLocation == null) { + outputLocation = javaProject.getOutputLocation(); + } + IFolder folder = getProjectFolder(outputLocation); + String output = folder.getProjectRelativePath().toString(); + outputJars.putIfAbsent(output, key); + } + } + } + } + } } } }