This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 218345 - Allow to copy static resources on save independently of Compile on Save
Summary: Allow to copy static resources on save independently of Compile on Save
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.2
Hardware: All All
: P3 normal with 8 votes (vote)
Assignee: Martin Janicek
URL:
Keywords:
: 216517 220493 236485 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-09-14 08:20 UTC by Petr Jiricka
Modified: 2014-12-20 12:50 UTC (History)
8 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
First sketch of possible solution (17.07 KB, patch)
2013-09-05 13:23 UTC, Martin Janicek
Details | Diff
Updated sketch of possible solution (17.98 KB, patch)
2013-09-05 13:39 UTC, Martin Janicek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2012-09-14 08:20:19 UTC
In Ant Web projects there is a separate setting for:
[ ] Copy Static Resources on Save
[ ] Compile on Save

This gives you finer control over your project behavior. In Maven project, there is just a single setting Compile on Save, which controls both classes compilation and static resource copying.

It would be useful to split this setting to two, analogously to Ant web projects, to give the user finer control.
Comment 1 Martin Janicek 2013-09-02 08:37:02 UTC
*** Bug 220493 has been marked as a duplicate of this bug. ***
Comment 2 Martin Janicek 2013-09-02 08:39:34 UTC
*** Bug 216517 has been marked as a duplicate of this bug. ***
Comment 3 Martin Janicek 2013-09-05 13:23:16 UTC
Created attachment 139702 [details]
First sketch of possible solution
Comment 4 Martin Janicek 2013-09-05 13:39:56 UTC
Created attachment 139703 [details]
Updated sketch of possible solution
Comment 5 Martin Janicek 2013-09-09 09:58:03 UTC
Implemented in web-main #bac5a505ae67
Comment 6 Martin Janicek 2013-10-08 08:15:52 UTC
Additional fix: web-main #97f2f753dd44
Comment 7 Quality Engineering 2013-10-09 02:21:02 UTC
Integrated into 'main-silver', will be available in build *201310090001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/97f2f753dd44
User: Martin Janicek <mjanicek@netbeans.org>
Log: #218345 - Apply the same rules for copy on save for static resources for all types of file events
Comment 8 ymajoros 2013-10-17 21:00:35 UTC
Hey, it seems that it will just pick .jsp and .html files:

282	        private boolean isStaticResource(String fileExt) {
283	            if ("html".equals(fileExt) || "jsp".equals(fileExt) || "xhtml".equals(fileExt)) {
284	                return true;
285	            }
286	            return false;
287	        }
288	

Why not jsf pages (.xhtml)? 

And images? Stylesheets? etc.
Comment 9 Martin Janicek 2013-10-18 09:23:44 UTC
The code you pasted is not valid (not sure what sources you are using). If you check-out Mercurial repository, you will see that xhtml, js, css files are handled as well.
You are right that images are missing, I'll add them. Anything else you can think of?
Comment 10 ymajoros 2013-10-22 07:08:26 UTC
I got the code it from an attachment to this issue.

Didn't check the repository, I believe you that it's ok there.
Comment 11 Martin Janicek 2013-10-22 08:29:13 UTC
Ok thanks, changing back to fixed ;)
Comment 12 lallafa 2014-04-02 16:16:19 UTC
Why restricting CoSsr for some extensions (html, jsp, xhtml, css, js) only?

I need it for Freemarker templates (*.ftl) too! I guess there are many more like *.txt, *.properties, *.xml, *.xls, ...
Comment 13 yastrebov 2014-04-21 14:46:13 UTC
To work with .ftl templates (NetBeans 8.0) you should check "Deploy on Save" and "Copy Static Resouces on Save" as a workaround.
Comment 14 pablopina 2014-04-26 06:55:25 UTC
Reopening as it doesnt' work properly for non-web maven projects. 

In our case, we are working on a maven javafx app on nb 8.0, we need to copy .css and .fxml file. +1 for a [] Copy Static Resources on Save checkbox above Compile On Save.
Comment 15 mehiel 2014-04-30 14:44:02 UTC
Copy Static Resources is a great addition to the IDE.

But IMHO we can't just hardcode what type of extensions should be considered static resources. There are even cases that an extension may be static resource in one project and dynamic on another. In my case I have .mustache templates that are evaluated client-side and they don't get copied. And .less files are missed too.

So we may have a basic set of static resources preconfigured and let the user fine-tune it both globally and per project.
Comment 16 pablopina 2014-05-01 00:42:37 UTC
I was thinking of just anything under src/main/resources -for maven-
Comment 17 mehiel 2014-05-01 09:30:18 UTC
(In reply to pablopina from comment #16)
> I was thinking of just anything under src/main/resources -for maven-

That's another way but I'm not sure if it's better than defining file extensions. 

And it won't be that simple if we want to follow every maven configuration. The IDE should get all the <resources/>, <warResources/> etc. (ok it does/knows that already for maven projects) and treat everything included in them as static resources, which may not be the case for every project out there.

I'll try to find some time to create a patch and see how it goes. The sure thing is that this is crucial for web developers because the case with version 8.0 until this is solved is worse than it was with 7.4. It reduces productivity a lot.
Comment 18 Martin Janicek 2014-05-02 09:24:50 UTC
Hi guys, thanks for your comments, I understand your issues. I would like to avoid situation where everyone would need to manage their own "list of static resources extension".

One possibility we could try is the one from comment 16.

Other I have in mind is simply the opposite approach which means put a list of what is not a static resource (that was actually the original purpose, to avoid java/groovy files). Which might be pretty simple for most usual use cases at least.

What do you think?
Comment 19 mehiel 2014-05-02 10:11:38 UTC
(In reply to Martin Janicek from comment #18)
> What do you think?

If we want to avoid over-configuration, sure what pablopina proposed (on comment 16) could work happily for most cases.

But I think we should avoid hardcode paths like "src/main/resources" or "src/main/webapp". We can get them from the project's pom/configuration, can't we?
Comment 20 Martin Janicek 2014-05-03 07:28:03 UTC
(In reply to mehiel from comment #19)
> But I think we should avoid hardcode paths like "src/main/resources" or
> "src/main/webapp". We can get them from the project's pom/configuration,
> can't we?

Ye, that shouldn't be a problem.
Comment 21 mehiel 2014-06-15 10:39:20 UTC
Any news on that?
Comment 22 verydapeng 2014-06-17 06:46:32 UTC
now it is very broken, i have to depend on an external watcher to sync the changes ...

for those who is using linux

here is a temp rescue 

inotifywait -r -m -e attrib -e modify $PROJ_SRC | while read line; do 
    rsync -r --ignore-existing $PROJ_SRC/* $SERVER_DEPLOYMENT
done
Comment 23 the_real_smithsos 2014-07-16 15:05:22 UTC
This also seems to ignore .jspf files.
Comment 24 Martin Janicek 2014-07-17 11:12:53 UTC
Fixed by change-set: web-main #de73823c63e8
Comment 25 mehiel 2014-07-17 15:35:57 UTC
(In reply to Martin Janicek from comment #24)
> Fixed by change-set: web-main #de73823c63e8

So it's working the other way around now. Instead of whitelisting static resources, it blacklist .java and .groovy files from copying on save. Seems like it solves all the cases mentioned above. Thanks Martin.
Comment 26 Martin Janicek 2014-07-17 16:48:20 UTC
(In reply to mehiel from comment #25)
> So it's working the other way around now. Instead of whitelisting static
> resources, it blacklist .java and .groovy files from copying on save. Seems
> like it solves all the cases mentioned above. Thanks Martin.

Ye, it was the simplest and safest way how to fix it for 8.0.1 ;)
Comment 27 Quality Engineering 2014-07-18 01:52:06 UTC
Integrated into 'main-silver', will be available in build *201407180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/de73823c63e8
User: Martin Janicek <mjanicek@netbeans.org>
Log: #218345 - Allow to copy static resources on save independently of Compile on Save
Comment 28 Martin Janicek 2014-07-30 12:30:51 UTC
*** Bug 236485 has been marked as a duplicate of this bug. ***
Comment 29 masengul 2014-12-20 12:50:10 UTC
hi.

i just saw this issue number on stackoverflow. after i read, i tried it in netbeans 8.0.2 and it works. it is great job. thanks for "copy static resurces on save" check box. 

before, when i unchecked deploy on save, also netbeans was not copying xhtml files. it was the biggest problem for us in big maven project.

thank you again for this fix.