-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
237 lines (210 loc) · 8.46 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
* Copyright (c) 2016-2020, Leftshift One
* __________________
* [2019] Leftshift One
* All Rights Reserved.
* NOTICE: All information contained herein is, and remains
* the property of Leftshift One and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Leftshift One
* and its suppliers and may be covered by Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Leftshift One.
*/
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import groovy.util.Node
import org.gradle.api.artifacts.DependencyResolveDetails
import org.gradle.api.credentials.AwsCredentials
import java.util.regex.Matcher
import java.util.regex.Pattern
buildscript {
ext {
kotlinVersion = "1.3.41"
}
repositories {
jcenter()
}
dependencies {
classpath "one.leftshift.asteria:asteria-code-analytics:latest.release"
classpath "one.leftshift.asteria:asteria-dependency:latest.release"
classpath "one.leftshift.asteria:asteria-docs:latest.release"
classpath "one.leftshift.asteria:asteria-email:latest.release"
classpath "one.leftshift.asteria:asteria-publish:latest.release"
classpath "one.leftshift.asteria:asteria-report:latest.release"
classpath "one.leftshift.asteria:asteria-version:latest.release"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
}
}
apply plugin: "antlr"
apply plugin: "one.leftshift.asteria-email"
apply plugin: "one.leftshift.asteria-report"
apply plugin: "one.leftshift.asteria-dependency"
apply plugin: "one.leftshift.asteria-version"
apply plugin: "maven-publish"
apply plugin: "signing"
apply plugin: "io.codearte.nexus-staging"
nexusStaging {
packageGroup = "one.leftshift"
serverUrl = "https://s01.oss.sonatype.org/service/local/"
stagingProfileId = System.getenv("OSSRH_STAGING_PROFILE_ID")
username = System.getenv("OSSRH_LOGIN_NAME")
password = System.getenv("OSSRH_LOGIN_PASSWORD")
}
asteriaEmail {
smtpHost = System.getenv("ASTERIA_EMAIL_SMTP_HOST")
smptUser = System.getenv("ASTERIA_EMAIL_SMTP_USER")
smptPassword = System.getenv("ASTERIA_EMAIL_SMTP_PASSWORD")
sender = System.getenv("ASTERIA_EMAIL_SENDER")
}
asteriaReport {
reportingUrl = System.getenv("ASTERIA_REPORT_URL")
depsJsonResult = file("${rootProject.buildDir}/dependencyUpdates/report.json")
junitXmlResults = fileTree(rootProject.projectDir) {
include("**/test-results/*/TEST-*.xml")
}
junitBinaryResults = files(["test"].collect {
"${project.buildDir}/test-results/${it}/binary"
})
}
allprojects {
apply plugin: "one.leftshift.asteria-dependency"
apply plugin: "one.leftshift.asteria-version"
repositories {
jcenter()
maven {
credentials(AwsCredentials) {
accessKey gradle.awsAccessKey
secretKey gradle.awsSecretKey
}
url gradle.releasesRepositoryUrl
}
maven {
credentials(AwsCredentials) {
accessKey gradle.awsAccessKey
secretKey gradle.awsSecretKey
}
url gradle.snapshotsRepositoryUrl
}
}
asteriaDependency {
enableBranchSnapshotRepositories = true
}
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:2.1.13.RELEASE") {
bomProperty("kotlin.version", kotlinVersion)
}
}
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "org.jetbrains.kotlin") {
details.useVersion kotlinVersion
}
}
}
if (System.getenv("CI")) {
afterEvaluate { rootProject.tasks.postRelease.finalizedBy rootProject.tasks.sendReleaseEmail }
if (tasks.findByName("publish")) {
afterEvaluate { rootProject.tasks.postRelease.dependsOn tasks.publish }
}
}
}
subprojects {
apply plugin: "one.leftshift.asteria-code-analytics"
asteriaCodeAnalytics {
sonarUrl = System.getenv("SONAR_HOST_URL")
sonarLoginToken = System.getenv("SONAR_LOGIN")
xmlCoverageReportEnabled = true
sonarProperties = [
"sonar.test.inclusions" : "**/*Test.*,**/*.test.ts,**/tests/test_*.py",
"sonar.python.coverage.reportPath": "${project(":explicit-python").projectDir}/build/coverage/coverage.xml",
]
coverageExcludes = ["**/*Kt.class"]
}
}
dependencies {
antlr "org.antlr:antlr4:4.8-1"
}
task generateGrammarSourceJava(type: AntlrTask) {
source = project.sourceSets.main.antlr
outputDirectory = file("${project(":explicit-java").buildDir}/generated-src/antlr/explicit/antlr")
arguments += ["-visitor", "-package", "explicit.antlr"]
}
task generateGrammarSourcePython(type: AntlrTask) {
source = project.sourceSets.main.antlr
outputDirectory = file("${project(":explicit-python").projectDir}/explicit_nlu/antlr")
arguments += ["-visitor", "-Dlanguage=Python3"]
}
generateGrammarSource.dependsOn generateGrammarSourceJava
generateGrammarSource.dependsOn generateGrammarSourcePython
task setVersionPython() {
doLast {
String pyprojectTomlPath = project(":explicit-python").projectDir.toString() + "/pyproject.toml"
File pyprojectTomlFile = file(pyprojectTomlPath)
String pyprojectTomlContent = pyprojectTomlFile.text
Pattern regex = Pattern.compile("^version\\s?=\\s?[\"'].*[\"']\\s?\$", Pattern.MULTILINE)
Matcher matcher = regex.matcher(pyprojectTomlContent)
List<String> matches = []
while (matcher.find()) {
matches.add(matcher.group(0))
}
if (matches.size() > 1)
throw new RuntimeException("More than one version found in ${pyprojectTomlPath}")
if (matches.isEmpty() || matches.first().trim().isEmpty())
throw new RuntimeException("No version found in ${pyprojectTomlPath}")
pyprojectTomlFile.text = pyprojectTomlContent.replaceAll(matches.first(), "version = \"${version.toString()}\"")
logger.quiet("Updated version in ${pyprojectTomlPath} to ${version.toString()}")
}
}
task commitVersions() {
doLast {
// python
String pyprojectTomlPath = "${project(":explicit-python").projectDir}/pyproject.toml"
executeAssertExitCode(["git", "add", pyprojectTomlPath])
String commitMessage = "set version to ${version.toString()}"
executeWarnExitCode(["git", "commit", "-m", "'$commitMessage'".toString()])
}
}
commitVersions.dependsOn setVersionPython
task pushVersions() {
doLast {
executeAssertExitCode(["git", "push"])
}
}
pushVersions.dependsOn commitVersions
private void executeAssertExitCode(List<String> command) {
int exitCode = execute(command)
if (exitCode != 0) throw new RuntimeException("Command '${command.join(" ")}' failed with code ${exitCode}")
logger.debug("Executed command '${command.join(" ")}'")
}
private void executeWarnExitCode(List<String> command) {
int exitCode = execute(command)
if (exitCode != 0) logger.warn("Command failed with code ${exitCode}")
logger.debug("Executed command '${command.join(" ")}'")
}
private int execute(List<String> command) {
logger.debug("Executing command '${command.join(" ")}'")
def process = new ProcessBuilder(command).directory(projectDir).start()
process.consumeProcessOutput(System.out, System.err)
process.waitFor()
logger.debug("Executed command '${command.join(" ")}'")
return process.exitValue()
}
ext."signing.keyId" = System.getenv("OSSRH_SIGN_KEY_ID")
ext."signing.password" = System.getenv("OSSRH_SIGN_KEY_PASSWORD")
ext."signing.secretKeyRingFile" = System.getenv("OSSRH_SIGN_KEY_PATH")
signing {
sign publishing.publications
}
if (System.getenv("CI") == null || System.getenv("CI") != "true") {
afterEvaluate { rootProject.tasks.release.dependsOn rootProject.tasks.pushVersions }
}