-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
68 lines (60 loc) · 2.08 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
plugins {
id 'maven-publish'
}
allprojects {
ext {
artifactName = 'protobufs'
}
group = 'org.opensearch'
def build = new Properties()
file("version.properties").withInputStream { build.load(it) }
version = build.getProperty("version")
var isSnapshot = System.getProperty("build.snapshot", "true")
if (isSnapshot.toBoolean() && !version.endsWith("SNAPSHOT")) {
version = version + "-SNAPSHOT"
} else if (!isSnapshot && version.endsWith("SNAPSHOT")) {
throw GradleException("Expecting release (non-SNAPSHOT) build but version is not set accordingly: " + version)
}
}
repositories {
mavenCentral()
}
publishing {
publications {
create(MavenPublication) {
groupId = group
artifactId = artifactName
artifact "./generated/maven/publish/${artifactName}-${version}.jar"
artifact(source: "./generated/maven/publish/${artifactName}-${version}-sources.jar", classifier: 'sources')
artifact(source: "./generated/maven/publish/${artifactName}-${version}-javadoc.jar", classifier: 'javadoc')
}
}
repositories {
maven{
name = 'Snapshots'
url = uri("https://aws.oss.sonatype.org/content/repositories/snapshots/")
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
maven {
name = "localRepo"
url = "${rootProject.buildDir}/repository"
}
}
}
// Override maven publish generated pom with the one generated by ./tools/java/package_proto_jar.sh
tasks.named('generatePomFileForCreatePublication') {
doLast {
def generatedPom = file("$rootProject.buildDir/publications/create/pom-default.xml")
generatedPom.delete()
generatedPom << file("./generated/maven/publish/${artifactName}-${version}.pom").text
}
}
task clean(type: Delete) {
delete "${rootProject.buildDir}"
}
task cleanGenerated(type: Delete) {
delete "${rootProject.projectDir}/generated"
}