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

Bp at single jar #3027

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
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 @@ -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 @@ -271,30 +271,27 @@ private Map<String, String> computeOutputJars(IProject project) throws CoreExcep
if (name.startsWith(IBuildEntry.OUTPUT_PREFIX)) {
String key = name.substring(IBuildEntry.OUTPUT_PREFIX.length());
for (String token : entry.getTokens()) {
outputJars.put(token, key);
outputJars.put(normalizeOutputPath(token), key);
}
} else if (name.startsWith(IBuildEntry.JAR_PREFIX)) {
// Actually each source.<jar> should have a corresponding output.<jar> 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);
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(normalizeOutputPath(tokenOutput), key);
}
}
}
Expand All @@ -306,6 +303,13 @@ private Map<String, String> computeOutputJars(IProject project) throws CoreExcep
return outputJars;
}

private String normalizeOutputPath(String path) {
if (path != null && path.endsWith("/")) {
return path.substring(0, path.length() - 1);
}
return path;
}

private IPath getRealPath(IPath eclipseOutputLocation, Map<String, String> outputJars, IFolder mavenOutputFolder) {
if (eclipseOutputLocation == null) {
return null;
Expand All @@ -315,7 +319,9 @@ private IPath getRealPath(IPath eclipseOutputLocation, Map<String, String> outpu
IFolder jarFolder = projectFolder.getProject().getFolder(entry.getKey());
if (jarFolder.equals(projectFolder)) {
String jarOutputPath = entry.getValue();
if (".".equals(jarOutputPath)) {
if (".".equals(jarOutputPath) || outputJars.size() == 1) {
// special case of one classpath entry which is not ".", Tycho also use standard
// maven output dir
return mavenOutputFolder.getFullPath();
}
return mavenOutputFolder.getParent()
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
Loading