1
1
/*
2
- * Copyright 2002-2017 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
5
* use this file except in compliance with the License. You may obtain a copy of
13
13
* License for the specific language governing permissions and limitations under
14
14
* the License.
15
15
*/
16
-
17
16
package io.spring.gradle.convention
18
17
19
18
import org.gradle.api.Plugin
@@ -22,23 +21,50 @@ import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
22
21
23
22
class ArtifactoryPlugin implements Plugin<Project > {
24
23
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
+
25
42
@Override
26
43
void apply (Project project ) {
27
44
project. plugins. apply(' com.jfrog.artifactory' )
28
45
String name = Utils . getProjectName(project);
29
46
boolean isSnapshot = Utils . isSnapshot(project);
30
47
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 )
31
54
project. artifactory {
32
- contextUrl = ' https://repo.spring.io '
55
+ contextUrl = artifactoryUrl
33
56
publish {
34
57
repository {
35
- repoKey = isSnapshot ? ' libs-snapshot-local ' : isMilestone ? ' libs-milestone-local ' : ' libs-release-local '
58
+ repoKey = isSnapshot ? snapshotRepository : isMilestone ? milestoneRepository : releaseRepository
36
59
if (project. hasProperty(' artifactoryUsername' )) {
37
60
username = artifactoryUsername
38
61
password = artifactoryPassword
39
62
}
40
63
}
41
64
}
65
+ if (projectKey != null ) {
66
+ clientConfig. info. setProject(projectKey)
67
+ }
42
68
}
43
69
project. plugins. withType(MavenPublishPlugin ) {
44
70
project. artifactory {
0 commit comments