Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Gradle scripts to be compatible with Gradle 7 #99

Merged
merged 1 commit into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build-flags.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ if (!projectsWithFlags('java').isEmpty()) {
apply from: "${libDir}/java-versionprops.gradle"
apply from: "${libDir}/java-publish.gradle"
}

if (!projectsWithFlags('kotlin').isEmpty()) {
apply from: "${libDir}/kotlin.gradle"
}
4 changes: 2 additions & 2 deletions lib/common-dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.yaml.snakeyaml.Yaml
buildscript {
repositories {
mavenCentral()
jcenter()
gradlePluginPortal()
}

dependencies {
Expand Down Expand Up @@ -76,7 +76,7 @@ configure(dependencyManagementProject) {
apply plugin: com.github.benmanes.gradle.versions.VersionsPlugin

repositories {
jcenter()
google()
// Since we manage plugin versions here too.
gradlePluginPortal()
mavenCentral()
Expand Down
7 changes: 7 additions & 0 deletions lib/java-rpc-proto.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ configure(projectsWithFlags('java')) {
if (processResourcesTask != null) {
processResourcesTask.dependsOn(task)
}

def sourcesJarTask = tasks.findByName(sourceSet.getTaskName('sources', 'jar'))
if (sourcesJarTask) {
// A workaround for 'sourcesJar' uses this output of task ':generateProto' without
// declaring an explicit or implicit dependency.
sourcesJarTask.dependsOn(task)
}
project.ext.getGenerateSourcesTask().dependsOn(task)
}
}
Expand Down
5 changes: 5 additions & 0 deletions lib/java-rpc-thrift.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ configure(projectsWithFlags('java')) {
description: "Compiles the ${sourceSet.name} .thrift files."
])

def sourcesJarTask = project.tasks.findByName(sourceSet.getTaskName('sources', 'jar'))
if (sourcesJarTask) {
sourcesJarTask.dependsOn(task)
}

// Use afterEvaluate to give subprojects a chance to override the properties.
project.afterEvaluate {
def srcDirs = project.findProperty(sourceSet.getTaskName('', 'thriftSrcDirs'))
Expand Down
1 change: 1 addition & 0 deletions lib/java-versionprops.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ configure(projectsWithFlags('java', 'publish')) {
}

// Ensure version.properties is available during the build.
tasks.sourcesJar.dependsOn(tasks.versionProperties)
tasks.processResources.dependsOn(tasks.versionProperties)
}
6 changes: 6 additions & 0 deletions lib/java.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ configure(projectsWithFlags('java')) {
sourceSet.java.srcDir file("${project.ext.genSrcDir}/${sourceSet.name}/java")
sourceSet.resources.srcDir file("${project.ext.genSrcDir}/${sourceSet.name}/resources")
}
afterEvaluate {
Task generateSourcesTask = project.tasks.findByName('generateSources')
if (generateSourcesTask != null) {
tasks.sourcesJar.dependsOn(generateSourcesTask)
}
}

java {
withJavadocJar()
Expand Down
35 changes: 35 additions & 0 deletions lib/kotlin.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
configure(projectsWithFlags('kotlin')) {

apply plugin: 'kotlin'
apply plugin: "org.jlleitschuh.gradle.ktlint"

def target = "1.8"
def compilerArgs = ["-Xjsr305=strict", "-java-parameters"]
compileKotlin {
kotlinOptions.jvmTarget = target
kotlinOptions.freeCompilerArgs = compilerArgs
}
compileTestKotlin {
kotlinOptions.jvmTarget = target
kotlinOptions.freeCompilerArgs = compilerArgs
}

ktlint {
// https://github.com/pinterest/ktlint/issues/764
version.set("0.36.0")
verbose.set(true)
reporters {
reporter "html"
}
// https://github.com/pinterest/ktlint/issues/527
disabledRules = ["import-ordering"]

filter {
exclude("**/gen-src/**")
}
}

// A workaround for 'runKtlintCheckOverMainSourceSet' uses this output of task ':generateProto' without
// declaring an explicit or implicit dependency.
tasks.runKtlintCheckOverMainSourceSet.dependsOn(project.ext.getGenerateSourcesTask())
}