forked from aws/aws-advanced-jdbc-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
158 lines (141 loc) · 6.14 KB
/
build.gradle.kts
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
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.github.vlsi.gradle.dsl.configureEach
import com.github.vlsi.gradle.properties.dsl.props
import software.amazon.jdbc.buildtools.JavaCommentPreprocessorTask
import com.github.vlsi.gradle.publishing.dsl.simplifyXml
plugins {
java
publishing
signing
id("com.github.vlsi.gradle-extensions")
id("com.github.vlsi.stage-vote-release")
id("com.github.vlsi.ide")
}
val versionMajor = project.property("aws-advanced-jdbc-wrapper.version.major")
val versionMinor = project.property("aws-advanced-jdbc-wrapper.version.minor")
val versionSubminor = Integer.parseInt(project.property("aws-advanced-jdbc-wrapper.version.subminor").toString()) + if (project.property("snapshot") == "true") 1 else 0
val buildVersion = "$versionMajor.$versionMinor.$versionSubminor" + if (project.property("snapshot") == "true") "-SNAPSHOT" else ""
allprojects {
group = "software.amazon.jdbc"
version = buildVersion
repositories {
mavenCentral()
}
apply(plugin = "java")
apply(plugin = "signing")
apply(plugin = "maven-publish")
apply(plugin = "com.github.vlsi.ide")
tasks {
configureEach<JavaCommentPreprocessorTask> {
val re = Regex("^(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*")
val version = project.version.toString()
val matchResult = re.find(version)
?: throw GradleException("Unable to parse major.minor.patch version parts from project.version '$version'")
val (major, minor, patch) = matchResult.destructured
val git = org.ajoberstar.grgit.Grgit.open(mapOf("currentDir" to project.rootDir))
val revision = git.head().id
variables.apply {
put("version", version)
put("version.major", major)
put("version.minor", minor)
put("version.patch", patch.ifBlank { "0" })
put("version.revision", revision.toString())
}
}
}
val preprocessVersion by tasks.registering(JavaCommentPreprocessorTask::class) {
baseDir.set(projectDir)
sourceFolders.add("src/main/version/")
}
ide {
generatedJavaSources(
preprocessVersion,
preprocessVersion.get().outputDirectory.get().asFile,
sourceSets.main
)
}
publishing {
publications {
if (project.props.bool("nexus.publish", default = true)) {
create<MavenPublication>(project.name) {
groupId = "software.amazon.jdbc"
artifactId = "aws-advanced-jdbc-wrapper"
version = buildVersion
from(components["java"])
suppressAllPomMetadataWarnings()
pom {
simplifyXml()
name.set("AWS Advanced JDBC Wrapper")
description.set(
project.description ?: "Amazon Web Services (AWS) Advanced JDBC Wrapper"
)
url.set("https://github.com/awslabs/aws-advanced-jdbc-wrapper")
licenses {
license {
name.set("Apache 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0")
}
}
developers {
developer {
id.set("amazonwebservices")
organization.set("Amazon Web Services")
organizationUrl.set("https://aws.amazon.com")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:https://github.com/awslabs/aws-advanced-jdbc-wrapper.git")
developerConnection.set("scm:[email protected]:awslabs/aws-advanced-jdbc-wrapper.git")
url.set("https://github.com/awslabs/aws-advanced-jdbc-wrapper")
}
issueManagement {
system.set("GitHub issues")
url.set("https://github.com/awslabs/aws-advanced-jdbc-wrapper/issues")
}
}
}
signing {
if (project.hasProperty("signing.keyId")
&& project.property("signing.keyId") != ""
&& project.hasProperty("signing.password")
&& project.property("signing.password") != ""
&& project.hasProperty("signing.secretKeyRingFile")
&& project.property("signing.secretKeyRingFile") != ""
) {
sign(publishing.publications[project.name])
}
}
}
}
repositories {
maven {
name = "OSSRH"
url = if(project.property("snapshot") == "true") {
uri("https://aws.oss.sonatype.org/content/repositories/snapshots/")
} else {
uri("https://aws.oss.sonatype.org/service/local/staging/deploy/maven2/")
}
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
mavenLocal()
}
}
}