@@ -95,51 +95,35 @@ tasks.generateSmithyProjections {
9595 }
9696}
9797
98- abstract class ProtocolTestTask @Inject constructor(private val project : Project ) : DefaultTask() {
99- /* *
100- * The projection
101- */
102- @get:Input
103- abstract val projectionName: Property <String >
104-
105- /* *
106- * The projection root directory
107- */
108- @get:Input
109- abstract val projectionRootDirectory: Property <String >
110-
111- @TaskAction
112- fun runTests () {
113- val projectionRootDir = project.file(projectionRootDirectory.get())
114- println (" [$projectionName ] buildDir: $projectionRootDir " )
115- if (! projectionRootDir.exists()) {
116- throw GradleException (" $projectionRootDir does not exist" )
117- }
118- val wrapper = if (System .getProperty(" os.name" ).lowercase().contains(" windows" )) " gradlew.bat" else " gradlew"
119- val gradlew = project.rootProject.file(wrapper).absolutePath
120-
121- // NOTE - this still requires us to publish to maven local.
122- project.exec {
123- workingDir = projectionRootDir
124- executable = gradlew
125- args = listOf (" test" )
126- }
127- }
128- }
129-
13098smithyBuild.projections.forEach {
13199 val protocolName = it.name
100+ val dirProvider = smithyBuild
101+ .smithyKotlinProjectionPath(protocolName)
102+ .map { file(it.toString()) }
132103
133- tasks.register<ProtocolTestTask >(" testProtocol-$protocolName " ) {
134- dependsOn(tasks.generateSmithyProjections)
104+ tasks.register<Exec >(" testProtocol-$protocolName " ) {
135105 group = " Verification"
136- projectionName.set(it.name)
137- projectionRootDirectory.set(smithyBuild.smithyKotlinProjectionPath(it.name).map { it.toString() })
106+ dependsOn(tasks.generateSmithyProjections)
107+
108+ doFirst {
109+ val dir = dirProvider.get()
110+ require(dir.exists()) { " $dir does not exist" }
111+
112+ val wrapper = if (System .getProperty(" os.name" ).lowercase().contains(" windows" )) {
113+ " gradlew.bat"
114+ } else {
115+ " gradlew"
116+ }
117+ val gradlew = rootProject.layout.projectDirectory.file(wrapper).asFile.absolutePath
118+
119+ workingDir = dir
120+ executable = gradlew
121+ args = listOf (" test" )
122+ }
138123 }
139124}
140125
141126tasks.register(" testAllProtocols" ) {
142127 group = " Verification"
143- val allTests = tasks.withType<ProtocolTestTask >()
144- dependsOn(allTests)
128+ dependsOn(tasks.matching { it.name.startsWith(" testProtocol-" ) })
145129}
0 commit comments