Bug 43190 - no compilation if output dir does not exist
Summary: no compilation if output dir does not exist
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 3.0 M5   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-16 21:43 EDT by Jens Elkner CLA
Modified: 2003-11-14 07:26 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Elkner CLA 2003-09-16 21:43:41 EDT
E.g.: 

Project Properties | Java Build Path  
default output folder: $project/build/classes

If $project/build does not exist, 'Build All' does nothing (it does even NOT
issue a warning message)!

If one tries to 'Run' the class, a message is displayed, like:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/linofee/sitemenu/Start

So the developer starts digging, what could be wrong, but usually the last 
thing he probably expects is, that no class file[s] exist at all ...
Comment 1 Olivier Thomann CLA 2003-09-17 09:19:29 EDT
I tried to change the output dir to a path that doesn't exist and it is
automacally created for me.
The only problem I see is that in this case I can see it in the package
explorer, but I have no problem to compile files.
How did you change the output folder? Did you directly edit the .classpath file?
Comment 2 Jens Elkner CLA 2003-09-18 09:24:05 EDT
Output folder was set as described via 'Project Properties | Java Build Path',
i.e. no manual editing of .classpath.

However, I found a way to reproduce the problem:
0) I'm in the Java perspective (probably doesn't really matter)
1) Build the project via 'Project | Rebuild Project' (build/classes is created
   automatically)
2) in a terminal, cd ~/workspace/project and run 'ant clean':
   <property name="dist.dir"          location="dist"/>
   <property name="build.dir"         location="build"/>
   <target name="clean">
     <delete dir="${build.dir}"/>
     <delete dir="${dist.dir}"/>
   </target>
3) Try 'Run | $Start' - now get get the class not found error.
   I guess, if one invokes 'Run | ...', eclipse doesn't make 
   any checks for updates wrt. src AND targets ...
4) If you now try to save a file within the editor (incremental builds enabled),
   one gets a warning about "A class file was not written. The project may 
   be ...". The tail of the message is usually not visable, since cells in
   "Problems Table" are not multi-line capable ...
   Furthermore, one gets a lot of warnings/errors wrt. unresolvable classes...

BTW: You may ask, why the developer invokes ant at the command line. Answer:
     Because "Run | Ant ..." via eclipse is magnitudes slower and resource
     consuming, than the invocation of ant with the required target on the 
     cmd line ...
Comment 3 Philipe Mulet CLA 2003-09-27 05:25:59 EDT
Does it still occur if you manually refresh after running the external Ant 
command ?
Comment 4 Jens Elkner CLA 2003-09-27 18:29:04 EDT
No - after a manual refresh it works. 
However, IMHO eclipse should be able to handle such cases automatically 
(i.e. if it is not there, it should make/build the project automatically) ...
Comment 5 Philipe Mulet CLA 2003-09-29 04:53:17 EDT
I see. 

Ping'ing platform for comments about auto-refreshing before building ? Or 
should we rather introduce refresh action on failures only ?
Comment 6 John Arthorne CLA 2003-09-29 11:39:24 EDT
Our policy is generally that refreshes don't happen for free.  That's why the
"Run ant..." option in Eclipse has a tab to choose what to refresh after running
the script.  One possible solution is to use the IResource.FORCE flag when
writing/deleting in the output directory. This will ignore out of sync problems
and succeed with the operation.  Since the output dir only contains
auto-generated files, this seems acceptable. Catching out of sync errors and
refreshing is another option.

I think for 3.0 we are leaning towards releasing the auto-refresh plug-in, which
will quickly reconcile differences between the workspace and the file system,
thus making these errors less likely.
Comment 7 Kent Johnson CLA 2003-09-29 11:45:34 EDT
We already use the FORCE flag on writes & deletes.

IMO its up to the user to trigger a refresh, especially when he knows he just 
ran an ant script outside of Eclipse.
Comment 8 Philipe Mulet CLA 2003-09-29 12:17:39 EDT
Agreed. An incremental build without existing class files is pointless. 
Necessary action is first refresh then rebuild all.

Note that even if running an Ant script inside Eclipse, and wiping out our 
output folder, then the incremental build will be doomed as well.
Comment 9 Kent Johnson CLA 2003-10-17 13:17:23 EDT
Closing.

Manual refresh is required when external ant scripts are run.