netbeans-gradle-javaee-project icon indicating copy to clipboard operation
netbeans-gradle-javaee-project copied to clipboard

No autocompletion support for JSPs. Workaround: add WEB-INF to sourceSets.main.java.srcDir

Open gallardo opened this issue 10 years ago • 7 comments

Is there any kind of autocompletion/code browsing support for JSPs? I have tried many different configurations but I cannot get it working. This is repeatable. I'm using NetBeans 8.0.2, Gradle Support Version 1.3.4 (from Plugin Portal) and Gradle JavaEE Support Version 1.0.2 (from Plugin Portal).

gallardo avatar Apr 07 '15 11:04 gallardo

Expected (from a fresh created NetBeans-native "Java Web/Web Application" project):

image

Currently I'm getting a "No suggestion" popup:

image

Notice the additional node in Source Packages after giving Attila 's suggestion of explicitly adding the webAppDir to the java sources a try: image

Unfortunately it doesn't make a difference, and doesn't work either independently of which node I do select the file from.

gallardo avatar Apr 08 '15 08:04 gallardo

I was wrong, you shouldn't add the WEB-INF but the directory containing the jsp files. My guess is that the ClassPathProvider should provide the JSP files with classpaths (altough I'm not sure how it really supposed to know the dependencies of which source set).

kelemen avatar Apr 08 '15 08:04 kelemen

Still no luck. I'm attaching a screenshot with the expanded tree folder hierarchy: image

settings.gradle only defines the name of the root project:

rootProject.name = 'test-gradle-jee-autocompletion'

The build.gradle script is the default script with a few jetty properties to allow deploying and testing:

apply plugin: 'war'
apply plugin: 'jetty'

//webAppDirName='resources'

sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

if (!hasProperty('mainClass')) {
    ext.mainClass = ''
}

repositories {
    mavenCentral()
}

dependencies {
    compile group: 'javax.servlet', name: 'jsp-api', version: '2.0'
    compile group: 'javax.servlet', name: 'servlet-api', version: '2.4'
}

if (project.hasProperty('evaluatingIDE') && project.property('evaluatingIDE') == 'NetBeans') {
    sourceSets.main.java.srcDir(webAppDir.toString() + '/WEB-INF')
}

jettyRun.httpPort = 18080
jettyRunWar.httpPort = 18080
jettyRun.contextPath = ''
jettyRunWar.contextPath = ''

gallardo avatar Apr 08 '15 08:04 gallardo

Adding some environment info:

Product Version: NetBeans IDE 8.0.2 (Build 201408251540) Updates: NetBeans IDE is updated to version NetBeans 8.0.2 Patch 1 Java: 1.8.0_25; Java HotSpot(TM) 64-Bit Server VM 25.25-b02 Runtime: Java(TM) SE Runtime Environment 1.8.0_25-b17 System: Linux version 3.14.14-gentoo running on amd64; UTF-8; en_US (nb)

gallardo avatar Apr 08 '15 08:04 gallardo

My next guess is that GradleWebModuleImpl should provide a non empty class path in getMetadataModel. I don't know what the classpath is supposed to be though.

kelemen avatar Apr 08 '15 09:04 kelemen

Unfortunately, I'm unfamiliar with NetBeans plugins and cannot afford (now) to debug this project. I hope that hildo jumps in, or that I soon have some time to look at it myself (very improbable).

gallardo avatar Apr 08 '15 09:04 gallardo

Uhmmm... It seems as if this issue had another source. I now get autocompletion after having fixed a missing repository in a different gradle project, from a different (closed) Project Group!

image

I still need to apply kelemen's suggestion (adding a java srcDir to the main SourceSet), but it works. Thanks Kelemen!

I'm not closing this issue, as with the work-around a new additional redundant (and ugly) node is rendered.

EDIT: Added link to Kelemen's suggestion

gallardo avatar Apr 08 '15 13:04 gallardo