How to organize classpath - trying to delete a file from library

Hi,

I am a little confused about how to organize my classpath in IJ 6.0.

We have project organized like this:

projectroot
classes - compiled java classes
dist - distribution / build
rsrc - resources like property files, images, icons, configurations
src - java code files

In order to run the application from within the IDE rsrc and some subdirectories need to be in the classpath. Intuitively or naively, I configured those directories as a module library. Since IntelliJ 6.0, this had the effect that rsrc and its subdirs where not shown under project root anymore (in the project tree) but under the library node, which I found annoying but I accepted it. Today, I tried to delete a file in subdirectory of rsrc and IntelliJ responded with the message Detach library dialog. Huh? I never intended this. However, I was not able to delete the file from within the project tree at all.

So, I came to the conclusion, that I may do project configuration not as intended. Therefore I ask how my situation can be solved. Is there a way to attach a directory to IntelliJ's classpath without including it to a library? Probably it is easy and I am to blind to find it.

Still, I find when I try to delete a file in a library from within the project tree, IJ should not detach the library, but should ask whether the file should be deleted and removed from the library.


Kind regards

Thomas Gülden
Munich, Germany

2 comments

Thomas Gülden wrote:

I am a little confused about how to organize my classpath in IJ 6.0.

We have project organized like this:

projectroot
classes - compiled java classes
dist - distribution / build
rsrc - resources like property files, images, icons, configurations
src - java code files

So, I came to the conclusion, that I may do project configuration not
as intended. Therefore I ask how my situation can be solved. Is there
a way to attach a directory to IntelliJ's classpath without including
it to a library? Probably it is easy and I am to blind to find it.


Mark the directory as a 'Source Folder' under the appropriate content
root and ensure that there are resource patterns (in the compiler
settings) for all resources you want copied to the output path on
compilation. This should be all that you need for a simple case. The
directories will no longer appear in the libraries node but you do end
up with duplicated resources in the source and compiler output paths
(which may or may not be a problem for you).

If your needs are more esoteric then the package prefix option (the
button with the P icon that appears next to a source folder) is very useful.

My current project has (to borrow some of your directory names):

projectroot
rsrc
foo
bar
...
...
images

and I need both 'foo' and 'images' to appear at the root of the
classpath (so that foo/bar/... and images/.... are both found). Marking
both directories as source folders and specifying a path prefix of
'images' for the images directory makes this work exactly as I need.
Truly wonderful.

HTH.

--
Mark Scott
mark@codebrewer.com

0

Hi Mark,

Thanks for your help. It worked partly but not completely, due to some code internals, which we aren't responsible for and which we not gonna change because the IDE cannot cope with it due to the changes how it handles its classpath issues.

And your approach means that with every rebuild all resources need to be copied (including all the help files) which is something we only do when we make new build for our test environment.

I came now to the solution to create a new library called Resources to which I add rsrc and some of its subdirectories, and add rsrc as a source directory. This way it keeps showing up in the project tree. To avoid that the resource files get copied during each rebuild I exclueded them from compile.

Still, I think this way of project setup adds unnecessary complexity, it should be possible to simply add directories to the classpath without the necessity to add them to a library. Maybe this is possible by other means, which I don't see.

Kind regards

Thomas Gülden
Munich, Germany

0

Please sign in to leave a comment.