-
Notifications
You must be signed in to change notification settings - Fork 7
/
localPublish.gradle
57 lines (51 loc) · 1.67 KB
/
localPublish.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
/**
* Publish a plugin to a local Maven repository.
*
* The following should be set on the project:
* - group - the group name
* - version - the version number
* - ext.publishName - the artifact name
* - ext.publishHomepage (optional) - the author's homepage
*
* The following should be passed in from environment or command line:
* - ext.publishUrl - the Maven repository URL
* - ext.publishUser (optional) - the Maven repository user name
* - ext.publishPassword (optional) - the Maven repository password
*/
apply plugin: 'maven-publish'
ext {
if (!project.hasProperty('publishUrl')) publishUrl = null
if (!project.hasProperty('publishUser')) publishUser = null
if (!project.hasProperty('publishPassword')) publishPassword = null
if (!project.hasProperty('publishHomepage')) publishHomepage = null
}
publishing {
repositories {
maven {
url = publishUrl
credentials {
username publishUser
password publishPassword
}
}
}
publications {
mavenJava(MavenPublication) {
from components.java
artifactId = publishName
if (publishHomepage) {
pom.withXml {
asNode().appendNode('url', publishHomepage)
}
}
}
}
}
gradle.taskGraph.whenReady { graph ->
if (!project.hasProperty('publishName')) {
throw new GradleException('project.publishName was not set.')
}
if (graph.hasTask(':publish') && !publishUrl) {
throw new GradleException('To publish, you must pass in -PpublishUrl (and optionally publishUser/publishPassword).')
}
}