-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
77 lines (63 loc) · 1.68 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
plugins {
id 'java'
id 'antlr'
id 'application'
}
group 'com.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
// ANTLR dependency
antlr 'org.antlr:antlr4:4.9.2'
// ASM dependencies
implementation 'org.ow2.asm:asm:9.2'
implementation 'org.ow2.asm:asm-commons:9.2'
implementation 'commons-cli:commons-cli:1.5.0'
// JUnit for testing
testImplementation 'junit:junit:4.13.2'
}
sourceSets {
main {
java {
// Include generated ANTLR sources in the compilation process
srcDirs += "${buildDir}/generated-src/antlr/main"
}
}
}
tasks.withType(JavaCompile) {
// Ensure generated ANTLR sources are compiled
dependsOn tasks.generateGrammarSource
}
generateGrammarSource {
arguments += ['-visitor'] // Generates a parse tree visitor class
outputDirectory = file("${buildDir}/generated-src/antlr/main/com/example")
}
// Task to add a package declaration to the generated ANTLR files
tasks.named("generateGrammarSource") {
doLast {
def outputDir = file("${buildDir}/generated-src/antlr/main/com/example")
outputDir.eachFileRecurse { file ->
if (file.name.endsWith('.java')) {
def lines = file.readLines()
lines.add(0, "package com.example;")
file.text = lines.join('\n')
}
}
}
}
jar {
manifest {
attributes(
'Main-Class': 'com.example.Main' // Entry point for your compiler
)
}
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
application {
mainClass = 'com.example.Main'
}