-
Notifications
You must be signed in to change notification settings - Fork 11
/
artifactory.gradle
65 lines (58 loc) · 2.12 KB
/
artifactory.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
publishing {
publications {
mavenJava(MavenPublication) {
groupId cbGroup
artifactId project.name
version cbVersion
from components.java
artifact sourceJar
artifact javadocJar
pom.withXml { xmlProvider ->
// Create string from project.ext.pomXml
def pomString = new StringWriter()
pomXml.writeTo(pomString)
pomString = pomString.toString()
// Replace default xml with pomXml
def xmlStringBuilder = xmlProvider.asString()
xmlStringBuilder.setLength(0)
xmlStringBuilder.append(pomString)
}
pom.withXml {
def root = asNode()
if (root.dependencies) {
// eliminate test-scoped dependencies (no need in maven central POMs)
/* TODO: not working
root.dependencies.removeAll { dep ->
(dep.scope.text() == 'test')
}
*/
root.dependencies.get(0).dependency.each() { dep ->
String pomVer = dep.get("version").text();
String pomArtifactId = dep.get("artifactId").text();
String pomGroupId = dep.get("groupId").text();
if(pomVer.isEmpty()){
def depVer = project.dependencyManagement.dependencyManagementContainer.globalDependencyManagement.versions["$pomGroupId:$pomArtifactId"]
dep.appendNode('version',depVer)
}
}
}
}
}
}
}
artifactory {
contextUrl = 'https://oss.jfrog.org/artifactory'
publish {
repository {
repoKey = 'oss-snapshot-local'
username = bintrayUser
password = bintrayKey
maven = true
}
defaults {
publications('mavenJava')
}
}
}