typetools / typetools/checker-framework
No easy way to load stubs as Maven dependencies
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
I am using the Checkerframework in a Maven multi-modules project. For an external dependency I had to create a stubs file. The stubs file is part of a jar, which I create in a dedicated Maven module, so that I can reuse it.
According to the documentation and my searches on the Internet, the only way to use it is via -Astubs=....
All examples I have seen use a full qualified path (-Astubs=/some/dir/my.jar). For a Maven project, serveral persons contribute too, each one using his own directory structure, it is impossible to rely on a hard coded path.
So, it would be very helpful and would make it much easier use custom, project specific stub files, it it would be possible to put them simply in a jar and add it to the classpath, so that it is available during compilation.
Currently I use the following workaround currently to my jar as Maven artifact:
<compilerArgs combine.children="append">
<arg>-Aproject=${project.groupId}/${project.artifactId}</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
<arg>-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
<!-- Workaround to use the jar with stubs -->
<arg>-Astubs=${settings.localRepository}/com/example/checker-stubs/${project.version}/checker-stubs-${project.version}.jar</arg>
<arg>-AstubWarnIfNotFound</arg>
<arg>-AstubDebug</arg>
</compilerArgs>
Or is there a better way to achive my goal?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the -Astubs option resolves paths and how Maven's compilerArgs supplies the checker classpath. Reproduce the multi-module Maven setup with a stub JAR, then define completion as loading that JAR without a hard-coded repository path and verify the existing -AstubWarnIfNotFound and -AstubDebug behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100