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.
This is why makefiles/pom.xml/build.xml get checked in. Use your revision control system to create a branch. In one branch, make all the changes needed for 1.6 compatibility. In the other branches, don't. Any given branch will either safely compile for 1.4 or safely compile for 1.6, with no frankenbranches that try to do both at once, which is a Bad Idea(tm).
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With