gradle: make tests DSL groovy-friendly

This commit is contained in:
Alexey Andreev 2023-02-18 18:37:07 +01:00
parent a4b2199142
commit 725aac089b
4 changed files with 27 additions and 0 deletions

View File

@ -15,6 +15,7 @@
*/
package org.teavm.gradle;
import groovy.lang.Closure;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
@ -120,4 +121,9 @@ class TeaVMBaseExtensionImpl implements TeaVMBaseExtension {
public void tests(Action<TeaVMTests> config) {
config.execute(tests);
}
@Override
public void tests(Closure<Void> config) {
config.rehydrate(getTests(), config.getOwner(), config.getThisObject()).call();
}
}

View File

@ -15,6 +15,7 @@
*/
package org.teavm.gradle;
import groovy.lang.Closure;
import org.gradle.api.Action;
import org.gradle.api.model.ObjectFactory;
import org.teavm.gradle.api.TeaVMJSTests;
@ -40,6 +41,11 @@ class TeaVMTestsImpl implements TeaVMTests {
config.execute(js);
}
@Override
public void js(Closure<Void> config) {
config.rehydrate(getJs(), config.getOwner(), config.getThisObject()).call();
}
@Override
public TeaVMWasmTests getWasm() {
return wasm;
@ -50,6 +56,11 @@ class TeaVMTestsImpl implements TeaVMTests {
config.execute(wasm);
}
@Override
public void wasm(Closure<Void> config) {
config.rehydrate(getWasm(), config.getOwner(), config.getThisObject()).call();
}
void configure(TeaVMBaseExtensionImpl extension) {
js.configure(extension);
wasm.configure(extension);

View File

@ -15,6 +15,8 @@
*/
package org.teavm.gradle.api;
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
import org.gradle.api.provider.Provider;
@ -26,4 +28,6 @@ public interface TeaVMBaseExtension {
TeaVMTests getTests();
void tests(Action<TeaVMTests> config);
void tests(@DelegatesTo(TeaVMTests.class) Closure<Void> config);
}

View File

@ -15,6 +15,8 @@
*/
package org.teavm.gradle.api;
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
public interface TeaVMTests {
@ -22,7 +24,11 @@ public interface TeaVMTests {
void js(Action<TeaVMJSTests> config);
void js(@DelegatesTo(TeaVMJSTests.class) Closure<Void> config);
TeaVMWasmTests getWasm();
void wasm(Action<TeaVMWasmTests> config);
void wasm(@DelegatesTo(TeaVMWasmTests.class) Closure<Void> config);
}