gradle: make DSL groovy-friendly

This commit is contained in:
Alexey Andreev 2023-02-18 09:10:08 +01:00
parent 4fdb05905d
commit 27713b78f8
3 changed files with 39 additions and 1 deletions

View File

@ -15,7 +15,7 @@
*/ */
plugins { plugins {
id("org.teavm") version "0.7.0-SNAPSHOT" apply false id("org.teavm") version "0.8.0-SNAPSHOT" apply false
id("org.wisepersist.gwt") version "1.1.19" apply false id("org.wisepersist.gwt") version "1.1.19" apply false
} }

View File

@ -15,6 +15,7 @@
*/ */
package org.teavm.gradle; package org.teavm.gradle;
import groovy.lang.Closure;
import java.io.File; import java.io.File;
import org.gradle.api.Action; import org.gradle.api.Action;
import org.gradle.api.Project; import org.gradle.api.Project;
@ -117,6 +118,11 @@ class TeaVMExtensionImpl extends TeaVMBaseExtensionImpl implements TeaVMExtensio
action.execute(getJs()); action.execute(getJs());
} }
@Override
public void js(Closure<Void> action) {
action.rehydrate(getJs(), action.getOwner(), action.getThisObject()).call();
}
@Override @Override
public TeaVMWasmConfiguration getWasm() { public TeaVMWasmConfiguration getWasm() {
return wasm; return wasm;
@ -127,6 +133,11 @@ class TeaVMExtensionImpl extends TeaVMBaseExtensionImpl implements TeaVMExtensio
action.execute(getWasm()); action.execute(getWasm());
} }
@Override
public void wasm(Closure<Void> action) {
action.rehydrate(getWasm(), action.getOwner(), action.getThisObject()).call();
}
@Override @Override
public TeaVMWasiConfiguration getWasi() { public TeaVMWasiConfiguration getWasi() {
return wasi; return wasi;
@ -137,6 +148,11 @@ class TeaVMExtensionImpl extends TeaVMBaseExtensionImpl implements TeaVMExtensio
action.execute(wasi); action.execute(wasi);
} }
@Override
public void wasi(Closure<Void> action) {
action.rehydrate(getWasi(), action.getOwner(), action.getThisObject()).call();
}
@Override @Override
public TeaVMCConfiguration getC() { public TeaVMCConfiguration getC() {
return c; return c;
@ -147,6 +163,11 @@ class TeaVMExtensionImpl extends TeaVMBaseExtensionImpl implements TeaVMExtensio
action.execute(c); action.execute(c);
} }
@Override
public void c(Closure<Void> action) {
action.rehydrate(getC(), action.getOwner(), action.getThisObject()).call();
}
@Override @Override
public TeaVMCommonConfiguration getAll() { public TeaVMCommonConfiguration getAll() {
return all; return all;
@ -157,6 +178,11 @@ class TeaVMExtensionImpl extends TeaVMBaseExtensionImpl implements TeaVMExtensio
action.execute(getAll()); action.execute(getAll());
} }
@Override
public void all(Closure<Void> action) {
action.rehydrate(getAll(), action.getOwner(), action.getThisObject()).call();
}
private void inherit(TeaVMCommonConfiguration target, TeaVMCommonConfiguration source) { private void inherit(TeaVMCommonConfiguration target, TeaVMCommonConfiguration source) {
target.getMainClass().convention(source.getMainClass()); target.getMainClass().convention(source.getMainClass());
target.getOutputDir().convention(source.getOutputDir()); target.getOutputDir().convention(source.getOutputDir());

View File

@ -15,6 +15,8 @@
*/ */
package org.teavm.gradle.api; package org.teavm.gradle.api;
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import org.gradle.api.Action; import org.gradle.api.Action;
public interface TeaVMExtension extends TeaVMBaseExtension { public interface TeaVMExtension extends TeaVMBaseExtension {
@ -22,19 +24,29 @@ public interface TeaVMExtension extends TeaVMBaseExtension {
void js(Action<TeaVMJSConfiguration> action); void js(Action<TeaVMJSConfiguration> action);
void js(@DelegatesTo(TeaVMJSConfiguration.class) Closure<Void> action);
TeaVMWasmConfiguration getWasm(); TeaVMWasmConfiguration getWasm();
void wasm(Action<TeaVMWasmConfiguration> action); void wasm(Action<TeaVMWasmConfiguration> action);
void wasm(@DelegatesTo(TeaVMWasmConfiguration.class) Closure<Void> action);
TeaVMWasiConfiguration getWasi(); TeaVMWasiConfiguration getWasi();
void wasi(Action<TeaVMWasiConfiguration> action); void wasi(Action<TeaVMWasiConfiguration> action);
void wasi(@DelegatesTo(TeaVMWasiConfiguration.class) Closure<Void> action);
TeaVMCConfiguration getC(); TeaVMCConfiguration getC();
void c(Action<TeaVMCConfiguration> action); void c(Action<TeaVMCConfiguration> action);
void c(@DelegatesTo(TeaVMCConfiguration.class) Closure<Void> action);
TeaVMCommonConfiguration getAll(); TeaVMCommonConfiguration getAll();
void all(Action<TeaVMCommonConfiguration> action); void all(Action<TeaVMCommonConfiguration> action);
void all(@DelegatesTo(TeaVMCommonConfiguration.class) Closure<Void> action);
} }