jbang
jbang copied to clipboard
Edit with Eclipse and "sourcepath" for dependencies
jbang edit for eclipe is generating a .classpath file for Eclipse IDE:
<classpathentry kind="lib" path="/___/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.10.2/jackson-databind-2.10.2.jar"/>
As a result the source jar is not available in Eclipse when you click on the method of that library.
M2E (Maven support in Eclipse) or Buildship (Gradle support in Eclipse) are generating an entry that looks like this (with the sourcepath attribute set):
<classpathentry kind="lib" path="/___/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.10.2/jackson-databind-2.10.2.jar" sourcepath="/___/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.10.2/jackson-databind-2.10.2-sources.jar"/>
I looked a little bit at the code, and in my eyes the issue is that a classpath entry is really quickly converted to String (the absolute path to jar). Do you think this could be an object with more attributes instead (id of the resolver (maven repo, ...), path to the jar, path to the source-jar if available, ...)? I am happy to start something in this direction, if you confirm that you would accept a change like this.
I also have the feeling that resolving the dependencies is also not the same depending if you want to run or to edit the lib. In the second case, triggering a download of the sources could be useful. Or at least checking if the sources-jar are present in the local .m2 repo (if you want to avoid the waiting time of the download)
i would definitely review it if you make it :)
I acutally thought eclipse would fetch the sources if metadata present in them with m2e installed...but of course of you don't have m2e installed then having the sources would be fine.
The problem is that the project you create is a Java project:
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
So Eclipse doesn't apply either the Maven or the Gradle tooling => which is also a perfectly valid option, since the classpath is defined by the //DEPS entries in the Java file.
When I do jbang edit I get only a build.gradle file, not pom.xml (maybe my jbang version is old) so even if the .project file would define a maven nature, it would probably display an error that the POM file is missing.
i thought m2ehad fearturw that worked fr plain jdt projects but maybe that was in jboss tools we did that ;)
Undocumented feature of https://marketplace.eclipse.org/content/pde-source-lookup is it also discovers maven sources for non-plugin projects, i.e regular Java projects.
See also the discussion here in #1249