From e3da484f796a0e0e14bb85d814ff6d61204248d9 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Wed, 25 Jan 2023 10:55:38 +0100 Subject: [PATCH] Gradle: support configuring tests, fix test deobfuscation --- tools/deobfuscator-js/build.gradle.kts | 2 +- .../teavm/gradle/TeaVMBaseExtensionImpl.java | 22 ++++++- .../org/teavm/gradle/TeaVMExtensionImpl.java | 15 +++-- .../org/teavm/gradle/TeaVMJSTestsImpl.java | 55 +++++++++++++++++ .../org/teavm/gradle/TeaVMLibraryPlugin.java | 6 +- .../java/org/teavm/gradle/TeaVMPlugin.java | 12 +++- .../teavm/gradle/TeaVMTestConfigurator.java | 60 +++++++++++++++++++ .../java/org/teavm/gradle/TeaVMTestsImpl.java | 57 ++++++++++++++++++ .../org/teavm/gradle/TeaVMWasmTestsImpl.java | 47 +++++++++++++++ .../gradle/{ => api}/OptimizationLevel.java | 2 +- .../gradle/{ => api}/TeaVMBaseExtension.java | 7 ++- .../gradle/{ => api}/TeaVMCConfiguration.java | 2 +- .../{ => api}/TeaVMCommonConfiguration.java | 2 +- .../gradle/{ => api}/TeaVMConfiguration.java | 2 +- .../gradle/{ => api}/TeaVMExtension.java | 2 +- .../{ => api}/TeaVMJSConfiguration.java | 2 +- .../org/teavm/gradle/api/TeaVMJSTests.java | 26 ++++++++ .../gradle/{ => api}/TeaVMLibraries.java | 2 +- .../TeaVMNativeBaseConfiguration.java | 2 +- .../java/org/teavm/gradle/api/TeaVMTests.java | 28 +++++++++ .../{ => api}/TeaVMWasiConfiguration.java | 2 +- .../{ => api}/TeaVMWasmBaseConfiguration.java | 2 +- .../{ => api}/TeaVMWasmConfiguration.java | 2 +- .../org/teavm/gradle/api/TeaVMWasmTests.java | 24 ++++++++ .../{ => api}/TeaVMWebConfiguration.java | 2 +- .../teavm/gradle/api/TeaVMWebTestRunner.java | 23 +++++++ .../gradle/{ => tasks}/GenerateCTask.java | 2 +- .../{ => tasks}/GenerateJavaScriptTask.java | 2 +- .../gradle/{ => tasks}/GenerateWasiTask.java | 2 +- .../gradle/{ => tasks}/GenerateWasmTask.java | 2 +- .../{ => tasks}/GradleTeaVMToolLog.java | 8 +-- .../teavm/gradle/{ => tasks}/TeaVMTask.java | 3 +- 32 files changed, 394 insertions(+), 33 deletions(-) create mode 100644 tools/gradle/src/main/java/org/teavm/gradle/TeaVMJSTestsImpl.java create mode 100644 tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestConfigurator.java create mode 100644 tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestsImpl.java create mode 100644 tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmTestsImpl.java rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/OptimizationLevel.java (95%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/TeaVMBaseExtension.java (85%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/TeaVMCConfiguration.java (96%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/TeaVMCommonConfiguration.java (97%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/TeaVMConfiguration.java (96%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/TeaVMExtension.java (97%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/TeaVMJSConfiguration.java (96%) create mode 100644 tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMJSTests.java rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/TeaVMLibraries.java (96%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/TeaVMNativeBaseConfiguration.java (96%) create mode 100644 tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMTests.java rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/TeaVMWasiConfiguration.java (95%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/TeaVMWasmBaseConfiguration.java (96%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/TeaVMWasmConfiguration.java (95%) create mode 100644 tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmTests.java rename tools/gradle/src/main/java/org/teavm/gradle/{ => api}/TeaVMWebConfiguration.java (96%) create mode 100644 tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWebTestRunner.java rename tools/gradle/src/main/java/org/teavm/gradle/{ => tasks}/GenerateCTask.java (98%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => tasks}/GenerateJavaScriptTask.java (98%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => tasks}/GenerateWasiTask.java (97%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => tasks}/GenerateWasmTask.java (97%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => tasks}/GradleTeaVMToolLog.java (89%) rename tools/gradle/src/main/java/org/teavm/gradle/{ => tasks}/TeaVMTask.java (98%) diff --git a/tools/deobfuscator-js/build.gradle.kts b/tools/deobfuscator-js/build.gradle.kts index 11acb0b4c..f681ba8bb 100644 --- a/tools/deobfuscator-js/build.gradle.kts +++ b/tools/deobfuscator-js/build.gradle.kts @@ -56,7 +56,7 @@ val generateLibJs by tasks.register("generateLibJs") { mainClass.set("org.teavm.tooling.deobfuscate.js.Compiler") args( "org.teavm.tooling.deobfuscate.js.DeobfuscatorLib", - "\$teavm_deobfuscator", + "deobfuscator", File(buildDir, "teavm-lib").absolutePath, "deobfuscator-lib.js", ) diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtensionImpl.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtensionImpl.java index 6282c3b40..28c3114d9 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtensionImpl.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtensionImpl.java @@ -21,17 +21,23 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Properties; import javax.inject.Inject; +import org.gradle.api.Action; import org.gradle.api.Project; import org.gradle.api.artifacts.Dependency; +import org.gradle.api.model.ObjectFactory; import org.gradle.api.provider.Provider; +import org.teavm.gradle.api.TeaVMBaseExtension; +import org.teavm.gradle.api.TeaVMLibraries; +import org.teavm.gradle.api.TeaVMTests; import org.teavm.gradle.config.ArtifactCoordinates; -public class TeaVMBaseExtensionImpl implements TeaVMBaseExtension { +class TeaVMBaseExtensionImpl implements TeaVMBaseExtension { protected Project project; private Provider properties; + private TeaVMTestsImpl tests; @Inject - public TeaVMBaseExtensionImpl(Project project) { + TeaVMBaseExtensionImpl(Project project, ObjectFactory objectFactory) { this.project = project; properties = project.provider(() -> { var result = new Properties(); @@ -44,6 +50,8 @@ public class TeaVMBaseExtensionImpl implements TeaVMBaseExtension { } return result; }); + tests = new TeaVMTestsImpl(objectFactory); + tests.configure(this); } private void append(Properties target, File source) throws IOException { @@ -102,4 +110,14 @@ public class TeaVMBaseExtensionImpl implements TeaVMBaseExtension { return project.getProviders().gradleProperty("teavm." + name).getOrElse(null); }); } + + @Override + public TeaVMTests getTests() { + return tests; + } + + @Override + public void tests(Action config) { + config.execute(tests); + } } diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtensionImpl.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtensionImpl.java index 84e8ce605..f2eacb3e7 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtensionImpl.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtensionImpl.java @@ -16,21 +16,26 @@ package org.teavm.gradle; import java.io.File; -import javax.inject.Inject; import org.gradle.api.Action; import org.gradle.api.Project; import org.gradle.api.model.ObjectFactory; +import org.teavm.gradle.api.OptimizationLevel; +import org.teavm.gradle.api.TeaVMCConfiguration; +import org.teavm.gradle.api.TeaVMCommonConfiguration; +import org.teavm.gradle.api.TeaVMExtension; +import org.teavm.gradle.api.TeaVMJSConfiguration; +import org.teavm.gradle.api.TeaVMWasiConfiguration; +import org.teavm.gradle.api.TeaVMWasmConfiguration; -public class TeaVMExtensionImpl extends TeaVMBaseExtensionImpl implements TeaVMExtension { +class TeaVMExtensionImpl extends TeaVMBaseExtensionImpl implements TeaVMExtension { private TeaVMJSConfiguration js; private TeaVMWasmConfiguration wasm; private TeaVMWasiConfiguration wasi; private TeaVMCConfiguration c; private TeaVMCommonConfiguration all; - @Inject - public TeaVMExtensionImpl(Project project, ObjectFactory objectFactory) { - super(project); + TeaVMExtensionImpl(Project project, ObjectFactory objectFactory) { + super(project, objectFactory); js = objectFactory.newInstance(TeaVMJSConfiguration.class); wasm = objectFactory.newInstance(TeaVMWasmConfiguration.class); wasi = objectFactory.newInstance(TeaVMWasiConfiguration.class); diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMJSTestsImpl.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMJSTestsImpl.java new file mode 100644 index 000000000..26c984df8 --- /dev/null +++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMJSTestsImpl.java @@ -0,0 +1,55 @@ +/* + * Copyright 2023 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.gradle; + +import org.gradle.api.model.ObjectFactory; +import org.gradle.api.provider.Property; +import org.teavm.gradle.api.TeaVMJSTests; +import org.teavm.gradle.api.TeaVMWebTestRunner; + +class TeaVMJSTestsImpl implements TeaVMJSTests { + private Property enabled; + private Property runner; + private Property decodeStack; + + TeaVMJSTestsImpl(ObjectFactory objectFactory) { + enabled = objectFactory.property(Boolean.class); + runner = objectFactory.property(TeaVMWebTestRunner.class); + decodeStack = objectFactory.property(Boolean.class); + } + + @Override + public Property getEnabled() { + return enabled; + } + + @Override + public Property getRunner() { + return runner; + } + + @Override + public Property getDecodeStack() { + return decodeStack; + } + + void configure(TeaVMBaseExtensionImpl extension) { + enabled.convention(extension.property("tests.js.enabled").map(Boolean::parseBoolean).orElse(false)); + runner.convention(extension.property("tests.js.runner").map(s -> TeaVMWebTestRunner.valueOf(s.toUpperCase())) + .orElse(TeaVMWebTestRunner.CHROME)); + decodeStack.convention(extension.property("tests.js.decodeStack").map(Boolean::parseBoolean).orElse(true)); + } +} diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraryPlugin.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraryPlugin.java index 14f173992..4f40b9ab2 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraryPlugin.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraryPlugin.java @@ -20,6 +20,7 @@ import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.model.ObjectFactory; import org.gradle.api.plugins.JavaPlugin; +import org.teavm.gradle.api.TeaVMBaseExtension; import org.teavm.gradle.config.ArtifactCoordinates; public class TeaVMLibraryPlugin implements Plugin { @@ -32,9 +33,10 @@ public class TeaVMLibraryPlugin implements Plugin { @Override public void apply(Project project) { - var extension = objectFactory.newInstance(TeaVMBaseExtensionImpl.class); + var extension = new TeaVMBaseExtensionImpl(project, objectFactory); project.getExtensions().add(TeaVMBaseExtension.class, TeaVMPlugin.EXTENSION_NAME, extension); project.getDependencies().add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, ArtifactCoordinates.JUNIT); - project.getDependencies().add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, ArtifactCoordinates.CLASSLIB); + project.getDependencies().add(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, ArtifactCoordinates.CLASSLIB); + TeaVMTestConfigurator.configure(project, extension.getTests()); } } diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMPlugin.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMPlugin.java index e78a528b4..15d443fc9 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMPlugin.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMPlugin.java @@ -27,7 +27,14 @@ import org.gradle.api.plugins.WarPlugin; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; import org.gradle.api.tasks.bundling.War; +import org.teavm.gradle.api.TeaVMConfiguration; +import org.teavm.gradle.api.TeaVMExtension; import org.teavm.gradle.config.ArtifactCoordinates; +import org.teavm.gradle.tasks.GenerateCTask; +import org.teavm.gradle.tasks.GenerateJavaScriptTask; +import org.teavm.gradle.tasks.GenerateWasiTask; +import org.teavm.gradle.tasks.GenerateWasmTask; +import org.teavm.gradle.tasks.TeaVMTask; public class TeaVMPlugin implements Plugin { public static final String EXTENSION_NAME = "teavm"; @@ -53,10 +60,11 @@ public class TeaVMPlugin implements Plugin { registerTasks(project); addDependencies(project); setupWarTask(project); + TeaVMTestConfigurator.configure(project, project.getExtensions().getByType(TeaVMExtension.class).getTests()); } private void registerExtension(Project project) { - var extension = objectFactory.newInstance(TeaVMExtensionImpl.class); + var extension = new TeaVMExtensionImpl(project, objectFactory); project.getExtensions().add(TeaVMExtension.class, EXTENSION_NAME, extension); } @@ -83,6 +91,7 @@ public class TeaVMPlugin implements Plugin { sourceSet.setCompileClasspath(sourceSet.getCompileClasspath().plus(main) .plus(project.getConfigurations().getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME))); sourceSet.java(java -> { }); + project.getDependencies().add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, sourceSet.getOutput()); } private void registerTasks(Project project) { @@ -145,6 +154,7 @@ public class TeaVMPlugin implements Plugin { private void addDependencies(Project project) { project.getDependencies().add(CONFIGURATION_NAME, ArtifactCoordinates.CLASSLIB); project.getDependencies().add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, ArtifactCoordinates.JUNIT); + project.getDependencies().add(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, ArtifactCoordinates.CLASSLIB); } private void setupWarTask(Project project) { diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestConfigurator.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestConfigurator.java new file mode 100644 index 000000000..30eb82e0b --- /dev/null +++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestConfigurator.java @@ -0,0 +1,60 @@ +/* + * Copyright 2023 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.gradle; + +import java.io.File; +import org.gradle.api.Project; +import org.gradle.api.tasks.testing.Test; +import org.teavm.gradle.api.TeaVMTests; +import org.teavm.gradle.api.TeaVMWebTestRunner; + +class TeaVMTestConfigurator { + private TeaVMTestConfigurator() { + } + + static void configure(Project project, TeaVMTests tests) { + project.getTasks().withType(Test.class).configureEach(test -> { + test.getSystemProperties().putIfAbsent("teavm.junit.target", + new File(project.getBuildDir(), "tests/teavm")); + test.getSystemProperties().putIfAbsent("teavm.junit.threads", "1"); + + test.getSystemProperties().putIfAbsent("teavm.junit.js.enabled", + tests.getJs().getEnabled().get()); + test.getSystemProperties().putIfAbsent("teavm.junit.js.runner", + tests.getJs().getRunner().map(TeaVMTestConfigurator::runnerToString).get()); + test.getSystemProperties().putIfAbsent("teavm.junit.js.decodeStack", + tests.getJs().getDecodeStack().get()); + + test.getSystemProperties().putIfAbsent("teavm.junit.wasm.enabled", + tests.getWasm().getEnabled().get()); + test.getSystemProperties().putIfAbsent("teavm.junit.wasm.runner", + tests.getWasm().getRunner().map(TeaVMTestConfigurator::runnerToString).get()); + }); + } + + private static String runnerToString(TeaVMWebTestRunner runner) { + switch (runner) { + case CHROME: + return "browser-chrome"; + case FIREFOX: + return "browser-firefox"; + case CUSTOM_BROWSER: + return "browser"; + default: + return "none"; + } + } +} diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestsImpl.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestsImpl.java new file mode 100644 index 000000000..13a02f18b --- /dev/null +++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestsImpl.java @@ -0,0 +1,57 @@ +/* + * Copyright 2023 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.gradle; + +import org.gradle.api.Action; +import org.gradle.api.model.ObjectFactory; +import org.teavm.gradle.api.TeaVMJSTests; +import org.teavm.gradle.api.TeaVMTests; +import org.teavm.gradle.api.TeaVMWasmTests; + +class TeaVMTestsImpl implements TeaVMTests { + private TeaVMJSTestsImpl js; + private TeaVMWasmTestsImpl wasm; + + TeaVMTestsImpl(ObjectFactory objectFactory) { + js = new TeaVMJSTestsImpl(objectFactory); + wasm = new TeaVMWasmTestsImpl(objectFactory); + } + + @Override + public TeaVMJSTests getJs() { + return js; + } + + @Override + public void js(Action config) { + config.execute(js); + } + + @Override + public TeaVMWasmTests getWasm() { + return wasm; + } + + @Override + public void wasm(Action config) { + config.execute(wasm); + } + + void configure(TeaVMBaseExtensionImpl extension) { + js.configure(extension); + wasm.configure(extension); + } +} diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmTestsImpl.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmTestsImpl.java new file mode 100644 index 000000000..a8134bff3 --- /dev/null +++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmTestsImpl.java @@ -0,0 +1,47 @@ +/* + * Copyright 2023 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.gradle; + +import org.gradle.api.model.ObjectFactory; +import org.gradle.api.provider.Property; +import org.teavm.gradle.api.TeaVMWasmTests; +import org.teavm.gradle.api.TeaVMWebTestRunner; + +class TeaVMWasmTestsImpl implements TeaVMWasmTests { + private Property enabled; + private Property runner; + + TeaVMWasmTestsImpl(ObjectFactory objectFactory) { + enabled = objectFactory.property(Boolean.class); + runner = objectFactory.property(TeaVMWebTestRunner.class); + } + + @Override + public Property getEnabled() { + return enabled; + } + + @Override + public Property getRunner() { + return runner; + } + + void configure(TeaVMBaseExtensionImpl extension) { + enabled.convention(extension.property("tests.wasm.enabled").map(Boolean::parseBoolean).orElse(false)); + runner.convention(extension.property("tests.wasm.runner").map(s -> TeaVMWebTestRunner.valueOf(s.toUpperCase())) + .orElse(TeaVMWebTestRunner.CHROME)); + } +} diff --git a/tools/gradle/src/main/java/org/teavm/gradle/OptimizationLevel.java b/tools/gradle/src/main/java/org/teavm/gradle/api/OptimizationLevel.java similarity index 95% rename from tools/gradle/src/main/java/org/teavm/gradle/OptimizationLevel.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/OptimizationLevel.java index 480e11d9c..d92e732c0 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/OptimizationLevel.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/OptimizationLevel.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; public enum OptimizationLevel { NONE, diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtension.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMBaseExtension.java similarity index 85% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtension.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMBaseExtension.java index c1d54b21b..158250236 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtension.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMBaseExtension.java @@ -13,12 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; +import org.gradle.api.Action; import org.gradle.api.provider.Provider; public interface TeaVMBaseExtension { TeaVMLibraries getLibs(); Provider property(String name); + + TeaVMTests getTests(); + + void tests(Action config); } diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMCConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMCConfiguration.java similarity index 96% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMCConfiguration.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMCConfiguration.java index 2f7c13cdd..119a86e0d 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMCConfiguration.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMCConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; import org.gradle.api.provider.Property; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMCommonConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMCommonConfiguration.java similarity index 97% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMCommonConfiguration.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMCommonConfiguration.java index 787f374c4..9316f03d8 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMCommonConfiguration.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMCommonConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; import java.io.File; import org.gradle.api.provider.ListProperty; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMConfiguration.java similarity index 96% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMConfiguration.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMConfiguration.java index 2434c49a0..477f7a1c1 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMConfiguration.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; import org.gradle.api.provider.Property; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtension.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMExtension.java similarity index 97% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtension.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMExtension.java index 3a9aef486..ca6732c50 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtension.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMExtension.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; import org.gradle.api.Action; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMJSConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMJSConfiguration.java similarity index 96% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMJSConfiguration.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMJSConfiguration.java index 021fa0fdc..b33695eab 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMJSConfiguration.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMJSConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; import org.gradle.api.provider.Property; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMJSTests.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMJSTests.java new file mode 100644 index 000000000..20ffacccf --- /dev/null +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMJSTests.java @@ -0,0 +1,26 @@ +/* + * Copyright 2023 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.gradle.api; + +import org.gradle.api.provider.Property; + +public interface TeaVMJSTests { + Property getEnabled(); + + Property getRunner(); + + Property getDecodeStack(); +} diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraries.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMLibraries.java similarity index 96% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraries.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMLibraries.java index 2dc31139a..4a2ad5c90 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraries.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMLibraries.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; import org.gradle.api.artifacts.Dependency; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMNativeBaseConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMNativeBaseConfiguration.java similarity index 96% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMNativeBaseConfiguration.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMNativeBaseConfiguration.java index ce439b334..d915c013e 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMNativeBaseConfiguration.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMNativeBaseConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; import org.gradle.api.provider.Property; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMTests.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMTests.java new file mode 100644 index 000000000..48a042cb1 --- /dev/null +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMTests.java @@ -0,0 +1,28 @@ +/* + * Copyright 2023 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.gradle.api; + +import org.gradle.api.Action; + +public interface TeaVMTests { + TeaVMJSTests getJs(); + + void js(Action config); + + TeaVMWasmTests getWasm(); + + void wasm(Action config); +} diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasiConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasiConfiguration.java similarity index 95% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasiConfiguration.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasiConfiguration.java index a5d7203e4..f1e208359 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasiConfiguration.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasiConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; public interface TeaVMWasiConfiguration extends TeaVMWasmBaseConfiguration, TeaVMConfiguration { } diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmBaseConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmBaseConfiguration.java similarity index 96% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmBaseConfiguration.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmBaseConfiguration.java index 62cbac84d..f7bfdb559 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmBaseConfiguration.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmBaseConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; import org.gradle.api.provider.Property; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmConfiguration.java similarity index 95% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmConfiguration.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmConfiguration.java index d53af9cca..fd1a9392b 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmConfiguration.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; public interface TeaVMWasmConfiguration extends TeaVMWebConfiguration, TeaVMWasmBaseConfiguration { } diff --git a/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmTests.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmTests.java new file mode 100644 index 000000000..6be07b69c --- /dev/null +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmTests.java @@ -0,0 +1,24 @@ +/* + * Copyright 2023 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.gradle.api; + +import org.gradle.api.provider.Property; + +public interface TeaVMWasmTests { + Property getEnabled(); + + Property getRunner(); +} diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWebConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWebConfiguration.java similarity index 96% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMWebConfiguration.java rename to tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWebConfiguration.java index 436a2af2b..da9ca073a 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWebConfiguration.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWebConfiguration.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.api; import org.gradle.api.provider.Property; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWebTestRunner.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWebTestRunner.java new file mode 100644 index 000000000..70414874d --- /dev/null +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWebTestRunner.java @@ -0,0 +1,23 @@ +/* + * Copyright 2023 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.gradle.api; + +public enum TeaVMWebTestRunner { + CUSTOM_BROWSER, + CHROME, + FIREFOX, + NONE +} diff --git a/tools/gradle/src/main/java/org/teavm/gradle/GenerateCTask.java b/tools/gradle/src/main/java/org/teavm/gradle/tasks/GenerateCTask.java similarity index 98% rename from tools/gradle/src/main/java/org/teavm/gradle/GenerateCTask.java rename to tools/gradle/src/main/java/org/teavm/gradle/tasks/GenerateCTask.java index cde3fc95f..2eab7fb38 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/GenerateCTask.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/tasks/GenerateCTask.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.tasks; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/GenerateJavaScriptTask.java b/tools/gradle/src/main/java/org/teavm/gradle/tasks/GenerateJavaScriptTask.java similarity index 98% rename from tools/gradle/src/main/java/org/teavm/gradle/GenerateJavaScriptTask.java rename to tools/gradle/src/main/java/org/teavm/gradle/tasks/GenerateJavaScriptTask.java index 1131193e1..2b0d005d8 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/GenerateJavaScriptTask.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/tasks/GenerateJavaScriptTask.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.tasks; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/GenerateWasiTask.java b/tools/gradle/src/main/java/org/teavm/gradle/tasks/GenerateWasiTask.java similarity index 97% rename from tools/gradle/src/main/java/org/teavm/gradle/GenerateWasiTask.java rename to tools/gradle/src/main/java/org/teavm/gradle/tasks/GenerateWasiTask.java index b18934b84..c877d844a 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/GenerateWasiTask.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/tasks/GenerateWasiTask.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.tasks; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/GenerateWasmTask.java b/tools/gradle/src/main/java/org/teavm/gradle/tasks/GenerateWasmTask.java similarity index 97% rename from tools/gradle/src/main/java/org/teavm/gradle/GenerateWasmTask.java rename to tools/gradle/src/main/java/org/teavm/gradle/tasks/GenerateWasmTask.java index cdf38d187..e783bd314 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/GenerateWasmTask.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/tasks/GenerateWasmTask.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.tasks; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Input; diff --git a/tools/gradle/src/main/java/org/teavm/gradle/GradleTeaVMToolLog.java b/tools/gradle/src/main/java/org/teavm/gradle/tasks/GradleTeaVMToolLog.java similarity index 89% rename from tools/gradle/src/main/java/org/teavm/gradle/GradleTeaVMToolLog.java rename to tools/gradle/src/main/java/org/teavm/gradle/tasks/GradleTeaVMToolLog.java index 7611c9e66..2a7c4aa1d 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/GradleTeaVMToolLog.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/tasks/GradleTeaVMToolLog.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Alexey Andreev. + * Copyright 2023 Alexey Andreev. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,15 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.tasks; import org.gradle.api.logging.Logger; import org.teavm.tooling.TeaVMToolLog; -public class GradleTeaVMToolLog implements TeaVMToolLog { +class GradleTeaVMToolLog implements TeaVMToolLog { private Logger log; - public GradleTeaVMToolLog(Logger log) { + GradleTeaVMToolLog(Logger log) { this.log = log; } diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTask.java b/tools/gradle/src/main/java/org/teavm/gradle/tasks/TeaVMTask.java similarity index 98% rename from tools/gradle/src/main/java/org/teavm/gradle/TeaVMTask.java rename to tools/gradle/src/main/java/org/teavm/gradle/tasks/TeaVMTask.java index e30ff6904..dd1e55fea 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTask.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/tasks/TeaVMTask.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.teavm.gradle; +package org.teavm.gradle.tasks; import java.io.File; import java.io.IOException; @@ -33,6 +33,7 @@ import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Optional; import org.gradle.api.tasks.OutputDirectory; import org.gradle.api.tasks.TaskAction; +import org.teavm.gradle.api.OptimizationLevel; import org.teavm.tooling.TeaVMProblemRenderer; import org.teavm.tooling.builder.BuildException; import org.teavm.tooling.builder.BuildStrategy;