-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.gradle
114 lines (100 loc) · 4.04 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
apply plugin: 'maven-publish'
/// 构建源码jar包
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
archiveClassifier.set('sources')
}
task javadoc(type: Javadoc) {
//增加编码,这行很重要,如果是windows系统,同时如果在代码中有中文的话,不加这行,上传会报错
options.encoding = "utf-8"
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
archiveClassifier.set('javadoc')
}
def libGroupId = project.hasProperty('libGroupId') ? project.property('libGroupId') : 'com.angcyo'
def versionName = project.hasProperty('libVersionName') ? project.property('libVersionName') : 'master-SNAPSHOT'//'0.0.1'
def winRepo = project.hasProperty('libWinRepo') ? project.property('libWinRepo') : 'E:/maven'
def macRepo = project.hasProperty('libMacRepo') ? project.property('libMacRepo') : '/Users/angcyo/maven'
//执行任务↓
//Executing tasks: [publish] in project E:\AndroidProjects\angcyo\UICoreDemo
//Executing tasks: [publishAllPublicationsToMavenRepository] in project E:\AndroidProjects\angcyo\UICoreDemo
//Executing tasks: [publishReleasePublicationToMavenRepository] in project E:\AndroidProjects\angcyo\UICoreDemo
//不需要发布aar的模块
ext.noPublishModule = []
def rootPath = getRootDir()
def noPublishFile = new File(rootPath, '.nopublish')
if (noPublishFile.exists()) {
noPublishModule = noPublishFile.readLines('UTF8')
}
if (noPublishModule.size() > 0) {
println "不发布以下Module->↓\n" + noPublishModule
}
afterEvaluate {
publishing {
def ignore = false
if (new File(project.projectDir, ".nopublish").exists()) {
ignore = true
} else {
noPublishModule.each {
ignore = ignore || project.name == it
}
}
if (ignore) {
System.err.println("忽略Maven构建->" + project.name)
} else {
//产物收集配置
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = libGroupId
artifactId = project.name
version = versionName
//artifact javadocJar
artifact sourcesJar
}
}
//目标仓库配置
repositories {
maven {
// change to point to your repo, e.g. http://my.org/repo
//url = 'E:/AndroidProjects/maven'//"$buildDir/repo"
def os = System.getProperty("os.name").toLowerCase()
def path = os.contains("window") ? winRepo : macRepo
url = path
System.err.println(project.name + "->本地Maven路径:${path}")
}
}
}
}
}
//bintray {
// user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
// key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
//
// publications = ['release']
// configurations = ['archives']
//
// //https://github.com/bintray/gradle-bintray-plugin#buildgradle
// pkg {
// repo = "maven"
// name = "library" //发布到JCenter上的项目名字
// desc = 'create by angcyo.'
// //userOrg = "angcyo"
// websiteUrl = 'https://github.com/angcyo'
// vcsUrl = 'https://github.com/angcyo'
// licenses = ["MIT"]
// publicDownloadNumbers = true
// publish = true
//
// /*version {
// name = versionName
// desc = 'library ' + versionName
// }*/
// }
//}