-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
181 lines (165 loc) · 5.41 KB
/
build.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
buildscript {
repositories {
mavenLocal()
maven {
name "alimaven"
url "http://maven.aliyun.com/nexus/content/groups/public/"
}
// if (project.hasProperty("maven")) {
// mavenCentral()
// gradlePluginPortal()
// } else {
// maven {
// name "nexus"
// url property("nexus.repo.url")
// credentials {
// username property("nexus.username")
// password property("nexus.password")
// }
// }
// }
}
dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:$protobufPluginVersion"
// http://ajoberstar.org/grgit/grgit-reference.html
classpath "org.ajoberstar.grgit:grgit-gradle:$grgitGradleVersion"
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
// git version
apply plugin: "org.ajoberstar.grgit"
version = "1.0.1"
if (!project.hasProperty("release")) {
String branch = grgit.branch.current().name
String prefix = branch.replace("/", "-")
int commits = grgit.log().size()
String abbreviatedId = grgit.head().abbreviatedId
version = "${prefix}-${version}.${commits}.${abbreviatedId}"
}
println("version=$version")
// project setting
subprojects {
group = "xyz.codemeans.protobuf4j"
version = rootProject.version
ext {
publishable = true
}
repositories {
mavenLocal()
maven {
name "alimaven"
url "http://maven.aliyun.com/nexus/content/groups/public/"
}
}
apply plugin: "java"
apply plugin: "java-library"
// artifacts
jar << {
println "jar: ${archivePath}"
}
task sourcesJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allJava
classifier = 'sources'
doLast {
println "sources: ${archivePath}"
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
doLast {
println "sources: ${archivePath}"
}
}
apply plugin: "jacoco"
jacocoTestReport.dependsOn(test)
jacocoTestReport << {
println jacocoTestReport.reports.html.entryPoint
}
test << {
println test.reports.html.entryPoint
}
dependencies {
// test
testImplementation("junit:junit:$junitVersion")
}
}
project(":test-proto") {
ext.publishable = false
}
project(":example") {
ext.publishable = false
}
// 配置发布
configure(subprojects.findAll { it.ext.publishable }) {
// 在这里应用插件,否则相关publishing配置无法生效
apply plugin: "maven-publish"
publishing {
repositories {
maven {
name "oss"
def ossBaseUrl = "https://oss.sonatype.org/content/repositories"
url = project.hasProperty("release") ? "https://oss.sonatype.org/service/local/staging/deploy/maven2" : "$ossBaseUrl/snapshots"
credentials {
username property("maven2.username")
password property("maven2.password")
}
}
}
publications {
mavenJava(MavenPublication) {
from components.java
if (project.hasProperty("release")) {
version = project.getVersion()
} else {
version = project.getVersion() + "-SNAPSHOT"
}
artifact sourcesJar
artifact javadocJar
pom {
name = 'Protobuf4j: A Facility Framework to Develop with Google Protobuf'
description = 'A Facility Framework to Develop with Google Protobuf'
url = 'https://github.com/YuanWenqing/protobuf4j'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'yuanwq'
name = 'YuanWenqing'
email = 'ywq8876@163.com'
}
}
scm {
connection = 'scm:git:git://github.com:YuanWenqing/protobuf4j.git'
developerConnection = 'scm:git:ssh://github.com:YuanWenqing/protobuf4j.git'
url = 'https://github.com/YuanWenqing/protobuf4j'
}
}
}
}
}
publish {
doLast {
def pub = publishing.publications.mavenJava
println "artifact: ${pub.groupId}:${pub.artifactId}:${pub.version}"
for (repo in publishing.repositories) {
println "upload to ${repo.url}"
}
}
}
publishToMavenLocal {
doLast {
def pub = publishing.publications.mavenJava
println "artifact: ${pub.groupId}:${pub.artifactId}:${pub.version}"
}
}
task('local').dependsOn(publishToMavenLocal)
apply plugin: "signing" // generate a signature file for each artifact
signing {
sign publishing.publications.mavenJava
}
}