Trying to use Maven without needing the checker framework installed ahead of time. - Google Groups
tldr; The old way created unexpected behavior and failed typechecking when building multi-module projects, or using libraries compiled by Maven. I believe we have a way to use the Checker Framework as you'd like and I will open an issue for it.
Why we switched:
The primary reasons we moved Maven integration from a plugin based approach to using the Maven compiler plugin were:
1) Not all compiler preferences were inherited by the Checker Framework plugin. This means that checking might use compiler settings that differ from the arguments supplied by the developer via the Maven Compiler plugin.
2) #1 wouldn't be a problem but, to ensure proper type-checking of multi-module projects, or when using a library compiled by Maven, the Checker Framework needs to generate class-files which overwrite those created by the compiler. The reason the Checker Framework needs to generate class-files is that it inserts the type annotations into the bytecode to facilitate typechecking with the resulting library. Any generated bytecode should use the identical settings (especially the -target setting) as the compiler plugin but this was not always the case due to #1.
3) Inconsistency. Maven may invoke the compiler for tasks throughout the lifecycle (though usually just during compilation). If the compiler plugin is run after running maven checkers:check then the class files will no longer contain the annotations in bytecode, furthermore, if the settings between the Checker Framework and Maven Compiler plugin differ, there might be other issues (like two different -target versions).
Replacing the compiler with ours (which is what we do in Ant, Gradle, etc...) resolves these issues. However, it would be good to be able to specify the Checker Framework as a dependency in Maven and have all of the appropriate jars etc... downloaded and used by Maven without further configuration.
To do this, I propose that we add one more maven artifact to Maven central: our javac_maven script written so that it will run on Windows, Mac, and Linux (this is possible though ugly). Update the script so that it will identify the correct paths to the Maven artifacts of the version of the Checker Framework specified. Finally, in the Checker Framework manual, indicate that the <executable/> element of the Maven compiler should point to the artifact path of the Checker Framework. That is, the compiler configuration would have a line:
<executable>${maven.dependency.org.checkerframework .script.path }</excutable>
If we made the rest of the Checker Framework dependencies for the script, the only Maven configuration you would have to do is include the script as a dependencies with the version you wanted. I will open an issue explaining this change and we'll try to handle it in a timely manner.
Read full article from Trying to use Maven without needing the checker framework installed ahead of time. - Google Groups
No comments:
Post a Comment