-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
188 lines (156 loc) · 5.75 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
// (c) https://github.com/MontiCore/monticore
/* ============================================================ */
/* ========================= Plugins ========================== */
/* ============================================================ */
plugins {
id 'java'
id "monticore" version "$mc_version"
id 'maven-publish'
id "com.github.johnrengelman.shadow" version "6.0.0"
//id "de.set.ecj" version "1.4.1" // Eclipse compiler as it's much faster than javac
id 'org.unbroken-dome.test-sets' version '3.0.1'
id "io.github.themrmilchmann.ecj" version "0.2.0"
}
/* ============================================================ */
/* ========================= Project ========================== */
/* ============================================================ */
group = 'de.monticore.lang'
description = 'json'
sourceCompatibility = '11'
/* ============================================================ */
/* ========================= Versions ========================= */
/* ============================================================ */
def junit_version = "4.13.1"
def commons_cli_version = "1.4"
def grammar_classifier = "grammars"
def grammarDir = "src/main/grammars"
/* ============================================================ */
/* ======================= Configuration ====================== */
/* ============================================================ */
// configure non-standard source sets
sourceSets {
main.java.srcDirs += [ "$projectDir/target/generated-sources/monticore/sourcecode"]
grammars {
resources {
srcDirs([grammarDir])
include "**/*.mc4"
}
}
test {
java.srcDir "$projectDir/src/test/java"
resources.srcDir "$projectDir/src/test/resources"
}
}
buildDir = file("$projectDir/target")
configurations {grammar}
java {
registerFeature('grammars') {
usingSourceSet(sourceSets.grammars)
}
}
test {
useJUnit()
}
/* ============================================================ */
/* ======================= Dependencies ======================= */
/* ============================================================ */
repositories {
if(("true").equals(getProperty('useLocalRepo'))){
mavenLocal()
}
mavenCentral()
maven {
credentials.username mavenUser
credentials.password mavenPassword
url repo
}
}
dependencies {
grammar ("de.monticore:monticore-grammar:$mc_version") {capabilities {
requireCapability("de.monticore:monticore-grammar-grammars") }
}
implementation "de.se_rwth.commons:se-commons-logging:$se_commons_version"
implementation "org.antlr:antlr4-runtime:4.12.0"
implementation "de.monticore:monticore-runtime:${project.properties['mc_version']}"
implementation "de.monticore:monticore-grammar:${project.properties['mc_version']}"
implementation "org.assertj:assertj-core:3.7.0"
implementation "commons-cli:commons-cli:$commons_cli_version"
implementation 'org.apache.commons:commons-lang3:3.0'
implementation "net.sourceforge.plantuml:plantuml:1.2023.7"
testImplementation "junit:junit:$junit_version"
}
/* ============================================================ */
/* ========================== Tasks =========================== */
/* ============================================================ */
task generateJSON(type: MCTask) {
grammar = file "$projectDir/$grammarDir/de/monticore/lang/JSON.mc4"
outputDir = file "$buildDir/generated-sources/monticore/sourcecode"
handcodedPath "$projectDir/src/main/java"
def uptoDate = incCheck("de/monticore/lang/JSON.mc4")
outputs.upToDateWhen { uptoDate }
}
compileJava.dependsOn(generateJSON)
tasks.withType(Copy).all { duplicatesStrategy 'exclude' }
tasks.withType(JavaCompile) {
options.fork = true
options.encoding = "UTF-8"
options.deprecation = false
options.warnings = false
options.headerOutputDirectory.convention(null)
}
// build sources jar in addition
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = "sources"
}
sourcesJar.dependsOn project.collect { it.tasks.withType(MCTask)}
// build javadoc jar in addition
task javadocJar(type: Jar) {
from javadoc
archiveClassifier = "javadoc"
}
// generated java doc contains errors, disable for now
javadoc.failOnError(false)
// build grammar jar as well
task grammarJar(type: Jar) {
from("$projectDir/src/main/grammars/") { include "**/*.mc4" }
archiveClassifier = "grammars"
}
// all in one tool-jar
shadowJar {
manifest {
attributes "Main-Class": "de.monticore.lang.json.JSONTool"
}
archiveFileName = "MC${archiveBaseName.get()}.${archiveExtension.get()}"
archiveClassifier = "mc-tool"
minimize {
exclude(dependency('org.freemarker:freemarker:.*'))
}
}
jar.dependsOn shadowJar
/* ============================================================ */
/* ======================= Publishing ========================= */
/* ============================================================ */
publishing {
// configure what artifacts to publish
publications {
mavenJava(MavenPublication) {
artifactId = "$project.name"
from components.java
artifact sourcesJar
artifact javadocJar
// artifact shadowJar
}
}
repositories.maven {
credentials.username mavenUser
credentials.password mavenPassword
def releasesRepoUrl = "https://nexus.se.rwth-aachen.de/content/repositories/monticore-releases/"
def snapshotsRepoUrl = "https://nexus.se.rwth-aachen.de/content/repositories/monticore-snapshots/"
url = version.endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
}
}
task buildAll(type: GradleBuild) {
tasks = [ 'build' ]
}
defaultTasks 'build'