-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
222 lines (183 loc) · 7.54 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
import de.itemis.mps.gradle.downloadJBR.DownloadJbrForPlatform
import de.itemis.mps.gradle.BuildLanguages
import de.itemis.mps.gradle.GitBasedVersioning
import kotlin.reflect.KProperty1
import kotlin.reflect.full.memberProperties
buildscript {
repositories {
maven { url = uri("https://artifacts.itemis.cloud/repository/maven-mps/") }
}
dependencies {
classpath("de.itemis.mps:mps-gradle-plugin:1.28.0.1.f8ee996")
}
}
plugins {
id("maven-publish")
id("download-jbr") version "1.28.0.441.896925d"
}
repositories {
// Obtain gihub credentials for github packages access
val gpr_user: String? by extra
val gpr_token: String? by extra
val githubUsername = System.getenv("GITHUB_ACTOR") ?: gpr_user
val githubToken = System.getenv("GITHUB_TOKEN") ?: gpr_token
if(githubUsername == null || githubUsername == "" ) {
throw GradleException("No credentials found via envrionment variable (\$GITHUB_ACTOR) or via gradle properties (gpr_user) for auth towards Github packages")
}
if(githubToken == null || githubToken == "") {
throw GradleException("No credentials found via envrionment variable (\$GITHUB_TOKEN) or via gradle properties (gpr_token) for auth towards Github packages")
}
maven {
url = uri("https://maven.pkg.github.com/JetBrains/MPS-extensions")
credentials {
username = githubUsername
password = githubToken
}
}
maven {
url = uri("https://maven.pkg.github.com/mbeddr/build.publish.jdk")
credentials {
username = githubUsername
password = githubToken
}
}
maven {
url = uri("https://artifacts.itemis.cloud/repository/maven-mps/")
}
//maven { url = uri("https://projects.itemis.de/nexus/content/repositories/mbeddr") }
mavenCentral()
}
// configurations
val mpsDependencies: Configuration by configurations.creating
val mps: Configuration by configurations.creating
val buildDependencies: Configuration by configurations.creating
dependencies {
mpsDependencies("de.itemis.mps:extensions:" + Versions.extensions)
mps("com.jetbrains:mps:" + Versions.mpsFull)
buildDependencies("org.apache.ant:ant-junit:" + Versions.antjunit)
}
// misc
val codeDir = file("mps")
val mpsDir = file("$buildDir/mps")
val dependencyDir = file("$codeDir/dependencies")
val jbrDir = file("$buildDir/jbr")
val publishDir = file("$buildDir/dist")
val gitBranch: String = GitBasedVersioning.getGitBranch()
downloadJbr {
jbrVersion = Versions.jbr
}
// dependency versions
object Versions {
public const val groupID: String = "libre.doge.mps"
public const val artifactID: String = "dot"
public const val fullID: String = Versions.groupID + "." + Versions.artifactID
// java
public const val jbr: String = "11_0_14_1-b1751.46"
public const val jbrsdk: String = "11_0_14_1-b1751.46"
//WARNING: This variable is not used - https://github.com/gradle/gradle/issues/9830
public const val downloadJBR: String = "1.28.0.441.896925d"
// mps
public const val mpsMajor: String = "2021"
public const val mpsMinor: String = "3"
public const val mpsPatch: String = "5"
public const val mpsMajorMinor: String = Versions.mpsMajor + "." + Versions.mpsMinor
public const val mpsFull: String = Versions.mpsMajorMinor + "." + Versions.mpsPatch
// this project
public const val buildVerison: String = Versions.mpsFull + "-SNAPSHOT"
// mps dependencies
public const val extensions: String = "2021.3.2869.e5eae69"
public const val antjunit: String = "1.10.6"
override fun toString() : String{
return "\n"+ this::class.java.declaredFields.filter{ it.name != "INSTANCE" }.map { " - ${it.name} = \"${it.get(Versions)}\"" }.joinToString("\n")
}
}
// tasks
val extractMps by tasks.registering(Copy::class) {
from({ mps.resolve().map { zipTree(it) } })
into(mpsDir)
}
val extractMpsDependencies by tasks.registering(Copy::class) {
from({ mpsDependencies.resolve().map { zipTree(it) } })
into(dependencyDir)
}
fun antVar(name: String, value: String) = "-D$name=$value"
val printVersions by tasks.registering {
doFirst {
// print sanity feedback
logger.lifecycle("\n--------------------\nBuild Info:\n--------------------")
logger.lifecycle("Java path {}", project.ext["itemis.mps.gradle.ant.defaultJavaExecutable"])
logger.lifecycle("gitBranch: {}", gitBranch)
logger.lifecycle("Project directory: {}", projectDir)
logger.lifecycle("JBR directory: {}", jbrDir)
logger.lifecycle("Java version: {}", JavaVersion.current())
logger.lifecycle("gradle version: {}", project.gradle.gradleVersion)
// println("CI build: "+ ext["ciBuild"])
logger.lifecycle("Build directory: {}", buildDir)
logger.lifecycle("Publish directory: {}", publishDir)
logger.lifecycle("MPS directory: {}", mpsDir)
logger.lifecycle("Dependency versions: {}", Versions.toString())
}
}
val setup by tasks.registering {
group = "Setup"
description = "Download and extract MPS and the projects MPS dependencies."
dependsOn(extractMps)
dependsOn(extractMpsDependencies)
val downloadJbrForPlatform = tasks.getByName("downloadJbr", DownloadJbrForPlatform::class)
dependsOn(downloadJbrForPlatform)
dependsOn(printVersions)
ext["itemis.mps.gradle.ant.defaultJavaExecutable"] = downloadJbrForPlatform.javaExecutable
ext["itemis.mps.gradle.ant.defaultScriptArgs"] =
listOf(
antVar("mps_home", mpsDir.absolutePath),
antVar("dependencyDir", dependencyDir.absolutePath),
antVar("mps.generator.skipUnmodifiedModels", "true"),
antVar("build.dir", "$buildDir/")
)
ext["itemis.mps.gradle.ant.defaultScriptClasspath"] = buildDependencies.fileCollection { true }
}
val buildScripts by tasks.registering(BuildLanguages::class) {
dependsOn(setup)
script = "$projectDir/buildAll.xml"
}
val buildLanguages by tasks.registering(BuildLanguages::class) {
dependsOn(buildScripts)
group = "build"
description = "Build all languages in the MPS project"
script = "$buildDir/build.xml"
}
defaultTasks("buildLanguages")
// Publishing
val packageMpsPlugin by tasks.registering(Zip::class) {
dependsOn(buildLanguages)
archiveFileName.set(Versions.groupID + "." + Versions.artifactID + "." + Versions.buildVerison + ".zip")
from(file("build/artifacts/de.doge.mps.dot.build"))
destinationDirectory.set(publishDir)
}
val branch = GitBasedVersioning.getGitBranch()
publishing {
repositories {
if(branch.equals("main") || branch.equals("maintenance")) {
logger.lifecycle("Will publish, (branch is '{}')", branch)
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/nkoester/mps-dot")
credentials {
// or use githubUsername and githubToken ?
username = project.findProperty("gpr_user") as String? ?: System.getenv("GITHUB_ACTOR") as String?
password = project.findProperty("gpr_token") as String? ?: System.getenv("GITHUB_TOKEN") as String?
}
}
} else {
logger.lifecycle("Will not publish, (branch is '{}')", branch)
}
}
publications {
create<MavenPublication>("packagedModules"){
artifactId = Versions.artifactID
groupId = Versions.groupID
version = Versions.buildVerison
artifact(packageMpsPlugin)
}
}
}