tesla / m2eclipse-tycho

25 stars 26 forks source link

Jdt debugger does not find sources when Tycho Project Configurators is installed #32

Open LorenzoBettini opened 7 years ago

LorenzoBettini commented 7 years ago

If you have PDE projects with Maven nature (configured with Tycho), and you try to debug, e.g. a JUnit Test Case in a .tests project that tests a Java class in another project, then JDT debugger cannot find the sources of the classes of other projects (nor sources of possible dependencies used by the classes under test) if you have "Tycho Project Configurators" installed in your Eclipse.

For example, take the projects found here: https://github.com/LorenzoBettini/tycho-simple-example

Note that if this happens, and you uninstall the Tycho Project Configurators, debugger will work again (it will find the sources) ONLY if you use another fresh workspace or if you first remove a few folders in the .metadata directory (I did some tests and I had to remove .jdt., .debug. and .m2e.). Since I found no file left from the Tycho Project Configurators in the .metadata directory, can it be that m2eclipse-tycho interferes with some JDT indexes?

I'm using Eclipse Neon 2 and the Tycho Project Configurators taken from http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-tycho/0.9.0/N/LATEST

LorenzoBettini commented 7 years ago

Apparently, the problem is only in the Tycho Project Configurators 0.9.x: with version 0.8.x, which is the one proposed automatically if you have projects configured with a tycho build, the problem is not there. I was using 0.9.0 since I thought it was the latest release, but probably that's not the case and it's only a snapshot?

ifedorenko commented 7 years ago

You may want to try my "advanced" source lookup tech (can be installed form this p2 repository). It supports Debug As JUnit Plugin Test and Eclipse Application launch configuration and should be compatible with latest Eclipse and M2E releases.

LorenzoBettini commented 7 years ago

@ifedorenko thank you for the suggestion, and I'll try that. However, the problem I was referring to happens when you debug from Eclipse as plain JUnit, not as JUnit Plugin Test. Is the bug I reported known? Is 0.9.0 officially released or should we stay with 0.8.0?

LorenzoBettini commented 7 years ago

@ifedorenko I did some further investigations that I report here, hoping they're useful to fix this problem: when the Tycho project configurator 0.9.0 is used, the launch configuration adds these two additional entries:

<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>

which are responsible for NOT finding sources of other projects (including their dependencies).

Manually removing those two entries brings the launch configuration to a working state (sources of other projects and dependencies are correctly found during debugging). A working launch configuration can be found here: https://github.com/LorenzoBettini/tycho-simple-example/blob/78bbe0c28d38f0b6639ab007f07de0123f5a0d31/example.parent/example.tests/MyClassTest.launch. Upgrading the Tycho project configurator from 0.8.0 to 0.9.0 will modify this launch configuration to a NON working state adding the two above entries.

Can the problem be due to this commit https://github.com/tesla/m2eclipse-tycho/commit/fae253e88d064d534e963618f4684c9cba1b9f18? I see there's a comment from you (https://github.com/tesla/m2eclipse-tycho/commit/fae253e88d064d534e963618f4684c9cba1b9f18#diff-703464cb85074c6e19ca4d67df3b862fR132):

// igorf: Returned entries do not have attached sources. I am not actually sure this works.
LorenzoBettini commented 7 years ago

Unfortunately I have some bad updates (I've just realized that after seeing #34): the problem is still there also with tycho project configurator 0.8.0 (and also with 0.8.1): as soon as I open an existing launch configuration in the Run Configurations... dialog the two above mentioned entries are automatically added:

<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>

breaking completely the debugging features...

Sources of other projects (and dependencies) are not automatically available for any new debug configurations, making debugging a real pain...

The only solution is to uninstall the tycho project configurator plugin and get run of the launches saved in the workspace org.eclipse.debug.core/.launches.

ifedorenko commented 7 years ago

Have you tried advanced sourcelookup? I am debugging m2e and bunch of in-house projects without problems.

LorenzoBettini commented 7 years ago

@ifedorenko where can I find "advanced sourcelookup"? I mean in which preference/configuration? Can you share some of the projects you're using?

Note that the problems I experience when debugging are due to sources in other projects from the one where I'm debugging (e.g., JUnit tests in a different project) and to sources of plugin (PDE) dependencies.

ifedorenko commented 7 years ago

you can install it from https://repository.takari.io/content/sites/m2e.extras/sourcelookup/1.2.0/N/LATEST/

edit: the project github repo has some info about features and mode of operation https://github.com/ifedorenko/com.ifedorenko.m2e.sourcelookup