-
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.
Add sample project to execute Annotator (#260)
This PR introduces a sample script to easily run the Annotator on the example provided in the README. The script handles downloading annotator JAR and is designed to work directly within the project without requiring any hardcoded values, making it straightforward to execute. Also resolves minor issues in the README have been addressed, and it now reflects recent changes for better clarity and accuracy. This PR does not fully address #255 but is a good start.
- Loading branch information
1 parent
f8fb0ea
commit 98163b2
Showing
11 changed files
with
539 additions
and
92 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2024 University of California, Riverside. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
# | ||
|
||
# download annotator-core.jar from maven repository | ||
curl -O https://repo.maven.apache.org/maven2/edu/ucr/cs/riple/annotator/annotator-core/1.3.15/annotator-core-1.3.15.jar | ||
|
||
# make an EMPTY directory for the annotator output | ||
annotator_out_dir="$(pwd)/sample/annotator-out" | ||
rm -rvf "$annotator_out_dir" && mkdir -p "$annotator_out_dir" | ||
|
||
# make paths.tsv and add the placed nullaway_config_path and scanner_config_path | ||
scanner_config_path="$(pwd)/sample/annotator-out/scanner.xml" | ||
nullaway_config_path="$(pwd)/sample/annotator-out/nullaway.xml" | ||
echo -e "$nullaway_config_path\t$scanner_config_path" > sample/annotator-out/paths.tsv | ||
|
||
# run the annotator | ||
java -jar annotator-core-1.3.15.jar \ | ||
-bc "cd $(pwd)/sample && ./gradlew compileJava" \ | ||
-d "$annotator_out_dir" \ | ||
-n javax.annotation.Nullable \ | ||
-cp sample/annotator-out/paths.tsv \ | ||
-cn NULLAWAY \ | ||
-i com.uber.nullaway.annotations.Initializer \ | ||
-sre org.jspecify.annotations.NullUnmarked |
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,68 @@ | ||
/* | ||
* Copyright (c) 2024 University of California, Riverside. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
import net.ltgt.gradle.errorprone.CheckSeverity | ||
|
||
plugins { | ||
id 'java' | ||
id "net.ltgt.errorprone" version "2.0.1" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
annotationProcessor "com.uber.nullaway:nullaway:0.10.10" | ||
// Add annotator scanner | ||
annotationProcessor "edu.ucr.cs.riple.annotator:annotator-scanner:1.3.15" | ||
|
||
// add required annotation dependencies | ||
// Initializer | ||
compileOnly 'com.uber.nullaway:nullaway-annotations:0.10.10' | ||
// Nullable annotations | ||
compileOnly "com.google.code.findbugs:jsr305:3.0.2" | ||
// JSpecify annotations for NullUnmarked | ||
compileOnly "org.jspecify:jspecify:0.3.0" | ||
|
||
annotationProcessor "com.uber.nullaway:nullaway:0.10.10" | ||
errorprone "com.google.errorprone:error_prone_core:2.4.0" | ||
errorproneJavac "com.google.errorprone:javac:9+181-r4173-1" | ||
} | ||
|
||
def scanner_config_path = "${project.projectDir.absolutePath}/annotator-out/scanner.xml" | ||
def nullaway_config_path = "${project.projectDir.absolutePath}/annotator-out/nullaway.xml" | ||
|
||
|
||
tasks.withType(JavaCompile).configureEach { | ||
if (!name.toLowerCase().contains("test")) { | ||
options.errorprone { | ||
check("NullAway", CheckSeverity.ERROR) | ||
check("AnnotatorScanner", CheckSeverity.ERROR) | ||
option("NullAway:AnnotatedPackages", "edu.ucr.cs.riple") | ||
option("NullAway:SerializeFixMetadata", "true") | ||
option("NullAway:FixSerializationConfigPath", nullaway_config_path) | ||
option("AnnotatorScanner:ConfigPath", scanner_config_path) | ||
} | ||
options.compilerArgs << "-Xmaxerrs" << "100000" | ||
options.compilerArgs << "-Xmaxwarns" << "100000" | ||
} | ||
} |
Binary file not shown.
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,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.