Skip to content

Commit 804a0c7

Browse files
Merge branch '3.2.x'
Closes gh-2760
2 parents 79f64cd + a1837e3 commit 804a0c7

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

buildSrc/src/main/groovy/io/spring/gradle/convention/ArtifactoryPlugin.groovy

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
55
* use this file except in compliance with the License. You may obtain a copy of
@@ -13,7 +13,6 @@
1313
* License for the specific language governing permissions and limitations under
1414
* the License.
1515
*/
16-
1716
package io.spring.gradle.convention
1817

1918
import org.gradle.api.Plugin
@@ -22,23 +21,50 @@ import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
2221

2322
class ArtifactoryPlugin implements Plugin<Project> {
2423

24+
private static final String ARTIFACTORY_URL_NAME = "ARTIFACTORY_URL"
25+
26+
private static final String ARTIFACTORY_SNAPSHOT_REPOSITORY = "ARTIFACTORY_SNAPSHOT_REPOSITORY"
27+
28+
private static final String ARTIFACTORY_MILESTONE_REPOSITORY = "ARTIFACTORY_MILESTONE_REPOSITORY"
29+
30+
private static final String ARTIFACTORY_RELEASE_REPOSITORY = "ARTIFACTORY_RELEASE_REPOSITORY"
31+
32+
private static final String ARTIFACTORY_PROJECT_KEY = "ARTIFACTORY_PROJECT_KEY";
33+
34+
private static final String DEFAULT_ARTIFACTORY_URL = "https://repo.spring.io"
35+
36+
private static final String DEFAULT_ARTIFACTORY_SNAPSHOT_REPOSITORY = "libs-snapshot-local"
37+
38+
private static final String DEFAULT_ARTIFACTORY_MILESTONE_REPOSITORY = "libs-milestone-local"
39+
40+
private static final String DEFAULT_ARTIFACTORY_RELEASE_REPOSITORY = "libs-release-local"
41+
2542
@Override
2643
void apply(Project project) {
2744
project.plugins.apply('com.jfrog.artifactory')
2845
String name = Utils.getProjectName(project);
2946
boolean isSnapshot = Utils.isSnapshot(project);
3047
boolean isMilestone = Utils.isMilestone(project);
48+
Map<String, String> env = System.getenv()
49+
String artifactoryUrl = env.getOrDefault(ARTIFACTORY_URL_NAME, DEFAULT_ARTIFACTORY_URL)
50+
String snapshotRepository = env.getOrDefault(ARTIFACTORY_SNAPSHOT_REPOSITORY, DEFAULT_ARTIFACTORY_SNAPSHOT_REPOSITORY)
51+
String milestoneRepository = env.getOrDefault(ARTIFACTORY_MILESTONE_REPOSITORY, DEFAULT_ARTIFACTORY_MILESTONE_REPOSITORY)
52+
String releaseRepository = env.getOrDefault(ARTIFACTORY_RELEASE_REPOSITORY, DEFAULT_ARTIFACTORY_RELEASE_REPOSITORY)
53+
String projectKey = env.get(ARTIFACTORY_PROJECT_KEY)
3154
project.artifactory {
32-
contextUrl = 'https://repo.spring.io'
55+
contextUrl = artifactoryUrl
3356
publish {
3457
repository {
35-
repoKey = isSnapshot ? 'libs-snapshot-local' : isMilestone ? 'libs-milestone-local' : 'libs-release-local'
58+
repoKey = isSnapshot ? snapshotRepository : isMilestone ? milestoneRepository : releaseRepository
3659
if(project.hasProperty('artifactoryUsername')) {
3760
username = artifactoryUsername
3861
password = artifactoryPassword
3962
}
4063
}
4164
}
65+
if (projectKey != null) {
66+
clientConfig.info.setProject(projectKey)
67+
}
4268
}
4369
project.plugins.withType(MavenPublishPlugin) {
4470
project.artifactory {

0 commit comments

Comments
 (0)