com.uber.infer.InferJavaPlugin.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of infer-plugin Show documentation
Show all versions of infer-plugin Show documentation
Gradle integration for infer static analyzer.
The newest version!
package com.uber.infer
import com.uber.infer.extension.InferPluginExtension
import com.uber.infer.task.*
import com.uber.infer.util.ConfigurationUtils
import org.gradle.api.Plugin
import org.gradle.api.Project
/**
* Infer plug-in for standard Java projects.
*/
class InferJavaPlugin implements Plugin {
@Override
void apply(Project project) {
def checkForInferTask = project.tasks.create(Constants.TASK_CHECK_FOR_INFER, CheckForInfer)
def inferCaptureTask = project.tasks.create(Constants.TASK_PREPARE_FOR_INFER, PrepareForInfer) {
bootClasspath = {
null
}
compileDependencies = {
project.configurations.getByName("compile")
}
processorDependencies = {
ConfigurationUtils.getAvailable(project, 'apt')
}
providedDependencies = {
ConfigurationUtils.getAvailable(project, 'provided', 'compileOnly')
}
sourceFiles = {
project.sourceSets.main.java
}
sourceJavaVersion = {
project.sourceCompatibility
}
targetJavaVersion = {
project.targetCompatibility
}
eradicateExclude = {
project.eradicate.exclude
}
eradicateInclude = {
project.eradicate.include
}
inferExclude = {
project.infer.exclude
}
inferInclude = {
project.infer.include
}
}
inferCaptureTask.dependsOn(checkForInferTask)
// Required to ensure dependency artifacts are available.
inferCaptureTask.dependsOn("processResources")
def eradicateTask = project.tasks.create(Constants.TASK_ERADICATE, Eradicate)
eradicateTask.dependsOn(inferCaptureTask)
eradicateTask.setGroup(Constants.GROUP)
eradicateTask.setDescription("Runs Infer's eradicate static analysis.")
def inferTask = project.tasks.create(Constants.TASK_INFER, Infer)
inferTask.dependsOn(inferCaptureTask)
inferTask.setGroup(Constants.GROUP)
inferTask.setDescription("Runs Infer static analysis.")
project.extensions.create(Constants.EXTENSION_INFER_PLUGIN_NAME, InferPluginExtension, project)
def deleteInferConfigTask = project.tasks.create("deleteInferConfig", DeleteInferConfig)
inferTask.finalizedBy(deleteInferConfigTask)
eradicateTask.finalizedBy(deleteInferConfigTask)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy