-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle.kts
230 lines (198 loc) · 7.71 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
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
// based on https://github.com/specificlanguages/mps-gradle-plugin-sample
import org.apache.tools.ant.taskdefs.condition.Os
import com.specificlanguages.mps.MainBuild
import com.specificlanguages.mps.TestBuild
plugins {
id("com.specificlanguages.mps")
`maven-publish`
id("signing")
id("net.researchgate.release")
}
val releaseVersion: String by project
val isReleaseVersion = !releaseVersion.endsWith("SNAPSHOT")
val mpsVersionSuffix: String by project
val lionwebRelease: String by project
val lionwebJavaVersion: String by project
val mpsVersion: String by project
val jbrVersion: String by project
val mpsExtensionsVersion: String by project
val apacheCliVersion: String by project
repositories {
maven(url = "https://artifacts.itemis.cloud/repository/maven-mps")
mavenCentral()
mavenLocal()
}
dependencies {
"mps"("com.jetbrains:mps:$mpsVersion")
jbr("com.jetbrains.jdk:jbr_jcef:$jbrVersion")
// only needed for tests, but such a config is missing
// https://github.com/specificlanguages/mps-gradle-plugin/issues/9
// "generation" ("de.itemis.mps:extensions:$mpsExtensionsVersion")
}
mpsBuilds {
val main = create<MainBuild>("main") {
buildSolutionDescriptor = file("solutions/io.lionweb.mps.build/io.lionweb.mps.build.msd")
buildProjectName = "io.lionweb.mps"
buildFile = file("build.xml")
}
create<TestBuild>("test") {
dependsOn(main)
buildSolutionDescriptor = file("solutions/io.lionweb.mps.build.test/io.lionweb.mps.build.test.msd")
buildProjectName = "io.lionweb.mps.test"
buildFile = file("build-test.xml")
}
}
bundledDependencies {
register("libs") {
destinationDir = file("solutions/io.lionweb.lionweb.java/libs")
dependency("io.lionweb.lionweb-java:lionweb-java-$lionwebRelease-core:$lionwebJavaVersion")
}
register("apacheCli") {
destinationDir = file("solutions/org.apache.commons.cli/libs")
dependency("commons-cli:commons-cli:$apacheCliVersion")
}
}
group = "io.lionweb"
tasks.register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
}
tasks.register<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
}
tasks.register<Exec>("testCmdLineExport-library") {
workingDir("./test-project")
commandLine("./scripts/export-library.sh")
}
tasks.register<Exec>("testCmdLineExport-multiple") {
workingDir("./test-project")
commandLine("./scripts/export-multiple.sh")
}
tasks.register<Exec>("testCmdLineExport-foo") {
workingDir("./test-project")
commandLine("./scripts/export-foo.sh")
}
tasks.register<Exec>("testCmdLineExport-configs") {
workingDir("./test-project")
commandLine("./scripts/export-configs.sh")
}
tasks.register<Exec>("testCmdLineExport-DependsOnMpsExtension-externalLib") {
workingDir("./test-project-externalLib")
commandLine("./scripts/export-DependsOnMpsExtensions.sh")
}
tasks.register<Exec>("testCmdLineExport-foo-externalLib") {
workingDir("./test-project-externalLib")
commandLine("./scripts/export-foo.sh")
}
tasks.register("testCmdLineExport") {
dependsOn("testCmdLineExport-library")
dependsOn("testCmdLineExport-multiple")
dependsOn("testCmdLineExport-foo")
dependsOn("testCmdLineExport-configs")
dependsOn("testCmdLineExport-DependsOnMpsExtension-externalLib")
dependsOn("testCmdLineExport-foo-externalLib")
}
publishing {
val ossrhUsername = (project.findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME")) as String?
val ossrhPassword = (project.findProperty("ossrhPassword") ?: System.getenv("OSSRH_PASSWORD")) as String?
repositories {
maven {
val releaseRepo = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotRepo = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = java.net.URI(if (isReleaseVersion) releaseRepo else snapshotRepo)
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
publications {
register<MavenPublication>("mpsPlugin") {
from(components["mps"])
groupId = "io.lionweb.lionweb-mps"
val concatenatedArtifact = "lionweb-mps-$mpsVersionSuffix-lw$lionwebRelease"
artifactId = concatenatedArtifact
artifact(tasks.getByName("sourcesJar"))
artifact(tasks.getByName("javadocJar"))
// Put resolved versions of dependencies into POM files -- uncomment as soon as we have any dependencies
versionMapping { usage("java-runtime") { fromResolutionOf("generation") } }
pom {
name.set(concatenatedArtifact)
description.set("MPS APIs for the LionWeb system for MPS $mpsVersionSuffix, LionWeb release $lionwebRelease")
version = releaseVersion
packaging = "zip"
url.set("https://github.com/LionWeb-io/lionweb-mps")
scm {
connection.set("scm:git:https://github.com/LionWeb-io/lionweb-mps.git")
developerConnection.set("scm:git:[email protected]:LionWeb-io/lionweb-mps.git")
url.set("https://github.com/LionWeb-io/lionweb-mps.git")
}
licenses {
license {
name.set("Apache Licenve V2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0")
distribution.set("repo")
}
}
// The developers entry is strictly required by Maven Central
developers {
developer {
id.set("enikao")
name.set("Niko Stotz")
email.set("[email protected]")
}
}
}
}
}
repositories {
if (project.hasProperty("gpr.user")) {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/specificlanguages/mps-json")
credentials {
username = project.findProperty("gpr.user") as String?
password = project.findProperty("gpr.key") as String?
}
}
}
}
}
configurations.getByName("libs") {
attributes {
attribute(Attribute.of("org.gradle.dependency.bundling", String::class.java), "external")
attribute(TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE, project.objects.named(TargetJvmEnvironment::class.java, TargetJvmEnvironment.STANDARD_JVM))
}
}
tasks.withType(Sign::class) {
onlyIf("isReleaseVersion is set") { isReleaseVersion }
}
/**
* Assures ascii-armored gpg key contains newlines.
*/
fun restoreNewlines(encodedString: String?): String? {
if (encodedString != null && !encodedString.contains('\n')) {
return encodedString.replace("\\n", "\n")
}
return encodedString
}
signing {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
useGpgCmd()
}
val signingKey: String? = restoreNewlines(System.getenv("SIGNING_KEY"))
val signingPassword: String? = System.getenv("SIGNING_PASSWORD")
if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign(publishing.publications["mpsPlugin"])
}
release {
tagTemplate.set("$mpsVersionSuffix-lw$lionwebRelease-${releaseVersion.replace(snapshotSuffix.get(), "")}")
buildTasks.set(listOf("publish"))
git {
requireBranch.set("")
pushToRemote.set("origin")
pushOptions.add("--force")
}
}
tasks.withType(com.specificlanguages.mps.RunAnt::class).configureEach { environment.putAll(System.getenv()) }