-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a local release of the reference checker (#189)
Co-authored-by: Chris Povirk <[email protected]>
- Loading branch information
Showing
8 changed files
with
166 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -333,3 +333,47 @@ eclipse.classpath { | |
} | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
jspecifyReferenceChecker(MavenPublication) { | ||
pom { | ||
groupId = 'org.jspecify.reference' | ||
artifactId = 'checker' | ||
version = project.version | ||
name = 'JSpecify Reference Checker' | ||
description = 'The JSpecify Reference Checker' | ||
url = 'http://jspecify.org/' | ||
from components.java | ||
licenses { | ||
license { | ||
name = 'The Apache License, Version 2.0' | ||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
} | ||
} | ||
scm { | ||
connection = 'scm:git:[email protected]:jspecify/jspecify-reference-checker.git' | ||
developerConnection = 'scm:git:[email protected]:jspecify/jspecify-reference-checker.git' | ||
url = 'https://github.com/jspecify/jspecify-reference-checker' | ||
} | ||
developers { | ||
developer { | ||
id = 'cpovirk' | ||
name = 'Chris Povirk' | ||
email = '[email protected]' | ||
} | ||
developer { | ||
id = 'netdpb' | ||
name = 'David P. Baker' | ||
email = '[email protected]' | ||
} | ||
developer { | ||
id = 'wmdietl' | ||
name = 'Werner M. Dietl' | ||
email = '[email protected]' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
org.jspecify\:jspecify=0.3.0 | ||
org.jspecify\:jspecify=1.0.0 | ||
org.jspecify.conformance\:conformance-test-framework=0.0.0-SNAPSHOT | ||
org.jspecify.conformance\:conformance-tests=0.0.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# JSpecify Reference Checker Usage Demo | ||
|
||
This is a simple demonstration for how a gradle project can use the JSpecify Reference Checker. | ||
|
||
Until the JSpecify Reference Checker is released to Maven Central, in the parent directory, | ||
one must first run: | ||
|
||
```` | ||
./gradlew PublishToMavenLocal | ||
```` | ||
|
||
to publish the JSpecify Reference Checker to the local Maven repository. | ||
|
||
Then, in the current `usage-demo` directory, one can run: | ||
|
||
```` | ||
../gradlew assemble | ||
```` | ||
|
||
to assemble the demo project and get a set of three expected error messages | ||
(plus one warning from Error Prone). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// EISOP Checker Framework and JSpecify Reference Checker example. | ||
|
||
plugins { | ||
id 'java' | ||
id 'com.diffplug.spotless' version '6.25.0' | ||
id 'net.ltgt.errorprone' version '3.1.0' | ||
id 'org.checkerframework' version '0.6.42' apply false | ||
} | ||
|
||
ext { | ||
versions = [ | ||
eisopVersion: '3.42.0-eisop4', | ||
jspecifyVersion: '1.0.0', | ||
jspecifyReferenceCheckerVersion: '0.0.0-SNAPSHOT' | ||
] | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
// Project dependencies, e.g. error prone. | ||
dependencies { | ||
errorprone 'com.google.errorprone:error_prone_core:2.23.0' | ||
} | ||
|
||
// Dependency on JSpecify annotations. | ||
dependencies { | ||
implementation "org.jspecify:jspecify:${versions.jspecifyVersion}" | ||
} | ||
|
||
|
||
apply plugin: 'org.checkerframework' | ||
|
||
// Configure EISOP and JSpecify Reference Checker | ||
dependencies { | ||
compileOnly "io.github.eisop:checker-qual:${versions.eisopVersion}" | ||
testCompileOnly "io.github.eisop:checker-qual:${versions.eisopVersion}" | ||
checkerFramework "io.github.eisop:checker:${versions.eisopVersion}" | ||
|
||
compileOnly "org.jspecify.reference:checker:${versions.jspecifyReferenceCheckerVersion}" | ||
checkerFramework "org.jspecify.reference:checker:${versions.jspecifyReferenceCheckerVersion}" | ||
} | ||
|
||
checkerFramework { | ||
checkers = [ | ||
'com.google.jspecify.nullness.NullSpecChecker', | ||
] | ||
extraJavacArgs = [ | ||
// Check implementation code, i.e. method bodies. | ||
'-AcheckImpl', | ||
// Output the EISOP version, to ensure configuration is correct. | ||
'-Aversion' | ||
] | ||
} | ||
|
||
spotless { | ||
java { | ||
target '**/*.java' | ||
googleJavaFormat() | ||
formatAnnotations() | ||
} | ||
groovyGradle { | ||
target '**/*.gradle' | ||
greclipse() | ||
indentWithSpaces(4) | ||
trimTrailingWhitespace() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Project name is read-only in build scripts, and defaults to directory name. | ||
rootProject.name = "jspecify-reference-checker-usage-demo" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package demo; | ||
|
||
import java.lang.reflect.Method; | ||
import org.jspecify.annotations.NullMarked; | ||
import org.jspecify.annotations.Nullable; | ||
|
||
@NullMarked | ||
class Demo { | ||
// Error about usage on primitive, also a warning from Error Prone. | ||
void conflict(@Nullable int i) {} | ||
|
||
Object incompatible(@Nullable Object in) { | ||
// Error about incompatible return. | ||
return in; | ||
} | ||
|
||
String deref(@Nullable Object in) { | ||
// Error about dereference of nullable reference. | ||
return in.toString(); | ||
} | ||
|
||
void jdkDemo(Method m) throws Exception { | ||
// Demo to ensure the jspecify/jdk is used. No error expected. eisop/jdk would give an error. | ||
m.invoke(null); | ||
} | ||
} |