@@ -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,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
6670dokka {
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