Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions artifactory/commands/gradle/resources/jfrog.init.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
import org.gradle.util.GradleVersion

def artifactoryUrl = '{{ .ArtifactoryURL }}'
def gradleRepoName = '{{ .GradleRepoName }}'
def artifactoryUsername = '{{ .ArtifactoryUsername }}'
def artifactoryAccessToken = '{{ .ArtifactoryAccessToken }}'
def gradleVersion = GradleVersion.current()
def allowInsecure = gradleVersion >= GradleVersion.version("6.2") && artifactoryUrl.startsWith("http://")

void configureMavenRepo(repositories, String rtUrl, String rtUser, String rtPass, boolean allowInsecure) {
repositories.maven {
url rtUrl
credentials {
username = rtUser
password = rtPass
}
// This is used when Artifactory is running in HTTP mode
if (allowInsecure) {
allowInsecureProtocol = true
}
}
}

// Configure the pluginManagement repositories
gradle.settingsEvaluated { settings ->
settings.pluginManagement {
repositories {
maven {
url "${artifactoryUrl}/${gradleRepoName}"
credentials {
username = artifactoryUsername
password = artifactoryAccessToken
}
}
if (artifactoryUrl.startsWith("http://")) {
allowInsecureProtocol = true
}
configureMavenRepo(it, "${artifactoryUrl}/${gradleRepoName}", artifactoryUsername, artifactoryAccessToken, allowInsecure)
gradlePluginPortal() // Fallback to Gradle Plugin Portal
}
}
}

// Configure the project repositories
allprojects { project ->
project.repositories {
maven {
url "${artifactoryUrl}/${gradleRepoName}"
credentials {
username = artifactoryUsername
password = artifactoryAccessToken
}
if (artifactoryUrl.startsWith("http://")) {
allowInsecureProtocol = true
}
}
configureMavenRepo(it, "${artifactoryUrl}/${gradleRepoName}", artifactoryUsername, artifactoryAccessToken, allowInsecure)
}
}