Multiple language level packages in a single source directory

I find myself in an awkward situation with my project structure. It
looks something like this:

- ProjectRoot
- build
- Build output, including classes and product distribution
- src
- dist
- Base files for product distribution
- java
- com...
- java-test
- com...
- resources
- ...

Now the problem is that the "java" directory contains multiple packages
which are compiled with different JDKs. I.e. some packages are
compiled with 1.3, some with 1.4 and some with 5.0. There are good
reasons for this, mainly because the packages compiled with 1.3 are
required to run in environments where only JDK 1.3 is available. The 1.4
packages run in our own Java environment which we control and therefore
can use 1.4. The 5.0 packages are for supporting features available in
5.0 JVMs.

Our Ant build script handles this without a problem. Just a few filesets
and everything compiles.

However, in IDEA, I can't separate the packages into modules for 1.3,
1.4 and 5.0 because IDEA won't let me define two modules with the same
content root and exclude the packages I don't want for each module. I
have a single module with "java" as a source root, the JDK set to 1.4
and the language level set to 1.4. This worked reasonably well until we
started adding 5.0 code.

How do I solve this? I don't want to have to split it into separate
projects. One solution would be to split the "java" directory into
"java-13", "java-14" and "java-50", but I don't think that would be
received very well by project management :P In the long run, it may be
the best solution though.

But in the meantime, is there anything I can do to make IDEA work with
the directory structure I have now?

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://www.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001

4 comments
Comment actions Permalink

No suggestions? No comments? Am I completely unique in my project setup?

Ciao,
Gordon

0
Comment actions Permalink

I've been confronted with this painful situation too where I had 1.3,
1.4 and 1.5 sources in the same project. IDEA has been very
difficult to work with there.

I was lucky enough to be able to split all the 1.5 stuff into a separate
module with different content root. I kept the 1.3/1.4 sources mixed
(1.3-only classes were few) and had IDEA deal with them as 1.4.
Build was entirely done with ant. IDEA-built classes went into an
idea-only output path to prevent IDEA from killing the 1.3-built
classes (only useful for debugging).

Unfortunately, 1.5 features threw a big wrench in the already not-so-bright
picture. IDEA doesn't support module-specific language levels so I had to
set it to 1.5. From there, having modules of different JDK levels completely
confused IDEA which kept marking most generics (but not all) as errors
in the 1.5 module and trying to convert my 1.4 constructs into 1.5
constructs
in all the others.

I have tracker issues related to these problems but apparently it would
require
lots of architectural changes to allow for module-specific language levels.
In
your case, you're also facing the inability for multiple modules to have
overlapping content roots.

Good luck with this setup, sounds like you're in for some trouble ;)
(If you find a good working solution I'm definitely interested as I
occasionally
have to maintain the project I mentioned).

Vince.




0
Comment actions Permalink

The probable solution would be introducing several modules avoiding single
root issue by specifying package prefix to the source roots.
For instance:

com
intellij
some13code [ this covered by module13 content root = source root with
com.intellij.some13code package prefix]
some14code [ this covered by module14 content root = source root with
com.intellij.some14code package prefix]

Would that work?


-


Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"

I find myself in an awkward situation with my project structure. It
looks something like this:

- ProjectRoot
- build
- Build output, including classes and product distribution
- src
- dist
- Base files for product distribution
- java
- com...
- java-test
- com...
- resources
- ...
Now the problem is that the "java" directory contains multiple
packages which are compiled with different JDKs. I.e. some packages
are compiled with 1.3, some with 1.4 and some with 5.0. There are good
reasons for this, mainly because the packages compiled with 1.3 are
required to run in environments where only JDK 1.3 is available. The
1.4 packages run in our own Java environment which we control and
therefore can use 1.4. The 5.0 packages are for supporting features
available in 5.0 JVMs.

Our Ant build script handles this without a problem. Just a few
filesets and everything compiles.

However, in IDEA, I can't separate the packages into modules for 1.3,
1.4 and 5.0 because IDEA won't let me define two modules with the same
content root and exclude the packages I don't want for each module. I
have a single module with "java" as a source root, the JDK set to 1.4
and the language level set to 1.4. This worked reasonably well until
we started adding 5.0 code.

How do I solve this? I don't want to have to split it into separate
projects. One solution would be to split the "java" directory into
"java-13", "java-14" and "java-50", but I don't think that would be
received very well by project management :P In the long run, it may be
the best solution though.

But in the meantime, is there anything I can do to make IDEA work with
the directory structure I have now?

Ciao,
Gordon



0
Comment actions Permalink

Maxim Shafirov (JetBrains) wrote:

The probable solution would be introducing several modules avoiding
single root issue by specifying package prefix to the source roots.
For instance:

com
intellij
some13code [ this covered by module13 content root = source root with
com.intellij.some13code package prefix]
some14code [ this covered by module14 content root = source root with
com.intellij.some14code package prefix]

Would that work?


That's what I've done, although I'm still not able to use different
language levels for each module, which was my main goal. I can use the
correct JDK for each module, but the language level is project-wide. At
the moment it's set to 1.4 because that's the best compromise and we
have only a few Java 5 classes.

However, we're very seriously contemplating moving major parts of our
project to Java 5 in the not-too-distant future, so having support for
per-module language level settings is going to become far more important
for us.

If you're wondering, we can't move our entire product to Java 5 because
some of it has to run inside customers' existing appserver VMs which are
generally either 1.3 or 1.4. Only the newest appservers being released
now, like WebLogic 9, use Java 5 out of the box.

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://www.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001

0

Please sign in to leave a comment.