forked from INDExOS/media-for-mobile
-
Notifications
You must be signed in to change notification settings - Fork 2
/
artifactory_java.gradle
53 lines (43 loc) · 1.77 KB
/
artifactory_java.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
if (rootProject.plugins.hasPlugin("com.jfrog.artifactory") && getBuildProperty('ARTIFACTORY_PUBLISH_USERNAME')) {
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
//Workaround for strange init error "Cannot invoke method invoke() on null object"
def contextUrlTmp = getBuildProperty('ARTIFACTORY_CONTEXT_URL')
//By default we publish snapshots, if you want publish release
//please set env variable or gradle -P argument with PUBLISH_RELEASE=true
def publishRelease = getBuildProperty('PUBLISH_RELEASE', 'false').toBoolean()
def repoKeyTmp = publishRelease ?
getBuildProperty('ARTIFACTORY_REPO_KEY') :
getBuildProperty('ARTIFACTORY_SNAPSHOTS_REPO_KEY')
def usernameTmp = getBuildProperty('ARTIFACTORY_PUBLISH_USERNAME')
def passwordTmp = getBuildProperty('ARTIFACTORY_PUBLISH_PASSWORD')
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
groupId project.group
version project.version + (publishRelease ? "" : "-SNAPSHOT")
artifactId project.getName()
}
}
}
artifactory {
contextUrl = contextUrlTmp
publish {
repository {
repoKey = repoKeyTmp
username = usernameTmp
password = passwordTmp
}
}
}
artifactoryPublish {
publications('mavenJava')
}
artifactoryPublish.dependsOn('clean', 'generatePomFileForMavenJavaPublication', 'jar')
publish.dependsOn artifactoryPublish
artifactoryPublish.mustRunAfter('clean')
jar.mustRunAfter clean
} else {
logger.lifecycle(":${project.name} ARTIFACTORY_PUBLISH_USERNAME is empty, skip publish plugin init")
}