forked from atlassian-labs/nadel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
191 lines (170 loc) · 6.04 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
182
183
184
185
186
187
188
189
190
191
import java.text.SimpleDateFormat
plugins {
id "org.jetbrains.kotlin.jvm" version "1.5.31"
id "com.jfrog.artifactory" version "4.16.1"
id "biz.aQute.bnd.builder" version "5.3.0"
}
if (JavaVersion.current() != JavaVersion.VERSION_11) {
def msg = String.format("This build must be run with Java 11 - you are running %s - Gradle finds the JDK via JAVA_HOME=%s",
JavaVersion.current(), System.getenv("JAVA_HOME"))
throw new GradleException(msg)
}
def getDevelopmentVersion() {
def output = new StringBuilder()
def error = new StringBuilder()
def gitShortHash = ["git", "-C", projectDir.toString(), "rev-parse", "--short", "HEAD"].execute()
gitShortHash.waitForProcessOutput(output, error)
def gitHash = output.toString().trim()
if (gitHash.isEmpty()) {
println "Git hash is empty: error: ${error.toString()}"
throw new IllegalStateException("Git hash could not be determined")
}
def version = new SimpleDateFormat("yyyy-MM-dd'T'HH-mm-ss").format(new Date()) + "-" + gitHash
println "Created development version: $version"
version
}
def releaseVersion = System.env.RELEASE_VERSION
version = releaseVersion ? releaseVersion : getDevelopmentVersion()
group = "com.atlassian"
allprojects {
description = "Nadel is a Java library that combines multiple GrahpQL services together into one API."
}
gradle.buildFinished { buildResult ->
println "*******************************"
println "*"
if (buildResult.failure != null) {
println "* FAILURE - ${buildResult.failure}"
} else {
println "* SUCCESS"
}
println "* Version: $version"
println "*"
println "*******************************"
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
}
}
subprojects {
apply plugin: "java"
apply plugin: "java-library"
apply plugin: "signing"
apply plugin: "maven-publish"
apply plugin: "com.jfrog.artifactory"
tasks.withType(Javadoc) {
exclude("**/antlr/**")
}
task sourcesJar(type: Jar) {
dependsOn classes
classifier "sources"
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier "javadoc"
from javadoc.destinationDir
}
publishing {
publications {
nadel(MavenPublication) {
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
groupId rootProject.group
artifactId project.name
version rootProject.version
pom.withXml {
// The ANTLR-related code below--introdcued in `1ac98bf`--addresses an issue with
// the Gradle ANTLR plugin. `1ac98bf` can be reverted and this comment removed once
// that issue is fixed and Gradle upgraded. See https://goo.gl/L92KiF and https://goo.gl/FY0PVR.
Node pomNode = asNode()
pomNode.dependencies."*".findAll() {
it.artifactId.text() == "antlr4"
}.each() {
it.parent().remove(it)
}
pomNode.children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name project.name
description project.description
url "https://github.com/atlassian-labs/nadel"
scm {
url "https://github.com/atlassian-labs/nadel"
connection "https://github.com/atlassian-labs/nadel"
developerConnection "https://github.com/atlassian-labs/nadel"
}
licenses {
license {
name "Apache License 2.0"
url "http://www.apache.org/licenses/"
distribution "repo"
}
}
developers {
developer {
id "andimarek"
name "Andreas Marek"
}
}
}
}
}
}
}
tasks.withType(PublishToMavenRepository) {
dependsOn(build)
}
signing {
if (System.getenv("SIGNING_KEY") != null) {
useInMemoryPgpKeys(System.getenv("SIGNING_KEY"), System.getenv("SIGNING_PASSWORD"))
sign(publishing.publications)
}
}
javadoc {
options.encoding = "UTF-8"
}
artifacts {
archives sourcesJar
archives javadocJar
}
artifactory {
publish {
setContextUrl("https://packages.atlassian.com/")
repository {
repoKey = "maven-central"
username = System.env.ARTIFACTORY_USERNAME
password = System.env.ARTIFACTORY_API_KEY
}
defaults {
publications("nadel")
publishIvy = false
// This needs to be "false", otherwise, the artifactory plugin will try to publish
// a build info file to Artifactory and fail because we don't have the permissions to do that.
publishBuildInfo = false
}
}
}
}
configurations {
ktlint
}
dependencies {
ktlint "com.pinterest:ktlint:0.39.0"
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations"
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "src/**/*.kt"
}
task ktlintSetCodeStyle(type: JavaExec) {
description = "Apply Kotlin formatter style"
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "applyToIDEAProject", "-y"
}