-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
153 lines (128 loc) · 5.79 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
plugins {
id "java"
id "org.embulk.embulk-plugins" version "0.7.0"
}
repositories {
mavenCentral()
}
group = "org.embulk"
version = "0.1.0-SNAPSHOT"
// The root project is a dummy Embulk plugin to be tested with ":embulk-junit5-api" and ":embulk-junit5-engine".
//
// src/main -- The main Embulk plugin code
// src/test -- The "unit tests" for the plugin code (normal JUnit 5 tests without any classpath hacks)
// src/embulkTest -- The "Embulk plugin tests" to run with ":embulk-junit5-api" and ":embulk-junit5-engine"
configurations {
compileClasspath.resolutionStrategy.activateDependencyLocking()
runtimeClasspath.resolutionStrategy.activateDependencyLocking()
// No need to declare "embulkTestImplementation" explicitly as the sourceSet "embulkTest" is declared below.
// No need to declare "embulkTestRuntime" explicitly as the sourceSet "embulkTest" is declared below.
//
// "embulkTestImplementation" should not ".extendsFrom testImplementation"
// so that it won't include main and test in the top-level class loader.
//
// "embulkTestRuntime" should not ".extendsFrom testRuntime" similarly.
}
sourceSets {
embulkTest {
java {
srcDir file("src/embulkTest/java")
}
resources.srcDir file("src/embulkTest/resources")
}
}
dependencies {
compileOnly "org.embulk:embulk-spi:0.11"
compileOnly "org.slf4j:slf4j-api:2.0.7"
implementation "org.embulk:embulk-util-config:0.5.0"
implementation "javax.validation:validation-api:2.0.1.Final"
implementation platform("com.fasterxml.jackson:jackson-bom:2.16.2")
implementation "com.fasterxml.jackson.core:jackson-annotations"
implementation "com.fasterxml.jackson.core:jackson-core"
implementation "com.fasterxml.jackson.core:jackson-databind"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.11.0"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.11.0"
embulkTestImplementation project(":embulk-junit5-api") // TODO: embulk-junit5-api depends on junit-jupiter-api transitively?
embulkTestImplementation "org.junit.jupiter:junit-jupiter-api:5.11.0"
embulkTestRuntimeOnly project(":embulk-junit5-engine")
// embulk-core can be loaded in the top-level class loader.
embulkTestRuntimeOnly "org.embulk:embulk-core:0.11.5"
// To access the Embulk core classes from the tests.
embulkTestCompileOnly "org.embulk:embulk-core:0.11.5"
// TODO: Confirm just 'embulkTestImplementation "org.embulk:embulk-core:0.11.5"' may be better?
}
embulkPlugin {
mainClass = "org.embulk.input.junit5example.ExampleInputPlugin"
category = "input"
type = "junit5example"
}
test {
useJUnitPlatform()
testLogging {
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
showCauses = true
showExceptions = true
showStackTraces = true
showStandardStreams = true
outputs.upToDateWhen { false }
}
}
def joinPluginClasspath(FileCollection embulkTestClassesDirs, File embulkTestResourcesDir, FileCollection mainRuntimeClasspath) {
List<String> list = []
embulkTestClassesDirs.files.each { file ->
list.add(file.getAbsolutePath())
}
list.add(embulkTestResourcesDir.getAbsolutePath())
mainRuntimeClasspath.files.each { file ->
list.add(file.getAbsolutePath())
}
return list.join(File.pathSeparator)
}
task embulkTest(type: Test, dependsOn: ":assemble") {
doFirst {
println "^^^^^ Classpath information in main ^^^^^"
println sourceSets.main.runtimeClasspath
println sourceSets.main.runtimeClasspathConfigurationName
sourceSets.main.runtimeClasspath.each {
println it
}
println "^^^^^ Classpath information in embulkTest ^^^^^"
println sourceSets.embulkTest.runtimeClasspath
println sourceSets.embulkTest.runtimeClasspathConfigurationName
sourceSets.embulkTest.runtimeClasspath.each {
println it
}
println "^^^^^ Classpath information done ^^^^^"
}
useJUnitPlatform()
// TODO See the following Gradle implementations to investigate Gradle classpath configurations.
//
// JavaPlugin.createDefaultTestSuite
// https://github.com/gradle/gradle/blob/v8.10.1/platforms/jvm/plugins-java/src/main/java/org/gradle/api/plugins/JavaPlugin.java#L354-L383
//
// SourceSet.getRuntimeClasspathConfigurationName
// https://github.com/gradle/gradle/blob/v8.10.1/platforms/jvm/platform-jvm/src/main/java/org/gradle/api/internal/tasks/DefaultSourceSet.java#L194-L197
//
// SourceSet.getRuntimeClasspath
// https://github.com/gradle/gradle/blob/v8.10.1/platforms/jvm/platform-jvm/src/main/java/org/gradle/api/internal/tasks/DefaultSourceSet.java#L239-L242
classpath = sourceSets.embulkTest.runtimeClasspath
// Pick up "@EmbulkPluginTest" methods from the classes in "testClassesDirs"
testClassesDirs = sourceSets.embulkTest.output.classesDirs
afterEvaluate { project ->
systemProperty "org.embulk.junit5.plugin.class.path",
joinPluginClasspath(sourceSets.embulkTest.output.classesDirs,
sourceSets.embulkTest.output.resourcesDir,
sourceSets.main.runtimeClasspath)
}
testLogging {
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
showCauses = true
showExceptions = true
showStackTraces = true
showStandardStreams = true
outputs.upToDateWhen { false }
}
}