-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
170 lines (144 loc) · 4.98 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
/*
Project log_ag
Gradle build file for JaCaMo Applications
March 27, 2023 - 12:57:02
*/
defaultTasks 'run'
apply plugin: 'java'
version '1.0'
group 'org.jacamo'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
repositories {
maven { url "https://raw.githubusercontent.com/jacamo-lang/mvn-repo/master" }
maven { url "https://repo.gradle.org/gradle/libs-releases" }
//maven { url "http://jacamo.sourceforge.net/maven2" }
//maven { url "https://jade.tilab.com/maven/" }
flatDir { dirs 'lib' }
mavenCentral()
}
dependencies {
//implementation('org.jacamo:jacamo:1.1')
implementation('com.google.code.gson:gson:2.8.8')
implementation('io.github.jason-lang:jason-interpreter:3.2.1-SNAPSHOT')
implementation('org.jacamo:jacamo:1.2-SNAPSHOT')
}
sourceSets {
main {
java {
srcDir 'src/env'
srcDir 'src/agt'
srcDir 'src/org'
srcDir 'src/int'
srcDir 'src/java'
}
resources {
srcDir 'src/resources'
}
}
}
task run (type: JavaExec, dependsOn: 'classes') {
group ' JaCaMo'
description 'runs the JaCaMo application'
doFirst {
mkdir 'log'
}
mainClass = 'jacamo.infra.JaCaMoLauncher'
args 'agent_logging.jcm'
// jvmArgs '-Xss15m'
classpath sourceSets.main.runtimeClasspath
}
task uberJar(type: Jar, dependsOn: 'classes') {
group ' JaCaMo'
description 'creates a single runnable jar file with all dependencies'
duplicatesStrategy 'exclude'
manifest {
attributes 'Main-Class': 'jacamo.infra.JaCaMoLauncher'
}
archiveBaseName = 'jacamo-agent_logging' // the name must start with jacamo so that jacamo...jar is found in the classpath
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
from (project.projectDir.absolutePath) {
include '**/*.asl'
include '**/*.xml'
include '**/*.sai'
include '**/*.ptl'
include '**/*.jcm'
include '*.properties'
}
from (project.buildDir.absolutePath + '/jcm') {
include '**/*'
}
with jar
doFirst {
copy {
from 'agent_logging.jcm'
rename 'agent_logging.jcm','default.jcm'
into project.buildDir.absolutePath + '/jcm'
}
}
}
task testJaCaMo {
description 'runs JaCaMo unit tests'
def errorOnTests = false
outputs.upToDateWhen { false } // disable cache
doFirst {
try {
javaexec {
mainClass = 'jacamo.infra.JaCaMoLauncher'
if (gradle.startParameter.logLevel.toString().equals("DEBUG")) {
args = ['src/test/tests.jcm', '--log-conf', '$jasonJar/templates/console-debug-logging.properties']
} else if (gradle.startParameter.logLevel.toString().equals("INFO")) {
args = ['src/test/tests.jcm', '--log-conf', '$jasonJar/templates/console-info-logging.properties']
} else {
args = ['src/test/tests.jcm', '--log-conf', '$jasonJar/templates/console-lifecycle-logging.properties']
}
classpath sourceSets.main.runtimeClasspath
errorOutput = new ByteArrayOutputStream()
standardOutput = new ByteArrayOutputStream()
ext.stdout = {
return standardOutput.toString()
}
ext.errout = {
return errorOutput.toString()
}
}
} catch (Exception e) {
errorOnTests = true
}
}
doLast {
def styler = 'black red green yellow blue magenta cyan white'
.split().toList().withIndex(30)
.collectEntries { key, val -> [(key) : { "\033[${val}m${it}\033[0m" }] }
def std = stdout()
std.splitEachLine('\n') { String line ->
line = line.replace("TESTING","${styler['yellow']('TESTING')}")
line = line.replace("PASSED","${styler['green']('PASSED')}")
line = line.replace("FAILED","${styler['red']('FAILED')}")
line = line.replace("TODO","${styler['magenta']('TODO')}")
line = line.replace("LAUNCHING","${styler['blue']('LAUNCHING')}")
println line
}
def err = errout()
err.splitEachLine('\n') { String line ->
line = line.replace("TESTING","${styler['yellow']('TESTING')}")
line = line.replace("PASSED","${styler['green']('PASSED')}")
line = line.replace("FAILED","${styler['red']('FAILED')}")
line = line.replace("TODO","${styler['magenta']('TODO')}")
line = line.replace("LAUNCHING","${styler['blue']('LAUNCHING')}")
println line
}
if (errorOnTests) {
throw new GradleException('JaCaMo unit tests: ERROR!')
}
}
}
tasks.test.finalizedBy testJaCaMo
clean {
delete 'bin'
delete 'build'
delete 'log'
}