Skip to content

Commit

Permalink
guestAuth fixed for .kts scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jk1 committed Oct 23, 2019
1 parent 2ca2e1b commit ee8c867
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/kotlin/com/github/jk1/tcdeps/KotlinScriptDslAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.gradle.api.artifacts.ModuleDependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.artifacts.dsl.RepositoryHandler
import org.gradle.api.artifacts.repositories.IvyArtifactRepository
import org.gradle.internal.artifacts.repositories.AuthenticationSupportedInternal

object KotlinScriptDslAdapter {

Expand All @@ -31,13 +32,11 @@ object KotlinScriptDslAdapter {
val tcUrl = repo.url.toString()
val normalizeTcUrl = if (tcUrl.endsWith('/')) tcUrl else "$tcUrl/"

if (repo.credentials != null) {
if (repo.credentials.username.orEmpty().isBlank() || repo.credentials.password.orEmpty().isBlank()) {
throw GradleException("Teamcity repository login and password cannot be empty")
}
repo.setUrl("${normalizeTcUrl}httpAuth/repository/download")
} else {
if (repo.credentials.username.orEmpty().isBlank() && repo.credentials.password.orEmpty().isBlank()) {
(repo as AuthenticationSupportedInternal).configuredCredentials = null
repo.setUrl("${normalizeTcUrl}guestAuth/repository/download")
} else {
repo.setUrl("${normalizeTcUrl}httpAuth/repository/download")
}
repositories.add(repo)
return repo
Expand Down

0 comments on commit ee8c867

Please sign in to comment.