Skip to content

Commit a920e31

Browse files
author
Abhijit Sarkar
committed
Configure things lazily
1 parent 704932f commit a920e31

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Like [GrpcCleanupRule](https://grpc.github.io/grpc-java/javadoc/io/grpc/testing/
66
JUnit 5 and actively maintained.
77

88
[![Sponsor](https://img.shields.io/badge/Sponsor-%E2%9D%A4-black?style=for-the-badge&logo=github&color=%23fe8e86)](https://github.com/sponsors/asarkar)
9-
[![CI](<https://img.shields.io/github/actions/workflow/status/asarkar/grpc-test/ci.yml?branch=main&style=for-the-badge&logo=github>)](https://github.com/asarkar/grpc-test/actions?query=workflow%3A%22CI+Pipeline%22)
9+
[![CI](<https://img.shields.io/github/actions/workflow/status/asarkar/grpc-test/ci.yml?branch=main&style=for-the-badge&logo=github>)](https://github.com/asarkar/grpc-test/actions?query=workflow%3A%22CI%20Pipeline%22)
1010
[![Maven](https://img.shields.io/maven-central/v/com.asarkar.grpc/grpc-test?style=for-the-badge&logo=apachemaven)](https://central.sonatype.com/artifact/com.asarkar.grpc/grpc-test?smo=true)
1111
[![Javadoc](https://javadoc.io/badge2/com.asarkar.grpc/grpc-test/javadoc.svg?style=for-the-badge&logo=readthedocs&logoColor=white)](https://javadoc.io/doc/com.asarkar.grpc/grpc-test)
1212
[![License](https://img.shields.io/github/license/asarkar/grpc-test?style=for-the-badge&logo=apache&color=blue)](https://www.apache.org/licenses/LICENSE-2.0)

client/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ dependencies {
2626
}
2727

2828
val javaVersion =
29-
JavaLanguageVersion.of(
30-
rootDir.resolve(".java-version").readText(Charsets.UTF_8).trim(),
31-
)
29+
providers
30+
.provider { rootDir.resolve(".java-version").readText(Charsets.UTF_8).trim() }
31+
.map(JavaLanguageVersion::of)
3232

3333
java {
3434
toolchain {

lib/build.gradle.kts

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.vanniktech.maven.publish.tasks.JavadocJar
44
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
55
import org.jlleitschuh.gradle.ktlint.tasks.KtLintCheckTask
66
import org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask
7+
import java.net.URI
78
import com.vanniktech.maven.publish.JavadocJar as PublishJavadocJar
89

910
plugins {
@@ -32,9 +33,9 @@ dependencies {
3233
}
3334

3435
val javaVersion =
35-
JavaLanguageVersion.of(
36-
rootDir.resolve(".java-version").readText(Charsets.UTF_8).trim(),
37-
)
36+
providers
37+
.provider { rootDir.resolve(".java-version").readText(Charsets.UTF_8).trim() }
38+
.map(JavaLanguageVersion::of)
3839

3940
kotlin {
4041
jvmToolchain {
@@ -55,25 +56,19 @@ ktlint {
5556
additionalEditorconfig = mapOf("max_line_length" to "100")
5657
}
5758

58-
val gitHubUsername: String by lazy {
59-
System.getenv("GITHUB_REPOSITORY_OWNER") ?: project.findProperty("gitHubUsername") as String
60-
}
61-
val gitHubRepo: String by lazy {
62-
System.getenv("GITHUB_REPOSITORY") ?: "$gitHubUsername/${rootProject.name}"
63-
}
64-
val gitHubRepoUrl: String by lazy { "github.com/$gitHubRepo" }
59+
val gitHubUsername = providers.environmentVariable("GITHUB_REPOSITORY_OWNER")
60+
val gitHubRepo = providers.environmentVariable("GITHUB_REPOSITORY")
61+
val gitHubUrl = providers.environmentVariable("GITHUB_SERVER_URL")
62+
val gitHubDomain = gitHubUrl.map { URI(it).host }
63+
val gitHubRepoUrl = gitHubUrl.zip(gitHubRepo, { x, y -> "$x/$y" })
6564

6665
dokka {
6766
moduleName = rootProject.name
6867
dokkaPublications.html {
6968
failOnWarning = true
7069
}
7170
dokkaSourceSets.main {
72-
jdkVersion = javaVersion.asInt()
73-
sourceLink {
74-
localDirectory = file(sourceRoots.asPath)
75-
remoteUrl("https://$gitHubRepoUrl")
76-
}
71+
jdkVersion = javaVersion.map { it.asInt() }
7772
}
7873
}
7974

@@ -100,7 +95,7 @@ mavenPublishing {
10095
pom {
10196
name = "$projectGroup:${rootProject.name}"
10297
description = projectDescription
103-
url = "https://$gitHubRepoUrl"
98+
url = gitHubRepoUrl
10499
licenses {
105100
license {
106101
name = licenseName
@@ -110,13 +105,17 @@ mavenPublishing {
110105
developers {
111106
developer {
112107
id = gitHubUsername
113-
url = "https://github.com/$gitHubUsername"
108+
url = gitHubUrl.zip(gitHubUsername, { x, y -> "$x/$y" })
114109
}
115110
}
116111
scm {
117-
connection = "scm:git:git://$gitHubRepoUrl.git"
118-
developerConnection = "scm:git:ssh://github.com:$gitHubRepo.git"
119-
url = "https://$gitHubRepoUrl"
112+
connection = gitHubDomain.zip(gitHubRepo, { x, y -> "scm:git:git://$x/$y.git" })
113+
developerConnection =
114+
gitHubDomain.zip(
115+
gitHubRepo,
116+
{ x, y -> "scm:git:ssh://$x:$y.git" },
117+
)
118+
url = gitHubRepoUrl
120119
}
121120
}
122121
}

0 commit comments

Comments
 (0)