-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlocal_publish.gradle
45 lines (39 loc) · 1.58 KB
/
local_publish.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
if (!hasProperty("publishLocal")) {
return
}
//publishLocal 是否发版到本地
//VERSION_NAME 版本号
//PUBLISH_GROUP_ID = "cn.theone" 组
//PUBLISH_ARTIFACT_ID 模块名
apply plugin: 'maven'
def getLocalProperties() {
def localProperties = new Properties()
InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream()
localProperties.load(inputStream)
return localProperties
}
def getPublishGroupId() {
def localGroupId = localProperties.getProperty('PUBLISH_GROUP_ID', "com.theone")
return hasProperty('PUBLISH_GROUP_ID') ? PUBLISH_GROUP_ID : localGroupId
}
def getPublishArtifactId() {
def localArtifactId = localProperties.getProperty('PUBLISH_ARTIFACT_ID', "")
return hasProperty('PUBLISH_ARTIFACT_ID') ? PUBLISH_ARTIFACT_ID : localArtifactId
}
//PUBLISH_VERSION_NAME>Local PUBLISH_VERSION_NAME > Local VERSION_NAME > VERSION_NAME
def getPublishVersionName() {
def temVersionName = hasProperty('VERSION_NAME') ? VERSION_NAME : "1.0.0"
def localVersionName = localProperties.getProperty('VERSION_NAME', temVersionName)
def localPublishVersionName = localProperties.getProperty('PUBLISH_VERSION_NAME', localVersionName)
return hasProperty('PUBLISH_VERSION_NAME') ? PUBLISH_VERSION_NAME : localPublishVersionName
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: uri("${System.properties['user.home']}/.gradle/local_repo"))
pom.version=getPublishVersionName()
pom.artifactId=getPublishArtifactId()
pom.groupId=getPublishGroupId()
}
}
}