forked from mbeddr/mps-gradle-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
176 lines (146 loc) · 4.93 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URI
buildscript {
configurations.classpath {
resolutionStrategy.activateDependencyLocking()
}
}
val kotlinApiVersion by extra { "1.5" }
val kotlinVersion by extra { "$kotlinApiVersion.31" }
plugins {
groovy
`java-gradle-plugin`
`kotlin-dsl`
`maven-publish`
kotlin("jvm") version "1.5.31"
}
//Gradle-Pluign-Version
val versionMajor = 2
val versionMinor = 0
group = "de.itemis.mps"
val kotlinArgParserVersion by extra { "2.0.7" }
val mpsVersion by extra { "2020.3.4" }
//this version needs to align with the version shiped with MPS found in the /lib folder otherwise, runtime problems will
//surface because mismatching jars on the classpath.
val fastXmlJacksonVersion by extra { "2.11.+" }
version = if (!project.hasProperty("useSnapshot") &&
(project.hasProperty("forceCI") || project.hasProperty("teamcity"))
) {
de.itemis.mps.gradle.GitBasedVersioning.getVersion(versionMajor, versionMinor)
} else {
"$versionMajor.$versionMinor-SNAPSHOT"
}
var currentBranch:String? = ""
currentBranch = de.itemis.mps.gradle.GitBasedVersioning.getGitBranch()
val mpsConfiguration = configurations.create("mps")
repositories {
mavenCentral()
maven {
url = URI("https://artifacts.itemis.cloud/repository/maven-mps")
}
}
dependencyLocking {
lockAllConfigurations()
}
dependencies {
implementation(localGroovy())
implementation(kotlin("stdlib", version = kotlinVersion))
implementation("net.swiftzer.semver:semver:1.1.2")
testImplementation("junit:junit:4.13.2")
}
gradlePlugin {
plugins {
register("generate-models") {
id = "generate-models"
implementationClass = "de.itemis.mps.gradle.generate.GenerateMpsProjectPlugin"
}
register("modelcheck") {
id = "modelcheck"
implementationClass = "de.itemis.mps.gradle.modelcheck.ModelcheckMpsProjectPlugin"
}
register("migrations-executor") {
id = "run-migrations"
implementationClass = "de.itemis.mps.gradle.runmigrations.RunMigrationsMpsProjectPlugin"
}
register("download-jbr") {
id = "download-jbr"
implementationClass = "de.itemis.mps.gradle.downloadJBR.DownloadJbrProjectPlugin"
}
}
}
tasks {
wrapper {
gradleVersion = "7.4.0"
distributionType = Wrapper.DistributionType.ALL
}
register("setTeamCityBuildNumber") {
doLast {
println("##teamcity[buildNumber '$version']")
}
}
}
allprojects {
apply<MavenPublishPlugin>()
publishing {
repositories {
if(currentBranch == "master" || currentBranch!!.startsWith("mps")) {
maven {
name = "itemisCloud"
url = uri("https://artifacts.itemis.cloud/repository/maven-mps-releases/")
if (project.hasProperty("artifacts.itemis.cloud.user") && project.hasProperty("artifacts.itemis.cloud.pw")) {
credentials {
username = project.findProperty("artifacts.itemis.cloud.user") as String?
password = project.findProperty("artifacts.itemis.cloud.pw") as String?
}
}
}
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/mbeddr/mps-gradle-plugin")
if(project.hasProperty("gpr.token")) {
credentials {
username = project.findProperty("gpr.user") as String?
password = project.findProperty("gpr.token") as String?
}
}
}
}
}
}
}
subprojects {
dependencyLocking {
lockAllConfigurations()
}
}
tasks.register("createClasspathManifest") {
val outputDir = file("$buildDir/$name")
inputs.files(sourceSets.main.get().runtimeClasspath)
.withPropertyName("runtimeClasspath")
.withNormalizer(ClasspathNormalizer::class)
outputs.dir(outputDir)
.withPropertyName("outputDir")
doLast {
outputDir.mkdirs()
file("$outputDir/plugin-classpath.txt").writeText(sourceSets.main.get().runtimeClasspath.joinToString("\n"))
}
}
dependencies {
testRuntimeOnly(files(tasks["createClasspathManifest"]))
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
kotlinOptions.apiVersion = kotlinVersion
kotlinOptions.allWarningsAsErrors = true
}
tasks.register("resolveAndLockAll") {
doFirst {
require(gradle.startParameter.isWriteDependencyLocks)
}
doLast {
configurations.filter { it.isCanBeResolved }.forEach { it.resolve() }
subprojects.forEach { project ->
project.configurations.filter { it.isCanBeResolved }.forEach { it.resolve() }
}
}
}