Skip to content

Commit 089505a

Browse files
committed
fix(Gradle): fix credentials checking in recent gradle releases
Signed-off-by: Mateusz Los <mateusz.los@extern.wenovate.de>
1 parent 4eccaca commit 089505a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

plugins/package-managers/gradle-plugin/src/main/kotlin/GradleModelExtensions.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import org.gradle.api.artifacts.Configuration
2525
import org.gradle.api.artifacts.dsl.RepositoryHandler
2626
import org.gradle.api.artifacts.repositories.ArtifactRepository
2727
import org.gradle.api.artifacts.repositories.AuthenticationSupported
28+
import org.gradle.api.artifacts.repositories.PasswordCredentials
2829
import org.gradle.api.artifacts.repositories.UrlArtifactRepository
2930
import org.gradle.api.attributes.AttributeContainer
3031
import org.gradle.internal.deprecation.DeprecatableConfiguration
@@ -71,7 +72,10 @@ internal fun RepositoryHandler.associateNamesWithUrlsTo(repositories: MutableMap
7172
* Convert this [UrlArtifactRepository] to an [OrtRepository] by extracting the relevant properties.
7273
*/
7374
internal fun UrlArtifactRepository.toOrtRepository(): OrtRepository {
74-
val credentials = (this as? AuthenticationSupported)?.credentials
75+
val credentials = (this as? AuthenticationSupported)?.let { authSupported ->
76+
runCatching { authSupported.getCredentials(PasswordCredentials::class.java) }.getOrNull()
77+
}
78+
7579
return OrtRepositoryImpl(
7680
url = url.toString(),
7781
username = credentials?.username,

0 commit comments

Comments
 (0)