How to attach JavaEE Platform sources when remote debugging?
I have started a remote debugging session, and when trying to navigate through the code, all javax.* classes remain hidden. I guess I can add the corresponding platform sources through Sources Window->Add Source Root, but this is quite inefficient.
Doesn't have NetBeans any means to automatically detect that my gradle project is been remote-debugged, so it can bind the JavaEE soources?
@kelemen Also not sure if this shouldn't be addressed upstream (https://github.com/kelemen/netbeans-gradle-project)?
Answering myself: this is definitely not an upstream issue, as Kelemen's plugin only provides support for plain java projects. It'd be this javaee plugin the one that knows that there is a JavaEE platform involved, and the only one that could configure which one.
If other dependencies are available, I believe this issue is slightly more complicated. My guess is that NB asks for the runtime dependencies and the plugin tells it sourceSets.main.runtimeClasspath which does not include the EE sources.
As a work around, you might try something like this:
if (project.hasProperty('evaluatingIDE') && project.property('evaluatingIDE') == 'NetBeans') {
configurations.compile.extendsFrom provided
}
This will effectively make NB believe that provided dependencies are also runtime dependencies. Note, that as far as I know runtime dependencies are only used to tell the debugger what it should expect to be on the classpath.
Ups! I see. Again, I misunderstood something :open_mouth: : I added and configured a new server via NB -> Servers -> Add Server. I then started the server in debug mode Services->Servers->myServer->Start in Debug Mode, and was hoping that the sources configured for that server were available during NB -> Debug -> Attach Debugger.... I was even about to file a feature request for this netbeans-gradle-javaee plugin to support the selection of a configured server!
Wouldn't my attempt and workflow make more sense? Gradle shouldn't care about real provided dependencies (not those against which I compile, but the real libraries in my destination server). This could be very well configured as netbeans project properties.
I'm not using the EE part of NetBeans, so I can't tell if it makes sense or how feasible it is in NB. Though, - in theory -, it seems better to use the actual libraries but would you also have the sources as well?
would you also have the sources as well?
Sorry, I don't understand: as long as the sources are available I don't see why not... ? Do you mean something like the sources of org.apache.tomcat:tomcat-catalina:8.0.26, for a dependency declared in the gradle file? Or do you mean downloading the sources and configuring the Tools -> Servers -> myServer -> Sources ...?
I just didn't know if the sources can be specified for NB there as well for the provided jars. Then I guess it should be possible, though I never really checked (too deep) how the EE part of NB works.