-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
142 lines (121 loc) · 4.49 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
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import org.gradle.api.artifacts.DependencyResolveDetails
import org.gradle.api.tasks.bundling.Jar
import java.util.regex.Matcher
import java.util.regex.Pattern
buildscript {
ext {
kotlinVersion = "1.3.41"
}
repositories {
mavenCentral()
}
dependencies {
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 "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
}
}
apply plugin: "antlr"
apply plugin: "kotlin"
apply plugin: "org.jetbrains.dokka"
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")
}
allprojects {
repositories {
mavenCentral()
}
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 }
}
}
}
repositories {
maven {
credentials(AwsCredentials) {
accessKey gradle.awsAccessKey
secretKey gradle.awsSecretKey
}
url gradle.releasesRepositoryUrl
}
maven {
credentials(AwsCredentials) {
accessKey gradle.awsAccessKey
secretKey gradle.awsSecretKey
}
url gradle.snapshotsRepositoryUrl
}
}
dependencies {
antlr "org.antlr:antlr4:4.7.2" // use ANTLR version 4
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-reflect"
implementation "org.apache.velocity:velocity-engine-core:2.1"
testImplementation "org.junit.jupiter:junit-jupiter:5.6.2"
testImplementation "org.assertj:assertj-core:3.13.2"
}
test {
useJUnitPlatform()
}
sourceSets.main.java.srcDirs += new File(buildDir, "generated-src/antlr")
generateGrammarSource {
outputDirectory = new File(project.rootDir, "build/generated-src/antlr/gaia/sdk/antlr")
arguments += ["-visitor", "-package", "gaia.sdk.antlr"]
}
compileKotlin.dependsOn generateGrammarSource
task generateSource(type: Test) {
useJUnitPlatform()
filter {
includeTestsMatching "gaia.sdk.codegen.KotlinCodegenTest"
}
}
generateSource.dependsOn generateGrammarSource
task setVersionJavascript() {
doLast {
String packageJsonPath = project(":gaia-sdk-javascript").projectDir.toString() + "/package.json"
File packageJsonFile = file(packageJsonPath)
def parsedJson = new JsonSlurper().parseText(packageJsonFile.text)
parsedJson.version = version.toString()
packageJsonFile.text = new JsonBuilder(parsedJson).toPrettyString()
logger.quiet("Updated version in ${packageJsonPath} to ${version.toString()}")
}
}
task setVersionPython() {
doLast {
String pyprojectTomlPath = project(":gaia-sdk-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()}")
}
}