Page 1 of 1

compiling docx4j - target 1.5

PostPosted: Thu Jun 30, 2011 2:06 pm
by jason
docx4j is intended to run on Java 1.5 (provided JAXB RI is on your path).

To support this, in the 2.7.0 release candidate maven pom.xml, we have:

<source>1.6</source>
<target>1.5</target>

The objective is to generate a jar which is compatible with Java 1.5, whilst at the same time allowing @Override annotations in the source code on methods which merely implement an interface (Java 6 allows this, but 1.5 gives an error).

When I played around with this, I found that both maven and ant would happily compile to target 1.5 with the pesky @Override annotations present (irrespective of whether source was set to 1.5 or 1.6 iirc).

Eclipse, however, requires that target be not less than source. (Not sure why; I think its semantics are just different) So in Eclipse, source must be 1.6 if you are to have @Override annotations on methods which merely implement an interface.

That is, unless m2eclipse is setting those properties. I found m2eclipse could set source=1.6, target=1.5. I haven't confirmed that exporting a jar in eclipse actually produces a 1.5 jar, but that's a secondary consideration (since we create jars via ant or maven, primarily).

Thoughts/comments?

Re: compiling docx4j - target 1.5

PostPosted: Thu Jun 30, 2011 8:45 pm
by tinne
Did you actually run this? using jdk 16.0_24, both maven 2.2.1 and 3.0.3 yield
Code: Select all
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
Failure executing javac, but could not parse the error:
javac: source release 1.6 requires target release 1.6

Then again, the javac documentation says
-source release
Specifies the version of source code accepted. The following values for release are allowed:
[...]
1.6
This is the default value. No language changes were introduced in Java SE 6. However, encoding errors in source files are now reported as errors, instead of warnings, as previously.

So, setting source and target to 1.5 seems to be perfectly reasonable to me (and makes more sense than compiling for 1.6, as special support for Java 5 JAXB is included).

Re: compiling docx4j - target 1.5

PostPosted: Thu Jun 30, 2011 9:57 pm
by jason
tinne wrote:Did you actually run this?


Evidently not! I got side tracked in checking that all the dependencies were compiled for 1.5, and then did the actual build via ant (where source and target are both set to 1.5).

So we're back to those settings in pom.xml as well, and left with the niggling annoyance that m2eclipse may set Eclipse's compiler settings to 1.5, which you then have to manually change back to 1.6.

Re: compiling docx4j - target 1.5

PostPosted: Fri Jul 01, 2011 9:31 am
by tinne
You could throw in these niggly eclipse configuration files from my project and suggest importing the folder as an existing project into a reasonably well equiped helios sp 2 (indigo is still missing most important plugins).

It is actually still missing the right formatter rules which could prevent me from all those merge conflict when merging with the official version of my own patches, but that could then be added.

Then again, some people prefer these ide specific files out of the SCMs.