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 49215 - inconsistency - ant build vs. automatic updating of files in build/*
Summary: inconsistency - ant build vs. automatic updating of files in build/*
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: Web Project (show other bugs)
Version: 4.x
Hardware: All All
: P4 blocker (vote)
Assignee: Pavel Buzek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-17 17:54 UTC by Pavel Buzek
Modified: 2016-07-07 08:55 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel Buzek 2004-09-17 17:54:37 UTC
The web module code is trying to keep the build
folder in sync with the web sources by updating
the files in build whenever the user saves,
renames, deletes, etc. the files in web sources
(see #46446). This is potentially inconsistent
with the way the Ant build builds the web module.

We are using Ant for building and the semantics of
build can be changed by various tasks overridden
by the user. The easiest way to break this is to
just define a filter in Packaging Project tab of
project properties - this will be ignored by the
java code that does automatic updates in build/*.
Even if we make the java code clever to cover
couple cases like that we will never get it work
right 100%. What if I have a -post-compile task
that changes all files after copying them.

So, mixing Ant with some clever java code is
dangerous and takes all the nice flexibility out.
And it can never be fixed since the semantics of
ant is unknown (bcs it can be overriden by user). 

I found the following solution for doing the
rename/delete/move synchronization but it is
implemented in build script so it does not get
done automatically on save. It requires the user
to build or run the project. Perhaps we could run
this ant task on Save asynchronously using an
unobtrusive progress bar or something...

The solution is Ant's sync task introduced in 1.6.
It synchronizes two directories doing all the
rename/delete/copy stuff. I am playing with it and
it seems to do what we want.

The only problem is that it interferes with the
way we currently create WEB-INF/classes under
build/web folder. The sync task naturally deletes
this because it is not in 'web' folder in source.
This is not acceptable, we need to preserve
WEB-INF/classes folder if nothing has changed -
first to avoid having to compile classes and
second to avoid unnecessary deployment steps (the
j2eeserver uses timestamps to figure out what
needs to be done).

I found a solution for this in defining a separate
folder into which the java classes are first
compiled and then copying them into
build/web/WEB-INF/classe. The content of build
directory would then look like:

build
   +-java
     +-WEB-INF
        +-classes
          +-mypackage
            +-Servlet.class
   +-web
     +-META-INF
       +-context.xml
     +-WEB-INF
        +-web.xml
        +-classes
          +-mypackage
            +-Servlet.class
     +-index.jsp

This way I let the sync task copy both the
projectHome/web and projectHome/build/java and it
works. The structure under java folder has to
follow the placement under build/web. The only
disadvantage is the extra copying of java classes.
I think this is worth the improvement.
Comment 1 Pavel Buzek 2004-09-17 18:40:24 UTC
not targeted for 4.0
Comment 2 Pavel Buzek 2004-09-24 19:37:19 UTC
Also see issue #45273 Remove library - doesn't clean project.
Comment 3 Pavel Buzek 2005-02-22 18:15:50 UTC
no user ever complained about this, changing to an enhancement, P4
Comment 4 ruhej 2006-02-14 13:46:30 UTC
I run in this issue today in our standard web-projekt ( 5.0 ).

I defined a filter in the build.xml file which replaces some tokens ( urls in
jsp and html files ). But every time I save a html/jsp-file It gets copied with
no tokens replaced into the build folder ( which is the web-root for our
external tomact ).

My workaround was to add overwrite="true" to the copy-task in the -copy-webdir
target so everytime I build the projekt all files are copied ( and the tokens
replaced ).

I would appreciate the possibility to turn the CopyOnSaveSupport functionality
off in a web-projekt.

Comment 5 Martin Balin 2016-07-07 08:55:39 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss