Community
Participate
Working Groups
I tried to set up an ant build script which uses Cheetah rev. 006 to compile my sources based on JRE 1.5. Unfortunately the switch "-1.5" is not yet enabled in the method setupJavacCommand() of JDTCompilerAdapter.class. There is a hardcoded comparison to JAVA_1_4 too, which leads to a "-1.3" if your environment is 1.5.
I will investigate.
Created attachment 13218 [details] Here is the source patch to apply on HEAD Let me know if it works fine.
Created attachment 13219 [details] Here is the binary patch. Override the existing file in the jdt.core plugin
Works fine for me. Thanks for the fast response and solution! I only wonder if it is desired not to be able to define the compliance via "- 1.3", "-1.4" and "-1.5" from within an ant script.
We thought about it, but we decided that it was more convenient to set the compliance according to the VM used to run the batch compiler. The other solution would be to do it using the compilerarg nested element. The problem is that we don't control what options are available for the javac ant task. Is this fine for you?
I agree that the current behaviour is convenient. It would have saved me some time if the adapter would have produced a warning like "Unknown VM Version, default compliance used". In addtion it should generate a warning if you specify a compliance at all (like "compliance is set according to VM: ignoring <-1.5>"). The errormessage which comes from the batch compiler itself wasn't useful ("duplicate compliance setting specification: -1.5").
I can change the way to ant adapter is working and then you would have a way to set the compliance level inside the compilerarg. It would not be set anymore using the VM used to run the build. Then you would not end up with the error message you got. Any suggestion is appreciated. The compliance level is something specific to the Eclipse compiler, because it has to behave like javac 1.3, javac 1.4 or javac 1.5. javac doesn't have this issue. The compliance level is implicitely the one for the javac version you are running. We wanted to make it as easy as possible to set up right. I can add this warning if you want: "Unknown VM Version, default compliance used" But I still believe it should be set without user interference.
I agree that usage should be as convenient as possible. I started trying the "-1.5" switch after having read the documentation provided in http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/jdt-core- home/howto/batch%20compile/batchCompile.html. I didn't know that it is set automatically. I suggest you add warnings like "Unknown VM Version, default compliance used" and "Compliance is set according to VM, compliance switch ignored". That would give a good feedback to what is happening.
I added the warning "Unknown VM Version, default compliance used" in which case I don't set any compliance (the default one is used). I might also change the batch compiler to allow two compliance settings on the same command line. The last one would be the one used to compile and a warning would be reported if two are specified.
The solution we will adopt is to add an extra argument in the constructor of the batch compiler to pass custom default arguments. The "guessed" compliance would simply be a new default. Therefore if none are specified in the nested compiler argument, the new default would be used. Otherwise the one that the user specified would be the one used for the compilation. Do you like this solution?
The solution with a new argument that sets the custom options is flexible enough to enable any argument in the nested compiler argument. Fixed and released in HEAD.