Skip to content

Commit

Permalink
Add reproducer for API tools failure if the whole bundle is a jar
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Nov 9, 2023
1 parent 8289287 commit 170d7a6
Show file tree
Hide file tree
Showing 74 changed files with 8,669 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ private BundleComponent importProject() throws CoreException, IOException {
}

private void createOutputFolder(IProject project, IPath projectPath) throws IOException, CoreException {
Map<String, String> outputJars = computeOutputJars(project);
IJavaProject javaProject = JavaCore.create(project);
if (javaProject != null) {
Map<String, String> outputJars = computeOutputJars(project, javaProject);
IFolder outputFolder = project.getFolder(outputDir);
// FIXME see bug https://github.com/eclipse-pde/eclipse.pde/issues/801
// it can happen that project output location != maven compiled classes, usually
Expand All @@ -258,7 +258,7 @@ private void createOutputFolder(IProject project, IPath projectPath) throws IOEx
}
}

private Map<String, String> computeOutputJars(IProject project) throws CoreException {
private Map<String, String> computeOutputJars(IProject project, IJavaProject javaProject) throws CoreException {
Map<String, String> outputJars = new HashMap<String, String>();
IPluginModelBase base = PluginRegistry.findModel(project);
if (base != null) {
Expand All @@ -278,23 +278,20 @@ private Map<String, String> computeOutputJars(IProject project) throws CoreExcep
// 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);
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 tokenOutput = folder.getProjectRelativePath().toString();
outputJars.putIfAbsent(tokenOutput, key);
}
}
}
Expand All @@ -316,6 +313,13 @@ private IPath getRealPath(IPath eclipseOutputLocation, Map<String, String> outpu
if (jarFolder.equals(projectFolder)) {
String jarOutputPath = entry.getValue();
if (".".equals(jarOutputPath)) {
// TODO need to handle this special case:
// if (".".equals(jarName) || jarToSourceFolderEntries.size() == 1) {
// // in case of one classpath entry which is not ".", also use standard
// // maven output dir for better interoperability with plain maven plugins
// dotJarName = jarName;
// outputDirectory = project.getBuildDirectory().getOutputDirectory();
// }
return mavenOutputFolder.getFullPath();
}
return mavenOutputFolder.getParent()
Expand Down Expand Up @@ -427,7 +431,7 @@ private IApiBaseline createBaseline(Collection<String> bundles, String name) thr
IApiComponent component = ApiModelFactory.newApiComponent(baseline, baselineBundle);
if (component != null) {
debug(component.getSymbolicName() + " " + component.getVersion() + " -- "
+ new File(Objects.requireNonNullElse(component.getLocation(), "Unknown")).getName());
+ new File(Objects.requireNonNullElse(component.getLocation(), "Unknown")).getAbsolutePath());
baselineComponents.add(component);
}
}
Expand Down
7 changes: 7 additions & 0 deletions tycho-its/projects/api-tools/single-jar/.mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions>
<extension>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-build</artifactId>
<version>${tycho-version}</version>
</extension>
</extensions>
1 change: 1 addition & 0 deletions tycho-its/projects/api-tools/single-jar/.mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Dtycho-version=5.0.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="model"/>
<classpathentry kind="src" path="jdi"/>
<classpathentry kind="src" path="eval"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/jdi-bin/
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.jdt.debug</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.jdt.debug" version="2">
<resource path="META-INF/MANIFEST.MF">
<filter id="926941240">
<message_arguments>
<message_argument value="3.22.0"/>
<message_argument value="3.21.100"/>
</message_arguments>
</filter>
</resource>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n
Loading

0 comments on commit 170d7a6

Please sign in to comment.