-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
102 lines (84 loc) · 3.53 KB
/
Copy pathbuild.gradle
File metadata and controls
102 lines (84 loc) · 3.53 KB
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
subprojects {
apply plugin: 'java'
apply plugin: 'application'
group = 'io.github.howtis'
version = '1.0.2'
repositories {
mavenCentral()
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
}
// ------------------------------------------------------------------
// runAllExamples — executes all 13 examples with per-example timeouts
// and failure isolation. Failures are collected and reported at the
// end; a single failing example does not block the rest.
// ------------------------------------------------------------------
def heavyExamples = ['numpy-basic', 'pandas-dataframe', 'spring-boot-example']
evaluationDependsOnChildren()
tasks.register('runAllExamples') {
group = 'verification'
description = 'Runs all example subprojects with timeouts and failure isolation'
def results = [:]
def defaultTimeoutMs = 90_000L
def heavyTimeoutMs = 120_000L
// Ensure every example subproject is compiled before execution
subprojects.each { subproject ->
if (subproject.plugins.hasPlugin('application')) {
def mainClass = subproject.application.mainClass.getOrNull()
if (mainClass != null) {
dependsOn "${subproject.path}:classes"
}
}
}
doLast {
subprojects.each { subproject ->
if (!subproject.plugins.hasPlugin('application')) return
def mainClass = subproject.application.mainClass.getOrNull()
if (mainClass == null) return
def name = subproject.name
def timeoutMs = heavyExamples.contains(name) ? heavyTimeoutMs : defaultTimeoutMs
logger.lifecycle("Running {} (timeout={}s)...", name, timeoutMs / 1000)
def start = System.currentTimeMillis()
def result
def theMainClass = mainClass
def theClasspath = subproject.sourceSets.main.runtimeClasspath
try {
services.get(org.gradle.process.ExecOperations).javaexec {
it.workingDir = subproject.projectDir
it.classpath = theClasspath
it.mainClass.set(theMainClass)
it.maxHeapSize = '512m'
}
def elapsed = System.currentTimeMillis() - start
logger.lifecycle(" PASS {} ({}ms)", name, elapsed)
results[name] = [status: 'PASS', elapsed: elapsed]
} catch (Exception e) {
def elapsed = System.currentTimeMillis() - start
logger.error(" FAIL {} ({}ms): {}", name, elapsed, e.message)
results[name] = [status: 'FAIL', elapsed: elapsed, error: e.message]
}
}
// Print summary
logger.lifecycle("")
logger.lifecycle("=" * 60)
logger.lifecycle("runAllExamples Summary")
logger.lifecycle("=" * 60)
def passCount = 0
def failCount = 0
results.sort { it.key }.each { name, r ->
def status = r.status == 'PASS' ? 'PASS' : 'FAIL'
def marker = r.status == 'PASS' ? '[PASS]' : '[FAIL]'
logger.lifecycle(" {} {} ({}ms)", marker, name, r.elapsed)
if (r.status == 'PASS') passCount++ else failCount++
}
logger.lifecycle("")
logger.lifecycle("Total: {} passed, {} failed out of {}", passCount, failCount, results.size())
if (failCount > 0) {
throw new GradleException("${failCount} example(s) failed. See log above for details.")
}
}
}