-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
159 lines (133 loc) · 4.76 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
plugins {
id "antlr"
id "application"
id "eclipse"
id "idea"
id "java"
id "maven-publish"
id "signing"
id "com.github.johnrengelman.shadow" version "8.1.1"
}
project.version = '0.1.0-SNAPSHOT'
project.group = 'de.hhu.stups'
final isSnapshot = project.version.endsWith("-SNAPSHOT")
repositories {
mavenCentral()
if (isSnapshot) {
maven {
name "snapshots"
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
}
// Prevent the full ANTLR tool (not just the runtime) being declared as a runtime dependency of our code.
// Workaround for https://github.com/gradle/gradle/issues/820
configurations {
api {
extendsFrom = extendsFrom.findAll {it != antlr}
}
}
dependencies {
def antlrVersion = "4.9.3"
antlr group: "org.antlr", name: "antlr4", version: antlrVersion
api group: "org.antlr", name: "antlr4-runtime", version: antlrVersion
testImplementation 'junit:junit:4.13.2'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
withJavadocJar()
}
// gradle generateGrammarSource
generateGrammarSource {
// This combination of "-lib", "-Xexact-output-dir", and outputDirectory is necessary
// to have both the grammar files and generated sources in the correct package without breaking imports.
arguments += ["-visitor", "-long-messages", "-package", "files", "-lib", "src/main/antlr/files", "-Xexact-output-dir"]
outputDirectory = file('build/generated-src/antlr/main/files')
}
// Workaround for Gradle's antlr plugin not adding the necessary dependencies to sourcesJar and javadocJar,
// causing an error with Gradle 8 because of undeclared dependencies.
// See https://github.com/gradle/gradle/issues/19555 and https://github.com/gradle/gradle/issues/25885
sourcesJar {
dependsOn("generateGrammarSource")
}
javadocJar {
dependsOn("generateGrammarSource")
}
def readCurrentGitCommit() {
def proc = ["git", "rev-parse", "HEAD"].execute(null, project.projectDir)
def exitCode = proc.waitFor()
if (exitCode != 0) {
throw new IllegalStateException("git rev-parse command exited with status code ${exitCode}:\n" + proc.err.readLines().join("\n"))
}
return proc.in.readLines()[0]
}
final currentGitCommit = readCurrentGitCommit()
processResources {
inputs.property("project.version", project.version)
inputs.property("currentGitCommit", currentGitCommit)
filesMatching("de/prob/parser/antlr/build.properties") {
expand(version: project.version, git: currentGitCommit)
}
}
sourceSets.test.runtimeClasspath += files(sourceSets.main.java.srcDirs) // What does this do?
tasks.withType(JavaExec) {
// Shouldn't be needed anymore - please use ./gradlew run --args="..." instead.
if(project.hasProperty('file')) {
if (project.hasProperty('typecheck')) {
args([file, typecheck])
} else {
args([file, true])
}
}
}
application {
mainClass = "de.prob.parser.antlr.Antlr4BParser"
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = "ANTLR B parser"
description = "DO NOT USE THIS PLEASE"
url = "https://github.com/hhu-stups/antlr-parser"
licenses {
license {
name = "EPL-1.0"
url = "https://www.eclipse.org/org/documents/epl-v10.html"
}
}
scm {
connection = "scm:git:https://github.com/hhu-stups/antlr-parser.git"
developerConnection = "scm:git:https://gitlab.cs.uni-duesseldorf.de/stups/prob/antlr_b_parser.git"
url = "https://github.com/hhu-stups/antlr-parser"
}
developers {
developer {
id = "vu"
name = "Fabian Vu"
email = "fabian.vu@hhu.de"
}
}
}
}
}
repositories {
maven {
final releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
final snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url isSnapshot ? snapshotsRepoUrl : releasesRepoUrl
if (project.hasProperty("ossrhUsername") && project.hasProperty("ossrhPassword")) {
credentials {
username project.ossrhUsername
password project.ossrhPassword
}
}
}
}
}
ext."signing.secretKeyRingFile" = rootProject.file("secring.gpg").absolutePath
signing {
sign publishing.publications.mavenJava
}