nb-springboot icon indicating copy to clipboard operation
nb-springboot copied to clipboard

Web resources node

Open AlexFalappa opened this issue 9 years ago • 2 comments
trafficstars

One or two nodes in the project view for web resources showing the content of src/main/resources/static and src/main/resources/templates folders

AlexFalappa avatar Oct 08 '16 16:10 AlexFalappa

First: Cool to have a Spring Boot plugin for Netbeans. :-)

Would implementing this ticket enable LESS compilation on save support?

The current status is that the following dialog appears when saving a ".less" file:

Do you want to configure automatic LESS compilation on save? Note that you can always turn this on (or off) later in Project Properties.

I even see INFO [CPOnSaveHook]: processSavedFile called for LESS type on project d:/project. in the logs.

But neither is the css file generated nor is there any way to change the setting in the project properties (the tab is not even showed).

I tried to fix it on my own but had no success so far. To not lose the knowledge I gained I will add some notes to this ticket.

I looked at the source code of Netbeans and it looks to me that CPOnSaveHook is only responsible for that dialog and not for triggering the invocation of LESS. I did some more research and found a real gem: http://hg.netbeans.org/main-silver/rev/306e875d1344 This is the original commit which added less support to Maven WAR projects.

I made a pretty simple try and added

<dependency>
    <groupId>org.netbeans.modules</groupId>
    <artifactId>org-netbeans-modules-web-common-ui</artifactId>
    <version>${netbeans.api.version}</version>
</dependency>
<dependency>
    <groupId>org.netbeans.modules</groupId>
    <artifactId>org-netbeans-modules-web-common</artifactId>
    <version>${netbeans.api.version}</version>
</dependency>

as dependencies and the following code to the the SpringBootServiceInitializer#projectOpened():

final CssPreprocessorsListener cssSupport = prj.getLookup().lookup(CssPreprocessorsListener.class);
if (cssSupport != null) {
    CssPreprocessors.getDefault().addCssPreprocessorsListener(cssSupport);
}

But it ends up in a ClassNotFoundException. I have no idea why... the dependency is added to the pom. I have to admit that I have no Netbeans plugin coding experience.

Another source of inspiration might be https://github.com/hildo/netbeans-gradle-javaee-project. The scope sounds pretty similar. I also found a forum thread initiated by the author of that plugin: http://netbeans-org.1045718.n5.nabble.com/How-to-start-for-netbeans-gradle-javaee-plugin-td5730673.html.

janScheible avatar Dec 29 '16 21:12 janScheible

@janScheible to answer your first question, unfortunately no, solving this issue would not automatically enable support for CSS preprocessors.

This issue only covers the presentation aspect: it aims at better showing int the Project view the web resources (html pages, css files, javascript files and so on) only for Spring Boot projects maven projects with JAR packaging, the idea is to make them look like in maven projects with WAR packaging.

You should try to change the packaging type to war in your pom.xml and check if preprocessor support get enabled as a consequence. This is obviously not a proper solution.

Anyway thank you for your investigation and the notes you added, I'm going to add a new issue and point it here for future reference.

AlexFalappa avatar Dec 30 '16 17:12 AlexFalappa