加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build.gradle 3.87 KB
一键复制 编辑 原始数据 按行查看 历史
import net.ltgt.gradle.errorprone.CheckSeverity
import org.gradle.internal.jvm.Jvm
buildscript {
dependencies {
classpath libs.androidPlugin
classpath libs.robovmPlugin
}
repositories {
mavenCentral()
google()
jcenter()
gradlePluginPortal()
}
}
plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.errorprone) apply false
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.protobuf) apply false
alias(libs.plugins.animalsniffer) apply false
alias(libs.plugins.googleJavaFormat) apply false
}
subprojects {
repositories {
mavenCentral()
google()
jcenter()
}
tasks.withType(JavaCompile).configureEach { task ->
task.options.encoding = 'UTF-8'
}
plugins.withType(JavaBasePlugin).configureEach {
java.toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
tasks.withType(Test).configureEach {
testLogging {
if (System.getenv("CI") == "true") {
events = ["failed", "skipped", "passed"]
}
exceptionFormat "full"
}
}
apply plugin: 'net.ltgt.errorprone'
dependencies {
errorproneJavac libs.errorproneJavac
errorprone libs.errorproneCore
}
tasks.withType(JavaCompile).configureEach { task ->
task.options.errorprone {
excludedPaths = '.*/build/generated/source/proto/.*'
check('MissingFail', CheckSeverity.ERROR)
check('MissingOverride', CheckSeverity.ERROR)
check('UnusedException', CheckSeverity.ERROR)
check('UnusedMethod', CheckSeverity.ERROR)
check('UnusedNestedClass', CheckSeverity.ERROR)
check('UnusedVariable', CheckSeverity.ERROR)
}
}
plugins.withId('java-library') {
// Animal Sniffer only works on JDK 11 or older currently.
if (!Jvm.current().javaVersion.isJava12Compatible()) {
project.apply plugin: 'ru.vyarus.animalsniffer'
animalsniffer {
sourceSets = [sourceSets.main] // Only check main sources, ignore test code.
}
dependencies {
signature 'org.codehaus.mojo.signature:java18:1.0@signature'
if (project.path != ':retrofit-converters:java8' &&
project.path != ':retrofit-converters:jaxb' &&
project.path != ':retrofit-converters:jaxb3' &&
project.path != ':retrofit-adapters:java8') {
signature 'net.sf.androidscents.signature:android-api-level-21:5.0.1_r2@signature'
}
}
}
// google-java-format only works on JDK 11 to JDK 15 (without wild flags).
if (Jvm.current().javaVersion.isJava11Compatible() && !Jvm.current().javaVersion.isCompatibleWith(JavaVersion.VERSION_16)) {
project.apply plugin: 'com.github.sherter.google-java-format'
googleJavaFormat {
toolVersion = '1.16.0'
// By default, the GJF plugin includes all Java folders inside the project directory. This
// does not work well with nested projects, especially when you want to exclude them.
source = sourceSets*.allJava
}
afterEvaluate {
def verify = tasks.getByName('verifyGoogleJavaFormat')
tasks.getByName('check').dependsOn(verify)
def prompt = tasks.create('promptGoogleJavaFormat') {
doLast {
println()
println('To automatically format, run "./gradlew googleJavaFormat"')
println()
}
onlyIf { verify.state.failure != null }
}
verify.finalizedBy(prompt)
}
}
}
plugins.withType(com.android.build.gradle.BasePlugin).configureEach { plugin ->
// Can remove this once https://issuetracker.google.com/issues/260059413 is fixed.
plugin.extension.compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
pluginManager.withPlugin("com.vanniktech.maven.publish") {
mavenPublish {
sonatypeHost = "S01"
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化