typetools / checker-framework

Pluggable type-checking for Java
http://checkerframework.org/
Other
990 stars 347 forks source link

SBT Support #3862

Closed sirinath closed 3 years ago

sirinath commented 3 years ago

Can SBT support be added.

mernst commented 3 years ago

Yes! Would you be willing to contribute it? I assume you are an SBT user, which none of the Checker Framework developers is. Therefore, you can do this much more efficiently than we can, and you can test it in real-world scenarios which we cannot.

The introduction to the "Integration with external tools" chapter (before the first section) gives some hints about how to get started.

sirinath commented 3 years ago

I am not that familiar with SBT internals.

mernst commented 3 years ago

To write a plugin might require use of SBT internals. To write a manual section about how to change your own build files should be possible without knowledge of SBT internals. Would you be willing to do that? Thanks in advance.

sirinath commented 3 years ago

Is the Checker Framework configured through java options?

sirinath commented 3 years ago

Can you specify all checkers?

mernst commented 3 years ago

Is the Checker Framework configured through java options?

Yes. The Introduction says:

These checkers are easy to use and are invoked as arguments to javac.

That is also explained in the "Integration with external tools" chapter, which says:

If your build system or IDE is not listed above, you should customize how it runs the javac command on your behalf. See your build system or IDE documentation to learn how to customize it, adapting the instructions for javac in Section 35.6.

sirinath commented 3 years ago

I think you can do something like javacOptions ++= Seq( ... )

sirinath commented 3 years ago

Following would be a way to get it working:

JDK 8

javacOptions ++= Seq(
    "-J-Xbootclasspath/p:$CHECKERFRAMEWORK/checker/dist/javac.jar",
    "-cp $CHECKERFRAMEWORK/checker/dist/checker-qual.jar",
    "-processorpath $CHECKERFRAMEWORK/checker/dist/checker.jar",
    "-processor org.checkerframework.checker.nullness.NullnessChecker",
    "-source 8", "-target 8"
  )

JDK 11

mernst commented 3 years ago

Thank you for these details. I have created a pull request to put them in the manual.

sirinath commented 3 years ago

Can you mention an all available processor list on one place so this line can be directly copied for the javac options?

mernst commented 3 years ago

Do you mean the list that appears in https://checkerframework.org/manual/#introduction?

I don't think it's good style to run every possible checker. The manual recommends starting with just one, so I don't want to violate this recommendation in the new section by showing a verbose -processor argument that includes every checker.

I have added a cross-reference to section 2.2, however. Does that help?

sirinath commented 3 years ago

Yes. But you can add a table/list of processors which you can choose from.

mernst commented 3 years ago

Where in the manual would you like that table/list to appear?

sirinath commented 3 years ago

Better under command line where the checkers are listed out.

mernst commented 3 years ago

You said "in the intro", but the list is already in the introduction. It's literally the 4th sentence in the manual.

mernst commented 3 years ago

OK, you edited your comment from "in the intro" to "Better under command line where the checkers are listed out." I don't understand what you are referring to. Can you be more specific, with a concrete reference to a manual section?

sirinath commented 3 years ago

All information is scattered around in the manual. So you can have:

It can be 2 appendices if it turns out to be too long.

mernst commented 3 years ago

I'm going to merge the pull request now, since it addresses the original issue.

A distinct issue is creating an appendix that mixes together all information about all checkers. If you wish to do that, please open a pull request for it.

Thanks again for the SBT instructions; I appreciate it!