-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
221 lines (206 loc) · 7.15 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
import com.strumenta.antlrkotlin.gradle.AntlrKotlinTask
plugins {
id 'org.jetbrains.kotlin.multiplatform' version '1.9.20'
id "org.jetbrains.kotlin.plugin.serialization" version "1.9.20"
id("org.jetbrains.dokka") version "1.9.10"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("com.strumenta.antlr-kotlin") version "$antlrKotlinVersion"
}
apply plugin: 'maven-publish'
apply plugin: 'antlr'
apply plugin: 'signing'
repositories {
mavenCentral()
mavenLocal()
}
//dependencies {
// antlr 'org.antlr:antlr4:4.7.1'
//}
kotlin {
jvm() { // Creates a JVM target with the default name 'jvm'
withJava()
}
js {// JS target named 'js'
browser {
testTask {
useKarma {
useChromeHeadless()
}
}
}
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib-common')
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version"
api "com.strumenta:antlr-kotlin-runtime:$antlrKotlinVersion"
}
}
commonTest {
// you have to add the generated sources the to the kotlin compiler source directory list
// this is not required if you use src/commonAntlr/kotlin
// and want to add the generated sources to version control
kotlin.srcDir("build/generated-src/commonAntlr/kotlin")
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
implementation kotlin("stdlib")
}
}
jvmMain {
dependencies {
implementation(kotlin('stdlib-jdk8'))
implementation("org.slf4j:slf4j-api:2.0.5")
}
}
// JVM-specific tests and their dependencies:
jvmTest {
kotlin.srcDirs(["$buildDir/generated-src/antlr"] as Set)
dependencies {
implementation kotlin('test-junit')
// implementation "org.antlr:antlr4-runtime:4.7.1"
implementation 'com.thoughtworks.xstream:xstream:1.4.19'
implementation "io.mockk:mockk:1.13.2"
}
}
js().compilations.all {
kotlinOptions {
moduleKind = "commonjs"
sourceMap = true
sourceMapEmbedSources = "always"
}
}
jsMain {
dependencies {
implementation kotlin('stdlib')
}
}
jsTest {
dependencies {
implementation kotlin('test')
}
}
}
}
//generateTestGrammarSource {
// source = project.objects
// .sourceDirectorySet("antlr", "antlr")
// .srcDir("src/jvmTest/antlr").with {
// include("*.g4")
// }
// arguments.addAll(["-package", "antlr.jvm"/*,"-atn"*/])
// outputDirectory = file("$projectDir/src/jvmTest/java/antlr/jvm")
//}
task generateKotlinCommonGrammarSource(type: AntlrKotlinTask) {
// the classpath used to run antlr code generation
// antlrClasspath = configurations.detachedConfiguration(
// project.dependencies.create("com.github.piacenti:antlr-kotlin-target:$antlrKotlinVersion")
// )
maxHeapSize = "64m"
packageName = "piacenti.dslmaker.antlr.generated"
// arguments = ["-atn"]
source = project.objects
.sourceDirectorySet("antlr", "antlr")
.srcDir("src/commonAntlrTest/antlr").with {
include("*.g4")
}
// outputDirectory is required, put it into the build directory
// if you do not want to add the generated sources to version control
outputDirectory = layout.buildDirectory.dir("generated-src/commonAntlr/kotlin").get().asFile
}
compileTestKotlinJvm.dependsOn generateKotlinCommonGrammarSource
compileTestKotlinJs.dependsOn generateKotlinCommonGrammarSource
// waiting for issue https://youtrack.jetbrains.com/issue/KT-43490 to be resolved before we can enable IR
//compileTestKotlinJsIr.dependsOn generateKotlinCommonGrammarSource
//compileTestKotlinJsLegacy.dependsOn generateKotlinCommonGrammarSource
jvmTest {
jvmArgs "-Dlog.level=ERROR", "-Xmx2048M"
}
task fixAntlrKotlinBugs() {
group = "build"
doLast {
file("$buildDir/generated-src/commonAntlr/kotlin").traverse { f ->
if (f.isFile()) {
//remove java files
if (f.name.endsWith(".java"))
f.delete()
}
}
}
}
generateKotlinCommonGrammarSource.finalizedBy fixAntlrKotlinBugs
task javadocJar(type: Jar, dependsOn: dokkaHtml) {
archiveClassifier.set('javadoc')
from dokkaHtml.outputDirectory
}
artifacts {
archives javadocJar, sourcesJar
}
// publish by calling tasks
// publishAllPublicationsToMavenCentralRepository closeAndReleaseMavenCentralStagingRepository
group = "com.github.piacenti"
version = "1.1.55"
task publishToCentral {
afterEvaluate {
dependsOn(publishAllPublicationsToMavenCentralRepository, closeAndReleaseMavenCentralStagingRepository)
}
}
nexusPublishing {
repositories {
mavenCentral {
username = System.getenv("OSSR_TOKEN_ID")
password = System.getenv("OSSR_TOKEN_VALUE")
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
publishing {
publications {
all {
pom {
artifact javadocJar
name = group + ":" + project.name
// optionally artifactId can be defined here
description = '''Kotlin multiplatform library to facilitate creation of DSLs with ANTLR or a simple built in parser'''
url = 'https://github.com/piacenti/dsl-maker'
scm {
connection = 'scm:git:git://github.com/piacenti/dsl-maker.git'
developerConnection = 'scm:git:ssh://github.com/piacenti/dsl-maker.git'
url = 'https://github.com/piacenti/dsl-maker/tree/main'
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
name = 'Gabriel Piacenti'
email = '[email protected]'
}
}
}
}
}
}
signing {
def signingKey = System.getenv("SIGNING_KEY")
def signingPassword = System.getenv("SIGNING_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPassword)
publishing.publications.forEach {
sign it
}
}
tasks.all {signTask->
if (signTask.name.contains("sign")) {
tasks.all {
if (name.contains("publish")) {
println("${it.name} should run after ${signTask.name}")
it.mustRunAfter(signTask)
}
}
}
}