|
| 1 | +/* |
| 2 | + * MIT License |
| 3 | + * |
| 4 | + * Copyright (c) 2024 Nima Karimipour |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in |
| 14 | + * all copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | + * THE SOFTWARE. |
| 23 | + */ |
| 24 | + |
| 25 | +import net.ltgt.gradle.errorprone.CheckSeverity |
| 26 | + |
| 27 | +plugins{ |
| 28 | + id "net.ltgt.errorprone" version "4.1.0" apply false |
| 29 | +} |
| 30 | + |
| 31 | +subprojects { |
| 32 | + apply plugin: "java" |
| 33 | + apply plugin: "net.ltgt.errorprone" |
| 34 | + |
| 35 | + repositories { |
| 36 | + mavenLocal() |
| 37 | + mavenCentral() |
| 38 | + google() |
| 39 | + } |
| 40 | + |
| 41 | + def libraryloader = project.getProperty("library-model-loader-path") |
| 42 | + |
| 43 | + repositories { |
| 44 | + mavenLocal() |
| 45 | + mavenCentral() |
| 46 | + } |
| 47 | + |
| 48 | + dependencies { |
| 49 | + if(project.name != "Target"){ |
| 50 | + compileOnly project(":Target") |
| 51 | + annotationProcessor files(libraryloader) |
| 52 | + } |
| 53 | + annotationProcessor "com.uber.nullaway:nullaway:" + System.getenv('NULLAWAY_TEST_VERSION') |
| 54 | + annotationProcessor "edu.ucr.cs.riple.annotator:annotator-scanner:" + System.getenv('ANNOTATOR_VERSION') |
| 55 | + |
| 56 | + // to add @Initializer |
| 57 | + compileOnly "com.uber.nullaway:nullaway-annotations:" + System.getenv('NULLAWAY_TEST_VERSION') |
| 58 | + // to add jetbrains annotations (testing type use vs type declaration) |
| 59 | + compileOnly 'org.jetbrains:annotations:24.0.0' |
| 60 | + compileOnly "org.jspecify:jspecify:0.3.0" |
| 61 | + compileOnly "com.google.code.findbugs:jsr305:3.0.2" |
| 62 | + errorprone "com.google.errorprone:error_prone_core:2.31.0" |
| 63 | + errorproneJavac "com.google.errorprone:javac:9+181-r4173-1" |
| 64 | + } |
| 65 | + |
| 66 | + tasks.withType(JavaCompile) { |
| 67 | + // remove the if condition if you want to run NullAway on test code |
| 68 | + if (!name.toLowerCase().contains("test")) { |
| 69 | + options.errorprone.disableAllChecks = true |
| 70 | + options.errorprone.disableAllWarnings = true |
| 71 | + options.errorprone { |
| 72 | + check("NullAway", CheckSeverity.WARN) |
| 73 | + check("AnnotatorScanner", CheckSeverity.WARN) |
| 74 | + option("NullAway:AnnotatedPackages", "test") |
| 75 | + option("NullAway:SerializeFixMetadata", "true") |
| 76 | + option("NullAway:FixSerializationConfigPath", project.getProperty(project.name + "-nullaway-config-path")) |
| 77 | + option("NullAway:AcknowledgeLibraryModelsOfAnnotatedCode", "true") |
| 78 | + option("NullAway:JSpecifyMode", project.getProperty("jspecify")) |
| 79 | + option("AnnotatorScanner:ConfigPath", project.getProperty(project.name + "-scanner-config-path")) |
| 80 | + } |
| 81 | + } |
| 82 | + options.compilerArgs << "-Xmaxerrs" << "100000" |
| 83 | + options.compilerArgs << "-Xmaxwarns" << "100000" |
| 84 | + options.fork = true |
| 85 | + } |
| 86 | +} |
0 commit comments