@@ -4,6 +4,7 @@ import com.vanniktech.maven.publish.tasks.JavadocJar
44import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
55import org.jlleitschuh.gradle.ktlint.tasks.KtLintCheckTask
66import org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask
7+ import java.net.URI
78import com.vanniktech.maven.publish.JavadocJar as PublishJavadocJar
89
910plugins {
@@ -32,9 +33,9 @@ dependencies {
3233}
3334
3435val 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
3940kotlin {
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
6665dokka {
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