Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-user] Tycho, Maven & PDE runbench classpath compatibility issues

Well, it's interesting that you get this kind of results since I've verified today at work that our projects do follow maven standard project structure (src in src/main/java and bin in target/classes) and can be successfully launched from Eclipse. Unfortunately, I do not have time to create a sample project right now, but I'm really curious as to why this does not work for you.

Just for the record, we're running Eclipse Luna/Mars with latest M2Eclipse versions, and import projects into workspace via Import Existing Maven Projects wizard. The target platform is however set to an independent p2 repo instead of the current running instance. The tycho version is 0.23.1 and M2Eclipse has Tycho Project Configurators installed from http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-tycho/0.9.0/N/LATEST/ (NB: M2Eclipse Marketplaces offers 0.8.0 instead). I've looked at classpath and build.properties, and they look very similar to yours. Could it be something else that is wrong?

Kind regards,
Mikhail Kalkov

2015-09-29 21:43 GMT+02:00 Adrian Price <aprice@xxxxxxxxx>:
Hi Mikhail,

Many thanks for your response and yes, you were absolutely correct, I had indeed lost a bin./includes "." entry somewhere along the way. However, restoring it made no difference (other than to build the binary JAR correctly).

Per the post subject, my question really was about the combination Tycho+Maven+Eclipse+PDE and whether these layers can coexist happily - I think it's a reasonable assumption that anyone developing Eclipse plug-ins using Maven+Tycho+m2e will wish to debug them in a self-hosted runbench using PDE. My conclusion is that self-hosting doesn't work if the default Maven project structure is used, and that PDE is the culprit.

I found that having non-default <classpathentry kind="src" path="src/main/java"/> + <classpathentry kind="output" path="classes"/> in .classpath and source.. = src/main/java/ + output.. = classes/ in build.properties works just fine. However, changing .classpath to <classpathentry kind="output" path="target/classes"/> and build.properties to output.. = target/classes/ doesn't work. The problem occurs even for non-Maven/Tycho plug-in projects. On the face of it, it would seem to be the multiple output path segments that breaks the self-hosting classpath. Under the debugger the classpaths of the two configurations are different - see attached screenshots. In the single-segment case (bin or classes) the classloader has two classpath entries, the first of which uses a 'NestedDirBundleFile' bundleFile pointing to the bin or classes subdirectory. In the two-segment case (target/classes) the classloader has only one classpath entry that points to the plug-in directory, with no provision for loading anything from the target/classes subdirectory! I shall log a PDE bug.

 Inline images 2Inline images 1

So although this is clearly a PDE issue I've gone into this much detail as it is surely relevant to any Tycho user who tries to use the default Maven project structure and can't figure out what they're doing wrong. Something for the Tycho FAQ, perhaps?

Thanks,

--A

On 28 September 2015 at 21:29, Mikhail Kalkov <mikhail.kalkov@xxxxxxxxx> wrote:
Hi Adrian,

It does work, but it's difficult to say more than this since you're conflating several issues. Firstly, you ask if a Tycho project can follow default Maven structure, but then suddenly jump to ask if PDE supports default Maven structure. Secondly, the error you mention is about location of class files, but you for some reason ask about location of source files too. Thirdly, there is no magic about "self-hosting". It's like hosting in any other p2 application but using own p2 repos. All of this is confusing me.

If I were you, I'd try couple things. First of all, build.properties I've seen so far always included a dot (".") in bin.includes. I haven't reflected about this but think it's suspiciout that the dot is missing in your case. Secondly, I suggest that you export your product and inspect offending jar file manually. Does it really have classes? Where are they?

My theory is PDE indeed has built-in support for classes in bin/ directory but if they end up elsewhere bin.includes should include (heh?) the path to them.

Kind regards,
Mikhail Kalkov

Kind regards,
Mikhail Kalkov

2015-09-28 18:21 GMT+02:00 Adrian Price <aprice@xxxxxxxxx>:
Sorry - I made a mistake when editing out some irrelevant stuff in build.properties, which should have read:
bin.includes = META-INF/,\
               plugin.properties,\
               plugin.xml

On 28 September 2015 at 17:15, Adrian Price <aprice@xxxxxxxxx> wrote:
Good day tycho-user@xxxxxxxxxxx,

There are several postings on related topics but I should like to ask the specific question:

Q: For an Eclipse plug-in project being built by Maven and Tycho, is it even possible to use to the Maven default project structure whereby Java sources live in src/main/java and get compiled to target/classes, and if so, how?

My experience is that if you have this .classpath:
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

and this build.properties:
source.. = src/main/java/
output.. = target/classes/
bin.includes = .META-INF/,\
               plugin.properties,\
               plugin.xml,\

then in a self-hosted runbench (Run|Debug As > Eclipse Application), the plug-in is unable to load any of its classes because the class loader tries to resolve the class file path relative to the location of the workspace project root rather than that project's target/classes directory. The only way I've found to get self-hosting to work is to change everything back to the PDE defaults of <classpathentry kind="output" path="bin"/> and output.. = bin/ ; then, under the debugger, one can observe the class loader magically resolving the class file's path relative to the <project>/bin directory in the workspace, using a org.eclipse.osgi.storage.bundlefile.NestedDirBundleFile.

I'm suspecting that PDE (or somewhere) might have some hard-coded reliance on a bin directory. All the Tycho examples I've seen use src and bin directories.

Could anyone confirm this limitation or suggest a way to get self-hosting to work?

Thanks,

--A


_______________________________________________
tycho-user mailing list
tycho-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/tycho-user


_______________________________________________
tycho-user mailing list
tycho-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/tycho-user


_______________________________________________
tycho-user mailing list
tycho-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/tycho-user


Back to the top