Community
Participate
Working Groups
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 ...
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?
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 ...
Does it still occur if you manually refresh after running the external Ant command ?
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) ...
I see. Ping'ing platform for comments about auto-refreshing before building ? Or should we rather introduce refresh action on failures only ?
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.
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.
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.
Closing. Manual refresh is required when external ant scripts are run.