Skip to content

Commit 1e76756

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

File tree

3 files changed

+39
-24
lines changed

3 files changed

+39
-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: 35 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,24 @@ 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 =
64+
providers.zip(
65+
gitHubUrl,
66+
gitHubRepo,
67+
{ x, y -> "$x/$y" },
68+
)
6569

6670
dokka {
6771
moduleName = rootProject.name
6872
dokkaPublications.html {
6973
failOnWarning = true
7074
}
7175
dokkaSourceSets.main {
72-
jdkVersion = javaVersion.asInt()
73-
sourceLink {
74-
localDirectory = file(sourceRoots.asPath)
75-
remoteUrl("https://$gitHubRepoUrl")
76-
}
76+
jdkVersion = javaVersion.map { it.asInt() }
7777
}
7878
}
7979

@@ -100,7 +100,7 @@ mavenPublishing {
100100
pom {
101101
name = "$projectGroup:${rootProject.name}"
102102
description = projectDescription
103-
url = "https://$gitHubRepoUrl"
103+
url = gitHubRepoUrl
104104
licenses {
105105
license {
106106
name = licenseName
@@ -110,13 +110,28 @@ mavenPublishing {
110110
developers {
111111
developer {
112112
id = gitHubUsername
113-
url = "https://github.com/$gitHubUsername"
113+
url =
114+
providers.zip(
115+
gitHubUrl,
116+
gitHubUsername,
117+
{ x, y -> "$x/$y" },
118+
)
114119
}
115120
}
116121
scm {
117-
connection = "scm:git:git://$gitHubRepoUrl.git"
118-
developerConnection = "scm:git:ssh://github.com:$gitHubRepo.git"
119-
url = "https://$gitHubRepoUrl"
122+
connection =
123+
providers.zip(
124+
gitHubDomain,
125+
gitHubRepo,
126+
{ x, y -> "scm:git:git://$x/$y.git" },
127+
)
128+
developerConnection =
129+
providers.zip(
130+
gitHubDomain,
131+
gitHubRepo,
132+
{ x, y -> "scm:git:ssh://$x:$y.git" },
133+
)
134+
url = gitHubRepoUrl
120135
}
121136
}
122137
}

0 commit comments

Comments
 (0)