-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
131 lines (112 loc) · 5.99 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
plugins {
id 'java'
id 'application'
}
version '1.0'
repositories {
mavenCentral()
}
def urlFile = { url, name ->
File file = new File("$buildDir/downloads/${name}.jar")
file.parentFile.mkdirs()
if (!file.exists()) {
new URL(url).withInputStream { downloadStream ->
file.withOutputStream { fileOut ->
fileOut << downloadStream
}
}
}
files(file.absolutePath)
}
dependencies {
implementation group: 'javax.inject', name: 'javax.inject', version: '1'
// https://mvnrepository.com/artifact/commons-cli/commons-cli
implementation group: 'commons-cli', name: 'commons-cli', version: '1.4'
// https://mvnrepository.com/artifact/com.google.guava/guava
implementation group: 'com.google.guava', name: 'guava', version: '21.0'
// https://mvnrepository.com/artifact/com.google.inject/guice
implementation group: 'com.google.inject', name: 'guice', version: '3.0'
// https://mvnrepository.com/artifact/org.eclipse.emf/org.eclipse.emf.common
implementation group: 'org.eclipse.emf', name: 'org.eclipse.emf.common', version: '2.15.0'
// https://mvnrepository.com/artifact/org.antlr/ST4
implementation group: 'org.antlr', name: 'ST4', version: '4.3.1'
// https://mvnrepository.com/artifact/org.eclipse.xtext/org.eclipse.xtext
implementation group: 'org.eclipse.xtext', name: 'org.eclipse.xtext', version: '2.19.0'
// Eclipse doesn't manage a Maven repo, so we use this function to get the JAR from direct download
implementation urlFile('https://download.eclipse.org/modeling/mdt/uml2/updates/5.5/R202211161811/plugins/org.eclipse.uml2.uml_5.5.0.v20221116-1811.jar', 'org.eclipse.uml2.uml_5.5.0')
implementation urlFile('https://download.eclipse.org/modeling/mdt/uml2/updates/5.5milestones/S202211161811/plugins/org.eclipse.uml2.common_2.5.0.v20221116-1811.jar', 'org.eclipse.uml2.common_2.5.0')
implementation urlFile('https://download.eclipse.org/modeling/mdt/uml2/updates/5.5milestones/S202211161811/plugins/org.eclipse.uml2.types_2.5.0.v20221116-1811.jar', 'org.eclipse.uml2.types_2.5.0')
implementation urlFile('https://download.eclipse.org/modeling/mdt/uml2/updates/5.5milestones/S202211161811/plugins/org.eclipse.uml2.uml.profile.standard_1.5.0.v20221116-1811.jar', 'org.eclipse.uml2.uml.profile.standard_1.5.0')
implementation urlFile('https://download.eclipse.org/modeling/mdt/uml2/updates/5.5milestones/S202211161811/plugins/org.eclipse.uml2.uml.resources_5.5.0.v20221116-1811.jar', 'org.eclipse.uml2.uml.resources_5.5.0')
}
mainClassName = 'comodo2.engine.Main'
application {
mainClass = mainClassName
}
sourceSets {
main.java.srcDirs = ['comodo2/src']
main.resources.srcDirs = ['comodo2/src']
}
jar {
duplicatesStrategy = 'exclude'
manifest {
attributes 'Main-Class': mainClassName
}
from {
configurations.runtimeClasspath.collect {
it.isDirectory() ? it : zipTree(it)
}
} {exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'}
}
// #################### TESTING ########################
// The testing strategy is: each target is executed on a set of models in the execute<name>Target.
// The output is then compared in test<name>Target with the reference output, usually stored under test/<name>/ref.
// RESULTS_MAPPING is used to store the results of the tests.
ext.TEST_OUTPUT_PATH = "./test/gradle-testgen"
ext.RESULTS_MAPPING = [:]
// This function defines tasks that execute the target on the test models and compares the output with the reference output
def defineTargetTestingTask(String taskName, String targetType, String inputFilePath, String modelName, String expectedOutputPath, String extraArgs = "") {
task("execute${taskName}Target", type: Exec) {
dependsOn build
group = "Execution"
description = "Run the ${targetType} target on the test models (${modelName})"
commandLine "java", "-classpath", sourceSets.main.runtimeClasspath.getAsPath(), mainClassName
args "-i", inputFilePath, "-o", "${TEST_OUTPUT_PATH}/${taskName}", "-t", targetType, "-m", modelName, "-a", extraArgs
}
task("test${taskName}Target", type: Exec) {
dependsOn "execute${taskName}Target"
group = "DiffTesting"
description = "Test the ${targetType} target by comparing its output with the reference output."
new File("${TEST_OUTPUT_PATH}").mkdirs()
def outputFilename = "${TEST_OUTPUT_PATH}/${taskName}.difflog"
standardOutput = new FileOutputStream(outputFilename)
commandLine "diff", "-rb", "${TEST_OUTPUT_PATH}/${taskName}", "${expectedOutputPath}"
ignoreExitValue = true
doLast {
def output = new FileInputStream(outputFilename).text.trim()
if (output) {
println "[FAIL] Test failure: the generated code is different from the reference code. Please check the diff in ${outputFilename}."
RESULTS_MAPPING.put(taskName, "FAIL")
} else {
RESULTS_MAPPING.put(taskName, "PASS")
println "[PASS] Test succeeded."
}
}
}
}
// Defining test tasks
defineTargetTestingTask("QPC-C", "QPC-C", "./test/qpc/model/qpc-test-model/qpc-test-model.uml", "BlinkyChoice", "./test/qpc/ref")
defineTargetTestingTask("ELT-RAD1", "ELT-RAD", "./test/elt/model/hello/EELT_ICS_ApplicationFramework.uml", "hellomalif hellomal", "./test/elt/ref/hello", "-ndgALL")
defineTargetTestingTask("ELT-RAD2", "ELT-RAD", "./test/elt/model/hello/EELT_ICS_ApplicationFramework.uml", "hellomalif2 externalif2 hellomal2", "./test/elt/ref/hello2", "-ndgALL")
// Execute all tests and returns results
task testAll {
dependsOn tasks.matching { it.group == "DiffTesting" }
doLast{
println "${RESULTS_MAPPING.size()} tests executed. Results (PASS/FAIL) by target: ${RESULTS_MAPPING}"
if (RESULTS_MAPPING.values().any { it == "FAIL" }) {
throw new GradleException("[FAIL] At least one test failed. See logs above and in ${TEST_OUTPUT_PATH}/*.difflog for details.")
} else {
println "[PASS] All tests succeeded."
}
}
}