Rebuild Project delete all the empty folders

Hi,

first of all, let me thank you for this greate tool. the community edition is really good. i have been using jcreator for more than 5 years and now changed to IDEA.

my question:

when i "Rebuild Project" it deletes all the empty folders even when "Clear output directory on rebuild" is unchecked. how to prevent this? these folders are used by the application when it is running.

23 comments
Comment actions Permalink

Hi Abdullah,
Thank you for the kind words.
As for the problem, could you please elaborate? Rebuild deletes everything only under the output roots and the contents of these roots is supposed to be recreated during rebuild (otherwise there is nothing to start).
If everything is recreated, there should be no problem.

Eugene

0
Comment actions Permalink

I am encountering the same issue. The reason that I can't have IDEA delete those folders is that I have the output (.class files) committed to subversion. (Yes, I know, that's not standard. But for a number of good reasons I need to do it.)

So in the output path, there is a .svn directory containing a bunch of stuff that can't be deleted. Every time I go to Rebuild, it wipes out part of the .svn folder, which screws up subversion.

Is there any way to turn that behavior off? Or is there a way to "point" the Rebuild command to a custom ANT script target, instead of running the built-in (and broken) version?

Thanks,
Mason

0
Comment actions Permalink

My src files and all other project files/folders are under the output path. my structure is like:

- Project folder   (module compile output path)
     - src     (Source folder, all the files have "package classes;")
     - classes     (project compiler output, contains compiled classes)
     - lib
     - .....

some of the folders are empty and removed while rebuild.

0
Comment actions Permalink

Hi Mason,

I think unchecking "Settings | Compiler | Clear output directory on rebuild" will do the job.

Eugene.

0
Comment actions Permalink

Hi Abdullah,

I can suggest 2 options here:
1. just uncheck the "Clear output directory" setting (see my comment above)
2. I must admit your output paths configuration is a little bit non-standard. I'd reconfigured project so that the output paths contained only files produced by compilers.

Regards,
Eugene

0
Comment actions Permalink

Hi Abdullah and Eugene,  Thanks for the advice. But I DO have the "clear output directory" option UNCHECKED, and it still deletes empty directories. If I check this option, it removes ALL contents. It seems that there is an invisible "clear empty directories in the output folder" option that is always selected.  Anybody else know how to turn this behavior off?  Does anyone from the IDEA team read this forum?  Thanks, Mason

0
Comment actions Permalink

mfreed wrote:

Hi Abdullah and Eugene,  ...  Does anyone from the IDEA team read this forum?

Ummm... Eugene, the guy who's responded to your posts, is from the IDEA team. Hence the Jet Brains logo in his avatar ;)

The remvoal of empty directotries even when the "clear output directory" option is not selected would appear to unexpcted behavior. I would suggest opening an issue report for it: http://youtrack.jetbrains.net

0
Comment actions Permalink

Oops - sorry Eugene. I didn't notice your profile.

Mark, thanks for the suggestion. I've created a new bug report at:  http://youtrack.jetbrains.net/issue/IDEA-65067.

Thanks,
Mason

0
Comment actions Permalink

Forgot to mention that IDEA indeed clears the stuff that is about to be recompiled and this is done always. The option controls only whether to "wipe" output on rebuild or not. Not clearing old class files and dirs may lead to incorrect make, so this cannot be done.
Alternatively, you may remap compilation shortcuts to any action that will invoke the building process that suits your needs.

Eugene.

0
Comment actions Permalink

Hi Eugene,

Thanks for the clarification. But I still don't quite understand. When you say that "IDEA clears the stuff that is about to be recompiled", I assume you mean that it clears the .class files that it is about to re-write. I totally understand that, and there's no issue there. My problem is that it ALSO clears empty directories, such as ".svn\tmp\prop-base" which are in no way related to what is it about to recompile. Its that last thing that causes me problems.

I love your second suggestion, to remap the compilation shortcuts to my own ANT script (or similar). HOWEVER, how do I do that? I want the Build-->Rebuild Project menu item to point to my own ANT target that properly cleans and builds. I can't find any configuration option that let's me reconfigure what anything in the Build menu does. Help!

Thanks,
Mason

0
Comment actions Permalink

> My problem is that it ALSO clears empty directories, such as ".svn\tmp\prop-base" which are in no way

Unless the option is checked, this should not be the case. IDEA cleans only those files that produced itself. And I cannot reproduce this for any type of compilation (make/rebuild/compile). Probably I miss some important points. If you could send me a test project illustrating the problem with the instructions, I'd appreciated that.

As for assigning a shortcut to an ant target. First you should add your ant script to the ant view. You can open your ant file, invoke context menu with the right mouse click and choose "Add as Ant build file" action.
Then from the ant toolwindow you may assign shortcuts to targets.

Eugene.

0
Comment actions Permalink

attached is a test project. rebuild project will remove the empty folder



Attachment(s):
Test.zip
0
Comment actions Permalink

Thanks Abdullah - I appreciate it.

Eugene, I also copied Abdullah's test project to the YouTrack bug I created: http://youtrack.jetbrains.net/issue/IDEA-65067

Thanks,
Mason

0
Comment actions Permalink

Hi Eugene,

I just wanted to follow up on your instructions for incorporating an ANT script. I have done everything you said, except that I can't figure out how to assign an ANT target to the "Build-->Rebuild Project" menu item. Sure, I can create my own keyboard shortcut to execute an ANT target, but that's not what we're talking about here. How do I remap the "Build-->Rebuild Project" menu item?

Thanks,
Mason

0
Comment actions Permalink

Ah, ok, I see now.
The problem here might be in your setup. It is a good idea for the output directory not to be the same as module's content root, but instead a completely separate dir. That way rebuild will not clear the directory "empty folder" from your project.
In this setup, unfortunately, your content root has also a different role (an output directory) and because of that is deleted as a part of rebuild process. Rebuild has always deleted empty directories under the output root because there is no practical sense in them and they "pollute" the output. The flag "clear output directories on rebuild" defines the way data cleared and does not present and option whether to clear data or not. Strictly speaking, make should also clear empty directories, but this is sacrificed for efficiency. So rebuild is the only way to get really clean output in terms of empty directories.

Regards,
  Eugene

0
Comment actions Permalink

Hi Mason,
It is not possible to remap the Rebuild menu item.
However, a menu item corresponding to your ant target will be present in the "Build" menu at the bottom. There is an action group containing all registered ant scripts.

Eugene.

0
Comment actions Permalink

i was just trying to get the same structure when i was developing with jcreator. i want flat structure, src/classes/resources are all directories in the same level. it gives flexibilty when you want to compile your project from command line and develop your scripting on the same root folder. i don't know how to do it? i don't want test/production environment or anything like this.

0
Comment actions Permalink

Hi Abdullah,

I'd suggest to switch to maven layout then because it's the most wide spread one.

Regards, Denis

0
Comment actions Permalink

thanks for the suggestion. i will try to change my layout. it seems it is better to do it now than later.

0
Comment actions Permalink

Just point your module output path to the "clasess" directory instead of module content root and that's it.

0
Comment actions Permalink

yes but in this case i will have classes/classes/*.class files because i have "package classes;" in all of my codes.
i have seperated the output to a specific folder as per the default configuration for IntelliJ.

thanks again.

0
Comment actions Permalink

> classes/classes/*.class files because i have "package classes;" in all of my codes.

Yes, and this is absolutely correct, provided your package is indeed named "classes". The output root will in turn be a default package.

Regards,
  Eugene.

0

Please sign in to leave a comment.