I'm working on a large legacy codebase that currently only compiles with java 1.4. One of the things that I need to do is to get it working with 1.6 (well probably 1.7 now).
The head build doesn't currently compile with 1.6. This is for lots of reasons - most are easy to fix, like using enum
as a keyword, but we're struggling with Oracle/Sun updating the JDBC (Connection interface) to support types that are not available in java 1.4. This means if I make the changes to work with 1.6, the main production builds break as classes like NClob
break as they aren't in the 1.4 release; if I don't make the changes, I can't compile with the 1.6 compiler.
Are there any patterns to support conditional compilation/build in java? My only plan I've thus far come up with was to fiddle with the ant build to conditionally swap in/out classes depending on the build. This feels pretty horrible, hence asking the community here for thoughts.
Again, the boundaries on the problem are:
HEAD
on 1.4 (no 1.6 with 1.4 compatibility mode I'm afraid):(
)Many Thanks in advance.
There is a previous SO answer that covers this, essentially using ant's replace
task to make a quick and dirty version of IFDEF blocks. That would probably be easier than swapping out whole class files, and would make it easier to go full 1.6 whenever you can (just remove all of the 1.4 IFDEF blocks)