+
+ true
+ true
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/build_samples.xml b/.idea/runConfigurations/build_samples.xml
new file mode 100644
index 000000000..87019259f
--- /dev/null
+++ b/.idea/runConfigurations/build_samples.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/publish_locally.xml b/.idea/runConfigurations/publish_locally.xml
new file mode 100644
index 000000000..2a56cf45a
--- /dev/null
+++ b/.idea/runConfigurations/publish_locally.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/run_tests__wasi_.xml b/.idea/runConfigurations/run_tests__wasi_.xml
index e543ff1eb..2ecce298d 100644
--- a/.idea/runConfigurations/run_tests__wasi_.xml
+++ b/.idea/runConfigurations/run_tests__wasi_.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/README.md b/README.md
index 41e8a762f..b2a779356 100644
--- a/README.md
+++ b/README.md
@@ -21,13 +21,16 @@ Useful links:
Building TeaVM
--------------
-Simply clone source code (`git clone https://github.com/konsoletyper/teavm.git`) and run maven build (`mvn clean install`). You can do things a little faster (`mvn clean -DskipTests`) or even a little more faster (`mvn clean -DskipTests -Dteavm.build.all=false`).
+Simply clone source code (`git clone https://github.com/konsoletyper/teavm.git`)
+and run Gradle build (`gradle publishToMavenLocal`).
Preview builds
--------------
-You may want to access new features and don't want to wait until stable release is published on Maven Central. In this case you can get latest development build from [bintray](https://bintray.com/konsoletyper/teavm/teavm-dev). All you need is to put the following in your `pom.xml`:
+You may want to access new features and don't want to wait until stable release is published on Maven Central.
+In this case you can get latest development build from [bintray](https://bintray.com/konsoletyper/teavm/teavm-dev).
+All you need is to put the following in your `pom.xml`:
```xml
@@ -44,13 +47,21 @@ You may want to access new features and don't want to wait until stable release
```
-IDEA plugin is also available in preview builds. You need to add corresponding repository manually to IDEA. Open *Settings* -> *Plugins* -> *Browse repositories...* -> *Manage repositories...*, click *Add* button and enter `https://teavm.org/idea/dev/teavmRepository.xml`. Then get back to *Browse repositories* and pick TeaVM plugin from list.
+IDEA plugin is also available in preview builds. You need to add corresponding repository manually to IDEA.
+Open *Settings* -> *Plugins* -> *Browse repositories...* -> *Manage repositories...*, click *Add* button
+and enter `https://teavm.org/idea/dev/teavmRepository.xml`.
+Then get back to *Browse repositories* and pick TeaVM plugin from list.
Embedding TeaVM
---------------
-If you are not satisfied with Maven, you can embed TeaVM in your program or even create your own plugin for any build tool, like Ant or Gradle. The starting point for you may be `org.teavm.tooling.TeaVMTool` class from `teavm-tooling` artifact. You may want to go deeper and use `org.teavm.vm.TeaVM` from `teavm-core` artifact, learn how `TeaVMTool` initializes it. To learn how to use `TeaVMTool` class itself, find its usages across project source code. You most likely encounter Maven and IDEA plugins.
+If you are not satisfied with Maven, you can embed TeaVM in your program
+or even create your own plugin for any build tool, like Ant or Gradle.
+The starting point for you may be `org.teavm.tooling.TeaVMTool` class from `teavm-tooling` artifact.
+You may want to go deeper and use `org.teavm.vm.TeaVM` from `teavm-core` artifact, learn how `TeaVMTool` initializes it.
+To learn how to use `TeaVMTool` class itself, find its usages across project source code.
+You most likely encounter Maven and IDEA plugins.
Please, notice that these APIs for embedding are still unstable and may change between versions.
@@ -58,7 +69,13 @@ Please, notice that these APIs for embedding are still unstable and may change b
WebAssembly
-----------
-WebAssembly support is in experimental status. It may lack major features available in JavaScript backend. There's no documentation yet and you should do many things by hands (like embedding generated `wasm` file into your page, importing JavaScript objects, etc). Look at [samples/benchmark](https://github.com/konsoletyper/teavm/blob/master/samples/benchmark/) module. You should first examine `pom.xml` file to learn how to build `wasm` file from Java. Then you may want to examine `index-teavm.html` and `index-teavm.js` to learn how to embed WebAssembly into your web page.
+WebAssembly support is in experimental status. It may lack major features available in JavaScript backend.
+There's no documentation yet and you should do many things by hands
+(like embedding generated `wasm` file into your page, importing JavaScript objects, etc).
+Look at [samples/benchmark](https://github.com/konsoletyper/teavm/blob/master/samples/benchmark/) module.
+You should first examine `pom.xml` file to learn how to build `wasm` file from Java.
+Then you may want to examine `index-teavm.html` and `index-teavm.js`
+to learn how to embed WebAssembly into your web page.
License
@@ -66,13 +83,15 @@ License
TeaVM is distributed under [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
TeaVM does not rely on OpenJDK or code or other (L)GPL code.
-TeaVM has its own reimplementation of Java class library, which is either implemented from scratch or based on non-(L)GPL projects:
+TeaVM has its own reimplementation of Java class library, which is either implemented from scratch or
+based on non-(L)GPL projects:
* [Apache Harmony](https://harmony.apache.org/) (Apache 2.0)
* [Joda-Time](https://github.com/JodaOrg/joda-time) (Apache 2.0)
* [jzlib](https://github.com/ymnk/jzlib) (BSD style license)
-If you want to contribute code to implementation of Java class library, please make sure it's no based on OpenJDK or other code licensed under (L)GPL.
+If you want to contribute code to implementation of Java class library,
+please make sure it's no based on OpenJDK or other code licensed under (L)GPL.
Feedback
@@ -80,4 +99,5 @@ Feedback
More information is available at the official site: https://teavm.org.
-Ask your questions by email: info@teavm.org. Also you can report issues on a project's [issue tracker](https://github.com/konsoletyper/teavm/issues).
+Ask your questions by email: info@teavm.org. Also you can report issues on a project's
+[issue tracker](https://github.com/konsoletyper/teavm/issues).
diff --git a/all-deps/all-deps.iml b/all-deps/all-deps.iml
deleted file mode 100644
index f1e3f209a..000000000
--- a/all-deps/all-deps.iml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts
new file mode 100644
index 000000000..64efcfdeb
--- /dev/null
+++ b/build-logic/build.gradle.kts
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-gradle-plugin`
+ checkstyle
+}
+
+repositories {
+ mavenLocal()
+ mavenCentral()
+ gradlePluginPortal()
+}
+
+dependencies {
+ implementation(libs.shadowPlugin)
+ implementation(libs.maven.plugin.tools.api)
+ implementation(libs.maven.plugin.tools.generators)
+ implementation(libs.maven.plugin.tools.annotations)
+ implementation(libs.maven.embedder)
+ implementation(libs.maven.compat)
+}
+
+gradlePlugin {
+ plugins {
+ create("teavm-publish") {
+ id = "teavm-publish"
+ implementationClass = "org.teavm.buildutil.PublishTeaVMPlugin"
+ }
+ create("dependency-relocation") {
+ id = "dependency-relocation"
+ implementationClass = "org.teavm.buildutil.DependencyRelocationPlugin"
+ }
+ create("shadowApply") {
+ id = "shadowApply"
+ implementationClass = "org.teavm.buildutil.ShadowApplyPlugin"
+ }
+ create("mavenPlugin") {
+ id = "mavenPlugin"
+ implementationClass = "org.teavm.buildutil.MavenPluginPlugin"
+ }
+ }
+}
+
+checkstyle {
+ toolVersion = libs.versions.checkstyle.get()
+ configDirectory.set(project.layout.projectDirectory.dir("../config/checkstyle"))
+}
+
+java {
+ toolchain {
+ languageVersion.set(JavaLanguageVersion.of(11))
+ }
+}
+
+val generatedConfigDir = project.layout.buildDirectory.dir("generated/config").get()
+
+val generateConfig by tasks.registering {
+ val file = generatedConfigDir.file("org/teavm/buildutil/Config.java").asFile
+ outputs.file(file)
+ doLast {
+ file.parentFile.mkdirs()
+ file.writeText("""
+ package org.teavm.buildutil;
+
+ class Config {
+ static final String MAVEN_PLUGIN_API = "${libs.maven.plugin.api.get()}";
+ static final String MAVEN_PLUGIN_ANNOTATIONS = "${libs.maven.plugin.annotations.get()}";
+ static final String MAVEN_ARTIFACT = "${libs.maven.artifact.get()}";
+ static final String MAVEN_CORE = "${libs.maven.core.get()}";
+ }
+ """.trimIndent())
+ }
+}
+tasks.compileJava.configure { dependsOn(generateConfig) }
+
+sourceSets.main.configure { java.srcDir(generatedConfigDir) }
\ No newline at end of file
diff --git a/samples/benchmark/src/main/java/org/teavm/samples/benchmark/htmljava/BenchmarkFX.java b/build-logic/settings.gradle.kts
similarity index 57%
rename from samples/benchmark/src/main/java/org/teavm/samples/benchmark/htmljava/BenchmarkFX.java
rename to build-logic/settings.gradle.kts
index 780cefcd2..7070c9da2 100644
--- a/samples/benchmark/src/main/java/org/teavm/samples/benchmark/htmljava/BenchmarkFX.java
+++ b/build-logic/settings.gradle.kts
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Jaroslav Tulach.
+ * 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,20 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.teavm.samples.benchmark.htmljava;
-import net.java.html.boot.BrowserBuilder;
-
-public final class BenchmarkFX {
- private BenchmarkFX() {
+dependencyResolutionManagement {
+ versionCatalogs {
+ create("libs") {
+ from(files("../gradle/libs.versions.toml"))
+ }
}
-
- public static void main(String... args) {
- BrowserBuilder.newBrowser().loadPage("fx.html")
- .loadClass(BenchmarkStarter.class)
- .invoke("main")
- .showAndWait();
- System.exit(0);
- }
-
}
+
diff --git a/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationExtension.java b/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationExtension.java
new file mode 100644
index 000000000..fa4d8337c
--- /dev/null
+++ b/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationExtension.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.buildutil;
+
+import org.gradle.api.Action;
+
+public interface DependencyRelocationExtension {
+ void library(String libs, String alias, Action action);
+
+ String getArtifactIdPrefix();
+
+ void setArtifactIdPrefix(String prefix);
+
+ void skip(String project);
+}
diff --git a/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationExtensionImpl.java b/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationExtensionImpl.java
new file mode 100644
index 000000000..0c431892d
--- /dev/null
+++ b/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationExtensionImpl.java
@@ -0,0 +1,274 @@
+/*
+ * 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.buildutil;
+
+import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.gradle.api.Action;
+import org.gradle.api.Project;
+import org.gradle.api.Task;
+import org.gradle.api.artifacts.Dependency;
+import org.gradle.api.artifacts.ModuleIdentifier;
+import org.gradle.api.artifacts.VersionCatalogsExtension;
+import org.gradle.api.artifacts.component.ModuleComponentSelector;
+import org.gradle.api.artifacts.component.ProjectComponentSelector;
+import org.gradle.api.artifacts.result.ResolvedDependencyResult;
+import org.gradle.api.attributes.Usage;
+import org.gradle.api.initialization.Settings;
+import org.gradle.api.plugins.JavaLibraryPlugin;
+import org.gradle.api.plugins.JavaPlugin;
+import org.gradle.api.plugins.JavaPluginExtension;
+import org.gradle.api.plugins.catalog.VersionCatalogPlugin;
+import org.gradle.api.tasks.SourceSet;
+import org.gradle.api.tasks.bundling.AbstractArchiveTask;
+import org.gradle.jvm.tasks.Jar;
+
+class DependencyRelocationExtensionImpl implements DependencyRelocationExtension {
+ private static final String RELOCATE_JAR = "relocateJar";
+ private Settings target;
+ private Map depsByProjectPath = new LinkedHashMap<>();
+ private String artifactIdPrefix;
+ private Set skippedProjects = new HashSet<>();
+
+ DependencyRelocationExtensionImpl(Settings target) {
+ this.target = target;
+ target.getGradle().afterProject(project -> {
+ var dependency = depsByProjectPath.get(project.getPath());
+ if (dependency != null) {
+ setupSynthesizedProject(project, dependency);
+ } else {
+ setupConsumingProject(project);
+ }
+ });
+ }
+
+ private void setupSynthesizedProject(Project project, RelocatedDependency dependency) {
+ project.getPlugins().apply(VersionCatalogPlugin.class);
+ project.getPlugins().apply(JavaLibraryPlugin.class);
+ project.getPlugins().apply(PublishTeaVMPlugin.class);
+
+ var synthesizedProjects = new HashMap();
+ for (var dep : depsByProjectPath.values()) {
+ var lib = project.getExtensions().getByType(VersionCatalogsExtension.class).named(dep.libs)
+ .findLibrary(dep.alias).get().get();
+ synthesizedProjects.put(lib.getModule(), dep.projectPath);
+ }
+
+ var library = project.getExtensions().getByType(VersionCatalogsExtension.class).named(dependency.libs)
+ .findLibrary(dependency.alias).get().get();
+ var libraryDep = project.getDependencies().create(library);
+
+ project.getDependencies().add(JavaPlugin.COMPILE_ONLY_API_CONFIGURATION_NAME, library);
+
+ copyLibraryDeps(project, libraryDep, Usage.JAVA_RUNTIME, JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME,
+ synthesizedProjects);
+
+ project.setGroup(project.getRootProject().getGroup());
+ var prefix = artifactIdPrefix != null ? artifactIdPrefix : project.getRootProject().getName() + "-relocated";
+ var fullArtifactId = prefix + "-" + dependency.libs + "-" + dependency.alias;
+ project.getExtensions().configure(PublishTeaVMExtension.class, extension -> {
+ extension.setArtifactId(fullArtifactId);
+ });
+
+ var config = project.getConfigurations().detachedConfiguration(project.getDependencies().create(library));
+ config.setTransitive(false);
+ setupRelocation(project, config, dependency.relocations);
+ }
+
+ private void replaceArtifacts(Project project, String configurationName, Task task) {
+ var configuration = project.getConfigurations().getByName(configurationName);
+ configuration.getArtifacts().clear();
+ project.getArtifacts().add(configurationName, task);
+ }
+
+ private void copyLibraryDeps(Project project, Dependency dependency, String usage, String targetConfig,
+ Map synthesizedProjects) {
+ var detachedConfig = project.getConfigurations().detachedConfiguration(
+ project.getDependencies().create(dependency));
+ detachedConfig.setTransitive(true);
+ detachedConfig.getAttributes().attribute(Usage.USAGE_ATTRIBUTE,
+ project.getObjects().named(Usage.class, usage));
+ var root = detachedConfig.getIncoming().getResolutionResult().getRoot().getDependencies().iterator().next();
+ if (root instanceof ResolvedDependencyResult) {
+ var rootComponent = ((ResolvedDependencyResult) root).getSelected();
+ for (var dep : rootComponent.getDependencies()) {
+ var requested = dep.getRequested();
+ if (requested instanceof ModuleComponentSelector) {
+ var moduleDep = (ModuleComponentSelector) requested;
+ var replacement = synthesizedProjects.get(moduleDep.getModuleIdentifier());
+ if (replacement != null) {
+ var notation = new HashMap();
+ notation.put("path", replacement);
+ project.getDependencies().add(targetConfig,
+ project.getDependencies().project(notation));
+ } else {
+ project.getDependencies().add(targetConfig,
+ moduleDep.getGroup() + ":" + moduleDep.getModule() + ":" + moduleDep.getVersion());
+ }
+ } else if (requested instanceof ProjectComponentSelector) {
+ var projectDep = (ProjectComponentSelector) requested;
+ var notation = new HashMap();
+ notation.put("path", projectDep.getProjectPath());
+ project.getDependencies().add(targetConfig, project.getDependencies().project(notation));
+ }
+ }
+ }
+ }
+
+ private void setupConsumingProject(Project project) {
+ if (skippedProjects.contains(project.getPath())
+ || project.getExtensions().findByType(JavaPluginExtension.class) == null) {
+ return;
+ }
+
+ var relocations = new ArrayList();
+ var depsByLibrary = new LinkedHashMap();
+ for (var dependency : depsByProjectPath.values()) {
+ var library = project.getExtensions().getByType(VersionCatalogsExtension.class).named(dependency.libs)
+ .findLibrary(dependency.alias).get().get();
+ if (library != null) {
+ depsByLibrary.put(project.getDependencies().create(library), dependency);
+ }
+ relocations.addAll(dependency.relocations);
+ }
+
+ replaceDependencies(
+ project,
+ JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME,
+ Arrays.asList(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME,
+ JavaPlugin.RUNTIME_ELEMENTS_CONFIGURATION_NAME),
+ Arrays.asList(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME,
+ JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME,
+ JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME),
+ depsByLibrary
+ );
+
+ var sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
+ var main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
+ var sourceDirs = main.getOutput();
+ setupRelocation(project, sourceDirs, relocations);
+ }
+
+ private void replaceDependencies(Project project, String configurationName,
+ List runtimeConfigurations, List compileConfigurations,
+ Map depsByLibrary) {
+ var config = project.getConfigurations().findByName(configurationName);
+ if (config == null) {
+ return;
+ }
+ for (var iterator = config.getDependencies().iterator(); iterator.hasNext(); ) {
+ var dependency = iterator.next();
+ var relocatedDep = depsByLibrary.get(dependency);
+ if (relocatedDep != null) {
+ var projectNotation = new HashMap();
+ projectNotation.put("path", relocatedDep.projectPath);
+ for (var runtimeConfiguration : runtimeConfigurations) {
+ if (project.getConfigurations().findByName(runtimeConfiguration) != null) {
+ project.getDependencies().add(runtimeConfiguration,
+ project.getDependencies().project(projectNotation));
+ }
+ }
+ for (var compileConfiguration : compileConfigurations) {
+ project.getDependencies().add(compileConfiguration, dependency);
+ }
+ iterator.remove();
+ }
+ }
+ }
+
+ private void setupRelocation(Project project, Object input, List relocations) {
+ if (project.getTasks().findByPath(JavaPlugin.JAR_TASK_NAME) == null) {
+ return;
+ }
+ project.getTasks().named(JavaPlugin.JAR_TASK_NAME, Jar.class, jar -> {
+ jar.getArchiveClassifier().set("original");
+ });
+ var relocateTask = project.getTasks().create(RELOCATE_JAR, ShadowJar.class, task -> {
+ task.getArchiveClassifier().set("");
+ task.from(input);
+ for (var relocation : relocations) {
+ task.relocate(relocation.src, relocation.dest);
+ }
+ project.getTasks().getByName("assemble").dependsOn(task);
+ });
+ project.getTasks().withType(AbstractArchiveTask.class, archive -> {
+ archive.setPreserveFileTimestamps(false);
+ archive.setReproducibleFileOrder(true);
+ });
+
+ replaceArtifacts(project, JavaPlugin.RUNTIME_ELEMENTS_CONFIGURATION_NAME, relocateTask);
+ replaceArtifacts(project, JavaPlugin.API_ELEMENTS_CONFIGURATION_NAME, relocateTask);
+ }
+
+ @Override
+ public void library(String libs, String alias, Action action) {
+ var projectName = "relocated:" + libs + ":" + alias;
+ var projectPath = ":" + projectName;
+ target.include(projectName);
+ target.project(projectPath).setProjectDir(new File(target.getRootDir(), "relocated/" + libs + "/" + alias));
+ var dependency = new RelocatedDependency(projectPath, libs, alias);
+ depsByProjectPath.put(projectPath, dependency);
+ action.execute((src, dest) -> {
+ dependency.relocations.add(new Relocation(src, dest));
+ });
+ }
+
+ @Override
+ public String getArtifactIdPrefix() {
+ return artifactIdPrefix;
+ }
+
+ @Override
+ public void setArtifactIdPrefix(String prefix) {
+ artifactIdPrefix = prefix;
+ }
+
+ @Override
+ public void skip(String project) {
+ skippedProjects.add(project);
+ }
+
+ static class RelocatedDependency {
+ String projectPath;
+ String libs;
+ String alias;
+ List relocations = new ArrayList<>();
+
+ RelocatedDependency(String projectPath, String libs, String alias) {
+ this.projectPath = projectPath;
+ this.libs = libs;
+ this.alias = alias;
+ }
+ }
+
+ static class Relocation {
+ String src;
+ String dest;
+
+ Relocation(String src, String dest) {
+ this.src = src;
+ this.dest = dest;
+ }
+ }
+}
diff --git a/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationLibrary.java b/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationLibrary.java
new file mode 100644
index 000000000..37fd3fc64
--- /dev/null
+++ b/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationLibrary.java
@@ -0,0 +1,20 @@
+/*
+ * 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.buildutil;
+
+public interface DependencyRelocationLibrary {
+ void relocate(String from, String to);
+}
diff --git a/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationPlugin.java b/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationPlugin.java
new file mode 100644
index 000000000..e542f6a44
--- /dev/null
+++ b/build-logic/src/main/java/org/teavm/buildutil/DependencyRelocationPlugin.java
@@ -0,0 +1,27 @@
+/*
+ * 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.buildutil;
+
+import org.gradle.api.Plugin;
+import org.gradle.api.initialization.Settings;
+
+public class DependencyRelocationPlugin implements Plugin {
+ @Override
+ public void apply(Settings target) {
+ var extensions = new DependencyRelocationExtensionImpl(target);
+ target.getExtensions().add("dependencyRelocation", extensions);
+ }
+}
diff --git a/build-logic/src/main/java/org/teavm/buildutil/MavenArtifact.java b/build-logic/src/main/java/org/teavm/buildutil/MavenArtifact.java
new file mode 100644
index 000000000..95b8021e5
--- /dev/null
+++ b/build-logic/src/main/java/org/teavm/buildutil/MavenArtifact.java
@@ -0,0 +1,30 @@
+/*
+ * 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.buildutil;
+
+import java.io.Serializable;
+
+public class MavenArtifact implements Serializable {
+ public final String groupId;
+ public final String artifactId;
+ public final String version;
+
+ public MavenArtifact(String groupId, String artifactId, String version) {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.version = version;
+ }
+}
diff --git a/build-logic/src/main/java/org/teavm/buildutil/MavenPluginDescriptorTask.java b/build-logic/src/main/java/org/teavm/buildutil/MavenPluginDescriptorTask.java
new file mode 100644
index 000000000..08ea4e0da
--- /dev/null
+++ b/build-logic/src/main/java/org/teavm/buildutil/MavenPluginDescriptorTask.java
@@ -0,0 +1,115 @@
+/*
+ * 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.buildutil;
+
+import java.io.File;
+import javax.inject.Inject;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.apache.maven.plugin.descriptor.InvalidPluginDescriptorException;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.tools.plugin.DefaultPluginToolsRequest;
+import org.apache.maven.tools.plugin.extractor.ExtractionException;
+import org.apache.maven.tools.plugin.generator.GeneratorException;
+import org.apache.maven.tools.plugin.generator.PluginDescriptorFilesGenerator;
+import org.apache.maven.tools.plugin.scanner.MojoScanner;
+import org.codehaus.plexus.DefaultContainerConfiguration;
+import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainerException;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.gradle.api.DefaultTask;
+import org.gradle.api.provider.Property;
+import org.gradle.api.tasks.Input;
+import org.gradle.api.tasks.InputDirectory;
+import org.gradle.api.tasks.Optional;
+import org.gradle.api.tasks.OutputDirectory;
+import org.gradle.api.tasks.TaskAction;
+
+public abstract class MavenPluginDescriptorTask extends DefaultTask {
+ @Input
+ public abstract Property getGroupId();
+
+ @Input
+ public abstract Property getArtifactId();
+
+ @Input
+ public abstract Property getVersion();
+
+ @Input
+ public abstract Property getPluginName();
+
+ @Input
+ @Optional
+ public abstract Property getPluginDescription();
+
+ @InputDirectory
+ public abstract Property getClassesDirectory();
+
+ @OutputDirectory
+ public abstract Property getOutputDirectory();
+
+ @Inject
+ public MavenPluginDescriptorTask() {
+ var project = getProject();
+ getPluginName().convention(project.provider(project::getName));
+ getPluginDescription().convention(project.provider(() -> project.getDescription() != null
+ ? project.getDescription() : ""));
+ getVersion().convention(project.provider(() -> project.getVersion().toString()));
+ getGroupId().convention(project.provider(() -> project.getGroup().toString()));
+ getArtifactId().convention(project.provider(project::getName));
+ }
+
+ @TaskAction
+ public void generate() throws ExtractionException, InvalidPluginDescriptorException, GeneratorException,
+ PlexusContainerException, ComponentLookupException {
+ var cc = new DefaultContainerConfiguration()
+ .setClassPathScanning(PlexusConstants.SCANNING_INDEX)
+ .setAutoWiring(true)
+ .setJSR250Lifecycle(true)
+ .setName("maven");
+ var container = new DefaultPlexusContainer(cc);
+ var scanner = container.lookup(MojoScanner.class);
+ var descriptor = new PluginDescriptor();
+ descriptor.setGroupId(getGroupId().get());
+ descriptor.setArtifactId(getArtifactId().get());
+ descriptor.setVersion(getVersion().get());
+ descriptor.setName(getPluginName().get());
+ descriptor.setDescription(getPluginDescription().get());
+
+ var project = new MavenProject();
+ project.getBuild().setOutputDirectory(getClassesDirectory().get().getAbsolutePath());
+ project.getBuild().setDirectory(getOutputDirectory().get().getAbsolutePath());
+ project.setGroupId(getGroupId().get());
+ project.setArtifactId(getArtifactId().get());
+ project.setVersion(getVersion().get());
+ project.setArtifact(new DefaultArtifact(getGroupId().get(), getArtifactId().get(),
+ getVersion().get(), "compile", "jar", "", new DefaultArtifactHandler()));
+
+ var request = new DefaultPluginToolsRequest(project, descriptor);
+ request.setEncoding("UTF-8");
+ request.setSkipErrorNoDescriptorsFound(false);
+
+ scanner.populatePluginDescriptor(request);
+
+ var out = getOutputDirectory().get();
+ out.getParentFile().mkdirs();
+
+ var pluginDescriptorGenerator = new PluginDescriptorFilesGenerator();
+ pluginDescriptorGenerator.execute(out, request);
+ }
+}
diff --git a/build-logic/src/main/java/org/teavm/buildutil/MavenPluginPlugin.java b/build-logic/src/main/java/org/teavm/buildutil/MavenPluginPlugin.java
new file mode 100644
index 000000000..f51bc06d5
--- /dev/null
+++ b/build-logic/src/main/java/org/teavm/buildutil/MavenPluginPlugin.java
@@ -0,0 +1,73 @@
+/*
+ * 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.buildutil;
+
+import java.io.File;
+import org.gradle.api.Plugin;
+import org.gradle.api.Project;
+import org.gradle.api.plugins.JavaLibraryPlugin;
+import org.gradle.api.plugins.JavaPlugin;
+import org.gradle.api.publish.PublishingExtension;
+import org.gradle.api.publish.maven.MavenPublication;
+import org.gradle.api.tasks.SourceSetContainer;
+
+public class MavenPluginPlugin implements Plugin {
+ private static final String GENERATED_DIR = "generated/resources/maven-plugin";
+ private static final String PLUGIN_DIR = "META-INF/maven";
+
+ @Override
+ public void apply(Project project) {
+ project.getPlugins().apply(JavaLibraryPlugin.class);
+
+ installDependencies(project);
+
+ var generatedDir = new File(project.getBuildDir(), GENERATED_DIR);
+ var pluginDir = new File(generatedDir, PLUGIN_DIR);
+
+ var task = project.getTasks().create("generateMavenPluginDescriptor", MavenPluginDescriptorTask.class);
+ task.getOutputDirectory().convention(pluginDir);
+ var thisArtifact = project.provider(() -> getProjectArtifact(project));
+ task.getGroupId().convention(thisArtifact.map(a -> a.groupId));
+ task.getArtifactId().convention(thisArtifact.map(a -> a.artifactId));
+ task.getVersion().convention(thisArtifact.map(a -> a.version));
+
+ var sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
+ var main = sourceSets.getByName("main");
+ task.getClassesDirectory().convention(main.getOutput().getClassesDirs().getSingleFile());
+ task.dependsOn(project.getTasks().getByName(JavaPlugin.CLASSES_TASK_NAME));
+ main.getOutput().dir(generatedDir);
+ }
+
+ private void installDependencies(Project project) {
+ var config = JavaPlugin.COMPILE_ONLY_API_CONFIGURATION_NAME;
+ project.getDependencies().add(config, Config.MAVEN_PLUGIN_API);
+ project.getDependencies().add(config, Config.MAVEN_PLUGIN_ANNOTATIONS);
+ project.getDependencies().add(config, Config.MAVEN_ARTIFACT);
+ project.getDependencies().add(config, Config.MAVEN_CORE);
+ }
+
+ private MavenArtifact getProjectArtifact(Project project) {
+ var ext = project.getExtensions().getByType(PublishingExtension.class);
+ for (var publication : ext.getPublications()) {
+ if (publication instanceof MavenPublication) {
+ var mavenPublication = (MavenPublication) publication;
+ return new MavenArtifact(mavenPublication.getGroupId(), mavenPublication.getArtifactId(),
+ mavenPublication.getVersion());
+ }
+ }
+ return new MavenArtifact(project.getGroup().toString(), project.getName(), project.getVersion().toString());
+ }
+}
diff --git a/build-logic/src/main/java/org/teavm/buildutil/PublishTeaVMExtension.java b/build-logic/src/main/java/org/teavm/buildutil/PublishTeaVMExtension.java
new file mode 100644
index 000000000..5f98465e8
--- /dev/null
+++ b/build-logic/src/main/java/org/teavm/buildutil/PublishTeaVMExtension.java
@@ -0,0 +1,22 @@
+/*
+ * 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.buildutil;
+
+public interface PublishTeaVMExtension {
+ String getArtifactId();
+
+ void setArtifactId(String artifactId);
+}
diff --git a/build-logic/src/main/java/org/teavm/buildutil/PublishTeaVMPlugin.java b/build-logic/src/main/java/org/teavm/buildutil/PublishTeaVMPlugin.java
new file mode 100644
index 000000000..44ca4d296
--- /dev/null
+++ b/build-logic/src/main/java/org/teavm/buildutil/PublishTeaVMPlugin.java
@@ -0,0 +1,93 @@
+/*
+ * 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.buildutil;
+
+import org.gradle.api.Plugin;
+import org.gradle.api.Project;
+import org.gradle.api.plugins.JavaPluginExtension;
+import org.gradle.api.publish.PublishingExtension;
+import org.gradle.api.publish.maven.MavenPublication;
+import org.gradle.api.publish.maven.plugins.MavenPublishPlugin;
+import org.gradle.api.publish.plugins.PublishingPlugin;
+import org.gradle.api.tasks.javadoc.Javadoc;
+import org.gradle.external.javadoc.CoreJavadocOptions;
+
+public abstract class PublishTeaVMPlugin implements Plugin {
+ private static final String EXTENSION_NAME = "teavmPublish";
+
+ @Override
+ public void apply(Project target) {
+ target.getPlugins().apply(PublishingPlugin.class);
+ target.getPlugins().apply(MavenPublishPlugin.class);
+
+ var extension = new ExtensionImpl();
+ target.getExtensions().add(PublishTeaVMExtension.class, EXTENSION_NAME, extension);
+
+ target.afterEvaluate(p -> target.getExtensions().configure(PublishingExtension.class, publishing -> {
+ publishing.publications(publications -> {
+ publications.create("java", MavenPublication.class, publication -> {
+ customizePublication(target, publication, extension);
+ });
+ });
+ publishing.repositories(repositories -> {
+ var url = target.getProviders().gradleProperty("teavm.publish.url");
+ if (url.isPresent()) {
+ repositories.maven(repository -> {
+ repository.setName("teavm");
+ repository.setUrl(url.get());
+ repository.getCredentials().setUsername(target.getProviders().gradleProperty(
+ "teavm.publish.username").get());
+ repository.getCredentials().setPassword(target.getProviders().gradleProperty(
+ "teavm.publish.password").get());
+ });
+ }
+ repositories.mavenCentral();
+ });
+ }));
+
+ target.getExtensions().configure(JavaPluginExtension.class, ext -> {
+ ext.withSourcesJar();
+ ext.withJavadocJar();
+ });
+
+ target.getTasks().withType(Javadoc.class, task -> {
+ var options = (CoreJavadocOptions) task.getOptions();
+ options.addStringOption("Xdoclint:none", "-quiet");
+ });
+ }
+
+ private void customizePublication(Project project, MavenPublication publication, ExtensionImpl extension) {
+ publication.setGroupId("org.teavm");
+ if (extension.getArtifactId() != null) {
+ publication.setArtifactId(extension.getArtifactId());
+ }
+ publication.from(project.getComponents().getByName("java"));
+ }
+
+ private static class ExtensionImpl implements PublishTeaVMExtension {
+ private String artifactId;
+
+ @Override
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ @Override
+ public void setArtifactId(String artifactId) {
+ this.artifactId = artifactId;
+ }
+ }
+}
diff --git a/build-logic/src/main/java/org/teavm/buildutil/ShadowApplyPlugin.java b/build-logic/src/main/java/org/teavm/buildutil/ShadowApplyPlugin.java
new file mode 100644
index 000000000..b651118a1
--- /dev/null
+++ b/build-logic/src/main/java/org/teavm/buildutil/ShadowApplyPlugin.java
@@ -0,0 +1,27 @@
+/*
+ * 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.buildutil;
+
+import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin;
+import org.gradle.api.Plugin;
+import org.gradle.api.Project;
+
+public class ShadowApplyPlugin implements Plugin {
+ @Override
+ public void apply(Project target) {
+ target.getPlugins().apply(ShadowPlugin.class);
+ }
+}
diff --git a/build.gradle.kts b/build.gradle.kts
new file mode 100644
index 000000000..8de0a38a5
--- /dev/null
+++ b/build.gradle.kts
@@ -0,0 +1,17 @@
+/*
+ * 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.
+ */
+
+group = "org.teavm"
\ No newline at end of file
diff --git a/classlib/build.gradle.kts b/classlib/build.gradle.kts
new file mode 100644
index 000000000..a04064856
--- /dev/null
+++ b/classlib/build.gradle.kts
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "Java class library emulation"
+
+dependencies {
+ compileOnly(project(":core"))
+
+ implementation(project(":platform"))
+ implementation(project(":jso:apis"))
+ implementation(project(":jso:impl"))
+ implementation(project(":metaprogramming:impl"))
+ implementation(libs.commons.io)
+ implementation(libs.gson)
+ implementation(libs.jzlib)
+ implementation(libs.jodaTime)
+
+ testImplementation(libs.junit)
+ testImplementation(project(":core"))
+}
+
+tasks {
+ val generatedClassesDir = File(buildDir, "generated/classes/java/main")
+ val generateTzCache by registering(JavaExec::class) {
+ val outputFile = File(generatedClassesDir, "org/teavm/classlib/impl/tz/cache")
+ classpath(sourceSets.main.get().runtimeClasspath, sourceSets.main.get().compileClasspath)
+ outputs.file(outputFile)
+ inputs.files(sourceSets.main.get().runtimeClasspath)
+ dependsOn(compileJava)
+ mainClass.set("org.teavm.classlib.impl.tz.TimeZoneCache")
+ args(outputFile.absolutePath)
+ }
+ jar {
+ dependsOn(generateTzCache)
+ from(generatedClassesDir)
+ exclude("html/**")
+ exclude("org/teavm/classlib/impl/tz/tzdata*.zip")
+ }
+}
+
+teavmPublish {
+ artifactId = "teavm-classlib"
+}
diff --git a/classlib/pom.xml b/classlib/pom.xml
deleted file mode 100644
index b806a0149..000000000
--- a/classlib/pom.xml
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
-
- teavm-classlib
-
- TeaVM Java class library
- TeaVM Java class library emulation
-
-
- false
-
-
-
-
- junit
- junit
- test
-
-
- org.teavm
- teavm-platform
- ${project.version}
-
-
- org.teavm
- teavm-core
- ${project.version}
- provided
- true
-
-
- org.teavm
- teavm-jso
- ${project.version}
-
-
- org.teavm
- teavm-jso-apis
- ${project.version}
-
-
- org.teavm
- teavm-jso-impl
- ${project.version}
-
-
- org.teavm
- teavm-metaprogramming-api
- ${project.version}
-
-
- org.teavm
- teavm-metaprogramming-impl
- ${project.version}
-
-
- org.ow2.asm
- asm-util
- provided
- true
-
-
- commons-io
- commons-io
- true
-
-
- com.google.code.gson
- gson
-
-
- com.jcraft
- jzlib
-
-
- joda-time
- joda-time
-
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
-
-
- generate-tz-cache
-
- java
-
- process-classes
-
- org.teavm.classlib.impl.tz.TimeZoneCache
-
- ${project.build.directory}/classes/org/teavm/classlib/impl/tz/cache
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../checkstyle.xml
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
- html/**
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
- package
-
- shade
-
-
-
-
- org.teavm:teavm-classlib
-
-
-
-
- org.objectweb.asm
- org.teavm.asm
-
-
-
-
-
-
-
-
-
diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/regex/TMatcher.java b/classlib/src/main/java/org/teavm/classlib/java/util/regex/TMatcher.java
index 66f0a8ae2..07f03f2bb 100644
--- a/classlib/src/main/java/org/teavm/classlib/java/util/regex/TMatcher.java
+++ b/classlib/src/main/java/org/teavm/classlib/java/util/regex/TMatcher.java
@@ -35,33 +35,6 @@ package org.teavm.classlib.java.util.regex;
import java.util.ArrayList;
-/**
- * Provides a means of matching regular expressions against a given input,
- * finding occurrences of regular expressions in a given input, or replacing
- * parts of a given input. A {@code Matcher} instance has an associated
- * {@link TPattern} instance and an input text. A typical use case is to
- * iteratively find all occurrences of the {@code Pattern}, until the end of the
- * input is reached, as the following example illustrates:
- *
- *
- *
- *
- * Pattern p = Pattern.compile("[A-Za-z]+");
- *
- * Matcher m = p.matcher("Hello, Android!");
- * while (m.find()) {
- * System.out.println(m.group()); // prints "Hello" and "Android"
- * }
- *
- *
- *
- *
- * The {@code Matcher} has a state that results from the previous operations.
- * For example, it knows whether the most recent attempt to find the
- * {@code Pattern} was successful and at which position the next attempt would
- * resume the search. Depending on the application's needs, it may become
- * necessary to explicitly {@link #reset()} this state from time to time.
- */
public final class TMatcher implements TMatchResult {
static final int MODE_FIND = 1;
diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/regex/TPattern.java b/classlib/src/main/java/org/teavm/classlib/java/util/regex/TPattern.java
index 89a456459..edd2b3405 100644
--- a/classlib/src/main/java/org/teavm/classlib/java/util/regex/TPattern.java
+++ b/classlib/src/main/java/org/teavm/classlib/java/util/regex/TPattern.java
@@ -39,36 +39,6 @@ package org.teavm.classlib.java.util.regex;
import java.io.Serializable;
import java.util.ArrayList;
-/**
- * Represents a pattern used for matching, searching, or replacing strings.
- * {@code Pattern}s are specified in terms of regular expressions and compiled
- * using an instance of this class. They are then used in conjunction with a
- * {@link TMatcher} to perform the actual search.
- *
- * A typical use case looks like this:
- *
- *
- *
- *
- * The above code could also be written in a more compact fashion, though this
- * variant is less efficient, since {@code Pattern} and {@code Matcher} objects
- * are created on the fly instead of being reused. fashion:
- *
- *
- *
- * @see TMatcher
- */
public final class TPattern implements Serializable {
private static final long serialVersionUID = 5073258162644648461L;
diff --git a/classlib/src/main/java/org/threeten/bp/OffsetTime.java b/classlib/src/main/java/org/threeten/bp/OffsetTime.java
index 4f9e1be49..f4a85f5eb 100644
--- a/classlib/src/main/java/org/threeten/bp/OffsetTime.java
+++ b/classlib/src/main/java/org/threeten/bp/OffsetTime.java
@@ -1261,7 +1261,7 @@ public final class OffsetTime
* Outputs this time as a {@code String}, such as {@code 10:15:30+01:00}.
*
* The output will be one of the following ISO-8601 formats:
- *
+ *
*
{@code HH:mmXXXXX}
*
{@code HH:mm:ssXXXXX}
*
{@code HH:mm:ss.SSSXXXXX}
diff --git a/classlib/src/main/java/org/threeten/bp/ZoneOffset.java b/classlib/src/main/java/org/threeten/bp/ZoneOffset.java
index bcda00b34..21ce95cd8 100644
--- a/classlib/src/main/java/org/threeten/bp/ZoneOffset.java
+++ b/classlib/src/main/java/org/threeten/bp/ZoneOffset.java
@@ -149,7 +149,7 @@ public final class ZoneOffset
* This method parses the string ID of a {@code ZoneOffset} to
* return an instance. The parsing accepts all the formats generated by
* {@link #getId()}, plus some additional formats:
- *
+ *
*
{@code Z} - for UTC
*
{@code +h}
*
{@code +hh}
@@ -452,7 +452,7 @@ public final class ZoneOffset
*
* The ID is minor variation to the standard ISO-8601 formatted string
* for the offset. There are three formats:
- *
+ *
*
{@code Z} - for UTC (ISO-8601)
*
{@code +hh:mm} or {@code -hh:mm} - if the seconds are zero (ISO-8601)
*
{@code +hh:mm:ss} or {@code -hh:mm:ss} - if the seconds are non-zero (not ISO-8601)
diff --git a/classlib/src/main/java/org/threeten/bp/temporal/WeekFields.java b/classlib/src/main/java/org/threeten/bp/temporal/WeekFields.java
index 261e4df41..01465adf1 100644
--- a/classlib/src/main/java/org/threeten/bp/temporal/WeekFields.java
+++ b/classlib/src/main/java/org/threeten/bp/temporal/WeekFields.java
@@ -105,7 +105,7 @@ import org.threeten.bp.jdk8.Jdk8Methods;
* The earliest period is referred to as week 0 if it has less than the minimal number of days
* and week 1 if it has at least the minimal number of days.
*
- *
+ *
*
Examples of WeekFields
*
Date
Day-of-week
*
First day: Monday Minimal days: 4
First day: Monday Minimal days: 5
diff --git a/classlib/src/main/java/org/threeten/bp/zone/ZoneRules.java b/classlib/src/main/java/org/threeten/bp/zone/ZoneRules.java
index 096c67592..f79198ae6 100644
--- a/classlib/src/main/java/org/threeten/bp/zone/ZoneRules.java
+++ b/classlib/src/main/java/org/threeten/bp/zone/ZoneRules.java
@@ -198,16 +198,16 @@ public abstract class ZoneRules {
*
* There are various ways to handle the conversion from a {@code LocalDateTime}.
* One technique, using this method, would be:
- *
- * List validOffsets = rules.getOffset(localDT);
+ *
{@code
+ * var validOffsets = rules.getOffset(localDT);
* if (validOffsets.size() == 1) {
* // Normal case: only one valid offset
* zoneOffset = validOffsets.get(0);
* } else {
* // Gap or Overlap: determine what to do from transition (which will be non-null)
- * ZoneOffsetTransition trans = rules.getTransition(localDT);
+ * var trans = rules.getTransition(localDT);
* }
- *
+ * }
*
* In theory, it is possible for there to be more than two valid offsets.
* This would happen if clocks to be put back more than once in quick succession.
diff --git a/checkstyle.xml b/config/checkstyle/checkstyle.xml
similarity index 100%
rename from checkstyle.xml
rename to config/checkstyle/checkstyle.xml
diff --git a/license-regexp.txt b/config/checkstyle/license-regexp.txt
similarity index 100%
rename from license-regexp.txt
rename to config/checkstyle/license-regexp.txt
diff --git a/core/build.gradle.kts b/core/build.gradle.kts
new file mode 100644
index 000000000..27e7c2553
--- /dev/null
+++ b/core/build.gradle.kts
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "Compiler, backends and runtime"
+
+dependencies {
+ api(project(":interop:core"))
+ api(project(":metaprogramming:api"))
+
+ implementation(libs.asm.commons)
+ implementation(libs.asm.util)
+ implementation(libs.hppc)
+ implementation(libs.rhino)
+
+ compileOnly(libs.jackson.annotations)
+
+ testImplementation(libs.junit)
+}
+
+teavmPublish {
+ artifactId = "teavm-core"
+}
\ No newline at end of file
diff --git a/core/pom.xml b/core/pom.xml
deleted file mode 100644
index 80f1e2dfb..000000000
--- a/core/pom.xml
+++ /dev/null
@@ -1,159 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
-
- teavm-core
-
- TeaVM core
- TeaVM compiler and SPI
-
-
-
- junit
- junit
- test
-
-
- org.teavm
- teavm-interop
- ${project.version}
-
-
- org.teavm
- teavm-metaprogramming-api
- ${project.version}
-
-
- commons-io
- commons-io
- true
-
-
- org.ow2.asm
- asm-commons
- true
-
-
- org.ow2.asm
- asm-util
- true
-
-
- com.carrotsearch
- hppc
- true
-
-
- com.fasterxml.jackson.core
- jackson-annotations
- true
-
-
- org.mozilla
- rhino
- true
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../checkstyle.xml
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
- package
-
- shade
-
-
-
-
- junit:junit
- org.teavm:teavm-interop
- org.teavm:teavm-metaprogramming-api
- com.fasterxml.jackson.core:jackson-annotations
-
-
-
-
- *:*
-
- **/module-info.class
-
-
-
-
-
- org.objectweb.asm
- org.teavm.asm
-
-
- org.mozilla
- org.teavm.rhino
-
-
- com.carrotsearch.hppc
- org.teavm.hppc
-
-
- org.apache.commons
- org.teavm.apachecommons
-
-
-
-
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- ${maven-javadoc-plugin.version}
-
- protected
-
-
-
-
-
diff --git a/core/src/main/java/org/teavm/vm/TeaVMPluginReader.java b/core/src/main/java/org/teavm/vm/TeaVMPluginReader.java
index 58930516f..f981b4060 100644
--- a/core/src/main/java/org/teavm/vm/TeaVMPluginReader.java
+++ b/core/src/main/java/org/teavm/vm/TeaVMPluginReader.java
@@ -21,10 +21,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -55,11 +55,11 @@ final class TeaVMPluginReader {
static void load(ClassLoader classLoader, Consumer consumer) {
Set unorderedPlugins = new HashSet<>();
try {
- Enumeration resourceFiles = classLoader.getResources(DESCRIPTOR_LOCATION);
+ var resourceFiles = classLoader.getResources(DESCRIPTOR_LOCATION);
while (resourceFiles.hasMoreElements()) {
URL resourceFile = resourceFiles.nextElement();
- try (BufferedReader input = new BufferedReader(
- new InputStreamReader(resourceFile.openStream(), "UTF-8"))) {
+ try (var input = new BufferedReader(
+ new InputStreamReader(resourceFile.openStream(), StandardCharsets.UTF_8))) {
readPlugins(input, unorderedPlugins);
}
}
diff --git a/core/src/main/resources/org/teavm/backend/wasm/wasm-runtime.js b/core/src/main/resources/org/teavm/backend/wasm/wasm-runtime.js
index ab5605193..228c6e75c 100644
--- a/core/src/main/resources/org/teavm/backend/wasm/wasm-runtime.js
+++ b/core/src/main/resources/org/teavm/backend/wasm/wasm-runtime.js
@@ -166,7 +166,7 @@ TeaVM.wasm = function() {
const importObj = {};
const controller = defaults(importObj);
if (typeof options.installImports !== "undefined") {
- options.installImports(importObj);
+ options.installImports(importObj, controller);
}
return WebAssembly.instantiateStreaming(fetch(path), importObj).then((obj => {
diff --git a/deploy-settings.xml b/deploy-settings.xml
deleted file mode 100644
index 4b69f2ba9..000000000
--- a/deploy-settings.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
- teavm-repo
- ${env.TEAVM_DEPLOY_LOGIN}
- ${env.TEAVM_DEPLOY_PASSWORD}
-
-
-
diff --git a/deploy.sh b/deploy.sh
index 1e5453bc2..69d04b0e9 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -21,8 +21,7 @@ git fetch
git archive master | tar -x -C build-dir || { echo 'Git archive failed' ; exit 1; }
function deploy_teavm {
- TEAVM_OLD_VERSION=`mvn help:evaluate -Dexpression=project.version 2>/dev/null | grep -Ev "(^\[|Download)"`
- TEAVM_DEPLOY_VERSION=${TEAVM_OLD_VERSION%.0-SNAPSHOT}
+ TEAVM_DEPLOY_VERSION=`sed -En 's/teavm\.project\.version\s*=\s*([0-9]+\.[0-9]+)\..*/\1/p' gradle.properties`
git rev-parse master >commit-id.txt
TEAVM_DEPLOY_COMMIT_ID=`cat commit-id.txt`
@@ -45,31 +44,8 @@ function deploy_teavm {
echo "Building version $TEAVM_DEPLOY_VERSION_FULL"
- sed -i -e "s/{{TEAVM_DEPLOY_URL}}/ftp:\/\/${TEAVM_DEPLOY_SERVER//\//\\/}\/maven\/repository/g" pom.xml
-
- mvn -e versions:set \
- -DnewVersion="$TEAVM_DEPLOY_VERSION_FULL" \
- -DgenerateBackupPoms=false \
- || { echo 'Setting version' ; return 1; }
-
- mvn -T $TEAVM_DEPLOY_THREADS -e -V install \
- --settings ../deploy-settings.xml \
- -P with-idea -P with-cli -P deploy-to-teavm -P with-tests \
- -Dmaven.repo.local=`pwd`/../build-cache/maven-repository \
- -Dteavm.build.all=false \
- -Dteavm.junit.optimized=true \
- -Dteavm.junit.js.decodeStack=false \
- -Dteavm.junit.threads=$TEAVM_DEPLOY_TEST_THREADS \
- -Dteavm.junit.js.runner=browser-chrome \
- || { echo 'Build failed' ; return 1; }
-
- mvn -T $TEAVM_DEPLOY_THREADS -e -V deploy \
- --settings ../deploy-settings.xml \
- -P with-idea -P with-cli -P deploy-to-teavm \
- -Dmaven.repo.local=`pwd`/../build-cache/maven-repository \
- -Dteavm.build.all=false \
- -DskipTests \
- || { echo 'Deploy failed' ; return 1; }
+ ./gradlew build || { echo 'Build failed' ; return 1; }
+ ./gradlew publishAllPublicationsToMavenRepository || { echo 'Deploy failed' ; return 1; }
cat <idea-repository.xml
diff --git a/extras-slf4j/build.gradle.kts b/extras-slf4j/build.gradle.kts
new file mode 100644
index 000000000..2868da11b
--- /dev/null
+++ b/extras-slf4j/build.gradle.kts
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "TeaVM backend for slf4j"
+
+dependencies {
+ implementation(project(":jso:core"))
+
+ compileOnly(project(":core"))
+ compileOnly(libs.slf4j)
+}
+
+teavmPublish {
+ artifactId = "teavm-extras-slf4j"
+}
\ No newline at end of file
diff --git a/extras-slf4j/pom.xml b/extras-slf4j/pom.xml
deleted file mode 100644
index 48a16a53a..000000000
--- a/extras-slf4j/pom.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
-
- teavm-extras-slf4j
-
- TeaVM slf4j
- TeaVM backend for slf4j
-
-
-
- org.teavm
- teavm-core
- ${project.version}
- provided
-
-
- org.teavm
- teavm-jso
- ${project.version}
-
-
- org.slf4j
- slf4j-api
- provided
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../checkstyle.xml
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 000000000..52380a631
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+
+org.gradle.parallel=true
+org.gradle.daemon=true
+org.gradle.caching=true
+org.gradle.unsafe.configuration-cache=true
+
+teavm.project.version=0.7.0-SNAPSHOT
+teavm.tests.decodeStack=false
+teavm.tests.optimized=true
+teavm.tests.minified=false
\ No newline at end of file
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
new file mode 100644
index 000000000..a0c3efaec
--- /dev/null
+++ b/gradle/libs.versions.toml
@@ -0,0 +1,74 @@
+[versions]
+
+asm = "9.4"
+jackson = "2.12.2"
+jetty = "9.4.38.v20210224"
+shadow = "7.1.2"
+checkstyle = "8.41"
+idea = "2020.1.4"
+idea-scala = "2020.1.43"
+maven = "3.5.4"
+maven-tools = "3.7.1"
+
+
+[libraries]
+
+hppc = "com.carrotsearch:hppc:0.8.2"
+commons-io = "commons-io:commons-io:2.8.0"
+commons-cli = "commons-cli:commons-cli:1.4"
+rhino = "org.mozilla:rhino:1.7.11"
+slf4j = "org.slf4j:slf4j-api:1.7.30"
+javax-servlet = "javax.servlet:javax.servlet-api:3.1.0"
+javax-websocket = "javax.websocket:javax.websocket-api:1.0"
+
+asm = { module = "org.ow2.asm:asm", version.ref = "asm" }
+asm-commons = { module = "org.ow2.asm:asm-commons", version.ref = "asm" }
+asm-util = { module = "org.ow2.asm:asm-util", version.ref = "asm" }
+asm-tree = { module = "org.ow2.asm:asm-tree", version.ref = "asm" }
+asm-analysis = { module = "org.ow2.asm:asm-analysis", version.ref = "asm" }
+
+jackson-annotations = { module = "com.fasterxml.jackson.core:jackson-annotations", version.ref = "jackson" }
+jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" }
+
+gson = "com.google.code.gson:gson:2.8.6"
+jzlib = "com.jcraft:jzlib:1.1.3"
+jodaTime = "joda-time:joda-time:2.7"
+htmlunit = "net.sourceforge.htmlunit:htmlunit:2.37.0"
+httpclient = "org.apache.httpcomponents:httpclient:4.5.13"
+
+jetty-server = { module = "org.eclipse.jetty:jetty-server", version.ref = "jetty" }
+jetty-websocket-server = { module = "org.eclipse.jetty.websocket:javax-websocket-server-impl", version.ref = "jetty" }
+jetty-websocket-client = { module = "org.eclipse.jetty.websocket:websocket-client", version.ref = "jetty" }
+
+junit = "junit:junit:4.13.2"
+testng = "org.testng:testng:7.7.0"
+
+maven-plugin-api = { module = "org.apache.maven:maven-plugin-api", version.ref = "maven" }
+maven-artifact = { module = "org.apache.maven:maven-artifact", version.ref = "maven" }
+maven-core = { module = "org.apache.maven:maven-core", version.ref = "maven" }
+maven-embedder = { module = "org.apache.maven:maven-embedder", version.ref = "maven" }
+maven-compat = { module = "org.apache.maven:maven-compat", version.ref = "maven" }
+
+[libraries.maven-plugin-tools-api]
+module = "org.apache.maven.plugin-tools:maven-plugin-tools-api"
+version.ref = "maven-tools"
+[libraries.maven-plugin-tools-generators]
+module = "org.apache.maven.plugin-tools:maven-plugin-tools-generators"
+version.ref = "maven-tools"
+[libraries.maven-plugin-tools-annotations]
+module = "org.apache.maven.plugin-tools:maven-plugin-tools-annotations"
+version.ref = "maven-tools"
+
+[libraries.maven-plugin-annotations]
+module = "org.apache.maven.plugin-tools:maven-plugin-annotations"
+version.ref = "maven-tools"
+
+[libraries.shadowPlugin]
+module = "com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin"
+version.ref = "shadow"
+
+
+[plugins]
+
+shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
+intellij = { id = "org.jetbrains.intellij", version = "1.10.0" }
\ No newline at end of file
diff --git a/tools/idea/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
similarity index 100%
rename from tools/idea/gradle/wrapper/gradle-wrapper.jar
rename to gradle/wrapper/gradle-wrapper.jar
diff --git a/tools/idea/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
similarity index 100%
rename from tools/idea/gradle/wrapper/gradle-wrapper.properties
rename to gradle/wrapper/gradle-wrapper.properties
diff --git a/tools/idea/gradlew b/gradlew
similarity index 100%
rename from tools/idea/gradlew
rename to gradlew
diff --git a/tools/idea/gradlew.bat b/gradlew.bat
similarity index 100%
rename from tools/idea/gradlew.bat
rename to gradlew.bat
diff --git a/html4j/pom.xml b/html4j/pom.xml
deleted file mode 100644
index 3d40fe733..000000000
--- a/html4j/pom.xml
+++ /dev/null
@@ -1,133 +0,0 @@
-
-
- 4.0.0
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
-
- teavm-html4j
-
- TeaVM html4j support
- A set of interceptors and hacks for TeaVM to support html4j
-
-
-
- org.teavm
- teavm-core
- ${project.version}
-
-
- org.teavm
- teavm-classlib
- ${project.version}
-
-
- org.netbeans.html
- net.java.html.boot
-
-
- org.netbeans.html
- net.java.html.json.tck
- true
- test
-
-
- org.netbeans.html
- ko4j
- test
-
-
- junit
- junit
- test
-
-
- ${project.groupId}
- teavm-junit
- ${project.version}
- test
-
-
-
- commons-io
- commons-io
- true
-
-
- org.ow2.asm
- asm-commons
- true
-
-
- org.ow2.asm
- asm-util
- true
-
-
- com.carrotsearch
- hppc
- true
-
-
- org.mozilla
- rhino
- true
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../checkstyle.xml
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- org.apache.maven.surefire
- surefire-junit47
- ${maven-surefire-plugin.version}
-
-
-
-
- ${project.build.directory}/js-tests
- true
- false
-
- -Xmx1024m
-
-
-
-
-
diff --git a/interop/core/build.gradle.kts b/interop/core/build.gradle.kts
new file mode 100644
index 000000000..05b86ae3d
--- /dev/null
+++ b/interop/core/build.gradle.kts
@@ -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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "Runtime interoperability API"
+
+teavmPublish {
+ artifactId = "teavm-interop"
+}
\ No newline at end of file
diff --git a/interop/core/pom.xml b/interop/core/pom.xml
deleted file mode 100644
index 7e5a5b8d0..000000000
--- a/interop/core/pom.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- teavm-interop
-
- TeaVM interop API
- API that allows Java programs to interoperate with low-level languages like C in some low-level
- environments like WebAssembly and LLVM
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
- true
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
-
\ No newline at end of file
diff --git a/jso/apis/build.gradle.kts b/jso/apis/build.gradle.kts
new file mode 100644
index 000000000..55472aa09
--- /dev/null
+++ b/jso/apis/build.gradle.kts
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "Set of JavaScript API wrappers for JSO"
+
+configurations {
+ val teavm = create("teavm")
+ teavm.extendsFrom(compileClasspath.get())
+}
+
+dependencies {
+ api(project(":jso:core"))
+ api(project(":interop:core"))
+}
+
+teavmPublish {
+ artifactId = "teavm-jso-apis"
+}
\ No newline at end of file
diff --git a/jso/apis/pom.xml b/jso/apis/pom.xml
deleted file mode 100644
index e140a3eda..000000000
--- a/jso/apis/pom.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- teavm-jso-apis
-
- TeaVM JavaScript APIs
- Set of JavaScript API wrappers for JSO
-
-
-
- org.teavm
- teavm-jso
- ${project.version}
-
-
- org.teavm
- teavm-interop
- ${project.version}
-
-
- junit
- junit
- test
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
- true
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
-
- org.teavm.jso.apis
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
diff --git a/jso/core/build.gradle.kts b/jso/core/build.gradle.kts
new file mode 100644
index 000000000..a55b96529
--- /dev/null
+++ b/jso/core/build.gradle.kts
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "Library that adds convenient interface for interaction between TeaVM and JavaScript code"
+
+configurations {
+ val teavm = create("teavm")
+ teavm.extendsFrom(compileClasspath.get())
+}
+
+dependencies {
+ "teavm"(project(":jso:impl"))
+}
+
+teavmPublish {
+ artifactId = "teavm-jso"
+}
\ No newline at end of file
diff --git a/jso/core/pom.xml b/jso/core/pom.xml
deleted file mode 100644
index c37ca5504..000000000
--- a/jso/core/pom.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- teavm-jso
-
- TeaVM JavaScript objects
- A library that adds convenient interface for interaction between TeaVM and JavaScript code
-
-
-
- junit
- junit
- test
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
- true
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
-
- org.teavm.jso
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- true
-
-
-
-
-
diff --git a/jso/impl/build.gradle.kts b/jso/impl/build.gradle.kts
new file mode 100644
index 000000000..4b5dea21c
--- /dev/null
+++ b/jso/impl/build.gradle.kts
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "implementation of JSO"
+
+dependencies {
+ compileOnly(project(":core"))
+
+ implementation(libs.rhino)
+ implementation(project(":jso:core"))
+ implementation(project(":jso:apis"))
+}
+
+teavmPublish {
+ artifactId = "teavm-jso-impl"
+}
\ No newline at end of file
diff --git a/jso/impl/pom.xml b/jso/impl/pom.xml
deleted file mode 100644
index bfa796b69..000000000
--- a/jso/impl/pom.xml
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- teavm-jso-impl
-
- TeaVM JavaScript objects - implementation
- An implementation of JSO
-
-
-
- org.teavm
- teavm-core
- ${project.version}
- provided
-
-
- org.teavm
- teavm-jso-apis
- ${project.version}
-
-
- junit
- junit
- test
-
-
- org.mozilla
- rhino
- true
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
- package
-
- shade
-
-
-
-
- org.teavm:teavm-jso-impl
-
-
-
-
- org.mozilla
- org.teavm.rhino
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/metaprogramming/api/build.gradle.kts b/metaprogramming/api/build.gradle.kts
new file mode 100644
index 000000000..6916ad9f9
--- /dev/null
+++ b/metaprogramming/api/build.gradle.kts
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "Declaration of interfaces and annotations for TeaVM metaprogramming"
+
+configurations {
+ val teavm = create("teavm")
+ teavm.extendsFrom(compileClasspath.get())
+}
+
+dependencies {
+ "teavm"(project(":metaprogramming:impl"))
+}
+
+teavmPublish {
+ artifactId = "teavm-metaprogramming-api"
+}
\ No newline at end of file
diff --git a/metaprogramming/api/pom.xml b/metaprogramming/api/pom.xml
deleted file mode 100644
index 24da61afe..000000000
--- a/metaprogramming/api/pom.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- teavm-metaprogramming-api
-
- TeaVM metaprogramming API
- Declaration of interfaces and annotations for TeaVM metaprogramming
-
-
-
- junit
- junit
- test
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
-
- org.teavm.metaprogramming.api
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
\ No newline at end of file
diff --git a/metaprogramming/impl/build.gradle.kts b/metaprogramming/impl/build.gradle.kts
new file mode 100644
index 000000000..9cb473a2d
--- /dev/null
+++ b/metaprogramming/impl/build.gradle.kts
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "Implementation of metaprogramming API"
+
+dependencies {
+ compileOnly(project(":core"))
+
+ implementation(libs.commons.io)
+ implementation(libs.asm)
+ implementation(project(":metaprogramming:api"))
+}
+
+teavmPublish {
+ artifactId = "teavm-metaprogramming-impl"
+}
\ No newline at end of file
diff --git a/metaprogramming/impl/pom.xml b/metaprogramming/impl/pom.xml
deleted file mode 100644
index aa8eab4d7..000000000
--- a/metaprogramming/impl/pom.xml
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
- teavm
- org.teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- 4.0.0
-
- teavm-metaprogramming-impl
-
- TeaVM metaprogramming API implementation
- Implementation of metaprogramming API
-
-
-
- org.teavm
- teavm-core
- ${project.version}
- provided
-
-
- org.teavm
- teavm-metaprogramming-api
- ${project.version}
-
-
- commons-io
- commons-io
- true
-
-
- org.ow2.asm
- asm-commons
- true
-
-
- org.ow2.asm
- asm-util
- true
-
-
- junit
- junit
- test
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
- package
-
- shade
-
-
-
-
- org.teavm:teavm-metaprogramming-impl
-
-
-
-
- org.objectweb.asm
- org.teavm.asm
-
-
- org.apache.commons
- org.teavm.apachecommons
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/platform/build.gradle.kts b/platform/build.gradle.kts
new file mode 100644
index 000000000..f9208a513
--- /dev/null
+++ b/platform/build.gradle.kts
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "Low-level classes that help to implement Java class library"
+
+dependencies {
+ compileOnly(project(":core"))
+ compileOnly(libs.commons.io)
+ compileOnly(libs.asm)
+
+ implementation(project(":jso:apis"))
+}
+
+teavmPublish {
+ artifactId = "teavm-platform"
+}
\ No newline at end of file
diff --git a/platform/pom.xml b/platform/pom.xml
deleted file mode 100644
index 375750a2b..000000000
--- a/platform/pom.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
-
- teavm-platform
-
- TeaVM platform
- A low-level classes that help to implement Java class library
-
-
-
- org.teavm
- teavm-core
- ${project.version}
- provided
-
-
- org.teavm
- teavm-jso-apis
- ${project.version}
-
-
- junit
- junit
- test
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../checkstyle.xml
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
\ No newline at end of file
diff --git a/platform/src/main/java/org/teavm/platform/metadata/MetadataGenerator.java b/platform/src/main/java/org/teavm/platform/metadata/MetadataGenerator.java
index e66b2d689..fd138dc78 100644
--- a/platform/src/main/java/org/teavm/platform/metadata/MetadataGenerator.java
+++ b/platform/src/main/java/org/teavm/platform/metadata/MetadataGenerator.java
@@ -17,43 +17,6 @@ package org.teavm.platform.metadata;
import org.teavm.model.MethodReference;
-/**
- *
Represents a generator, that produces resources during compilation phase. User must implement this
- * interface and bind this implementation to a method that would read resources at runtime.
- *
- *
Here is the full workflow:
- *
- *
- *
Compiler finds a method that is marked with the {@link MetadataProvider} annotation.
- * This method must be declared as native, otherwise compiler should throw an exception.
- *
Compiler instantiates the {@link MetadataGenerator} instance with the no-arg constructor
- * If no such constructor exists, compiler throws exception.
- *
Compiler runs the {@link #generateMetadata(MetadataGeneratorContext, MethodReference)} method
- * ands gets the produced resource.
- *
Compiler generates implementation of the method marked with {@link MetadataProvider}, that
- * will return the generated resource in run time.
- *
- *
- *
Therefore, the type of the value, returned by the
- * {@link #generateMetadata(MetadataGeneratorContext, MethodReference)}
- * method must match the returning type of the appropriate method, marked with {@link MetadataProvider}.
- *
- *
The valid resource types are the following:
- *
- *
- *
Valid interfaces, extending the {@link Resource} annotation. Read the description of this interface
- * for detailed description about valid resources interfaces.
- *
{@link ResourceArray} of valid resources.
- *
{@link ResourceMap} of valid resources.
- *
The null value.
- *
- *
- *
All other types are not considered to be resources and therefore are not accepted.
+
+
\ No newline at end of file
diff --git a/samples/benchmark/src/main/webapp/bck2brwsr.html b/samples/pi/src/main/webapp/js.html
similarity index 50%
rename from samples/benchmark/src/main/webapp/bck2brwsr.html
rename to samples/pi/src/main/webapp/js.html
index 86cadce18..62b99b833 100644
--- a/samples/benchmark/src/main/webapp/bck2brwsr.html
+++ b/samples/pi/src/main/webapp/js.html
@@ -16,31 +16,30 @@
+ PI calculator example
- Bck2Brwsr jbox2d benchmark
+
+
+
+
-
Bck2Brwsr performance
-
+ Digit count:
+
+
-
-
-
-
Second
-
Time spent computing, ms
-
-
-
-
-
-
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/samples/pi/src/main/webapp/wasm.html b/samples/pi/src/main/webapp/wasm.html
new file mode 100644
index 000000000..29601f787
--- /dev/null
+++ b/samples/pi/src/main/webapp/wasm.html
@@ -0,0 +1,67 @@
+
+
+
+
+ PI calculator example
+
+
+
+
+
+
+
+
+ Digit count:
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/pom.xml b/samples/pom.xml
deleted file mode 100644
index 2930bdb18..000000000
--- a/samples/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
-
- teavm-samples
-
- pom
-
- TeaVM samples
- TeaVM code samples
-
-
- hello
- benchmark
- storage
- video
- async
- kotlin
- scala
- gamepad
-
-
diff --git a/samples/scala/build.gradle.kts b/samples/scala/build.gradle.kts
new file mode 100644
index 000000000..3ba21e7b9
--- /dev/null
+++ b/samples/scala/build.gradle.kts
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+plugins {
+ scala
+ war
+ id("org.teavm")
+}
+
+dependencies {
+ teavm(teavm.libs.jsoApis)
+ teavm("org.scala-lang:scala-library:2.13.10")
+}
+
+teavm.js {
+ addedToWebApp.set(true)
+ mainClass.set("org.teavm.samples.scala.Client")
+}
diff --git a/samples/scala/pom.xml b/samples/scala/pom.xml
deleted file mode 100644
index 49875343a..000000000
--- a/samples/scala/pom.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
- 4.0.0
-
- org.teavm
- teavm-samples
- 0.7.0-SNAPSHOT
-
- war
-
- teavm-samples-scala
-
- TeaVM Scala example
- A sample application written in Scala.
-
-
- 1.8
- 2.13.8
- UTF-8
-
-
-
-
- org.teavm
- teavm-classlib
- ${project.version}
- provided
-
-
- org.teavm
- teavm-jso
- ${project.version}
-
-
- org.scala-lang
- scala-library
- ${scala.version}
-
-
-
-
- src/main/scala
-
-
-
- net.alchim31.maven
- scala-maven-plugin
- 4.6.1
-
-
-
- compile
- testCompile
-
-
-
-
- ${scala.version}
-
-
-
- org.teavm
- teavm-maven-plugin
- ${project.version}
-
-
- web-client
-
- compile
-
-
- ${project.build.directory}/generated/js/teavm
- org.teavm.samples.scala.Client
- false
- true
- true
- true
-
-
-
-
-
- maven-war-plugin
- 3.2.3
-
-
-
- ${project.build.directory}/generated/js
-
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
-
diff --git a/samples/scala/src/main/webapp/index.html b/samples/scala/src/main/webapp/index.html
index 344147872..5fb4e7eb8 100644
--- a/samples/scala/src/main/webapp/index.html
+++ b/samples/scala/src/main/webapp/index.html
@@ -3,7 +3,7 @@
Hello Scala
-
+
diff --git a/samples/scala/src/main/scala/org/teavm/samples/scala/Calculator.scala b/samples/scala/src/teavm/scala/org/teavm/samples/scala/Calculator.scala
similarity index 78%
rename from samples/scala/src/main/scala/org/teavm/samples/scala/Calculator.scala
rename to samples/scala/src/teavm/scala/org/teavm/samples/scala/Calculator.scala
index 902026f6b..cff395043 100644
--- a/samples/scala/src/main/scala/org/teavm/samples/scala/Calculator.scala
+++ b/samples/scala/src/teavm/scala/org/teavm/samples/scala/Calculator.scala
@@ -1,3 +1,19 @@
+/*
+ * 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.samples.scala
import org.teavm.samples.scala.Grammar._
diff --git a/samples/scala/src/main/scala/org/teavm/samples/scala/Client.scala b/samples/scala/src/teavm/scala/org/teavm/samples/scala/Client.scala
similarity index 100%
rename from samples/scala/src/main/scala/org/teavm/samples/scala/Client.scala
rename to samples/scala/src/teavm/scala/org/teavm/samples/scala/Client.scala
diff --git a/samples/scala/src/main/scala/org/teavm/samples/scala/Grammar.scala b/samples/scala/src/teavm/scala/org/teavm/samples/scala/Grammar.scala
similarity index 100%
rename from samples/scala/src/main/scala/org/teavm/samples/scala/Grammar.scala
rename to samples/scala/src/teavm/scala/org/teavm/samples/scala/Grammar.scala
diff --git a/samples/settings.gradle.kts b/samples/settings.gradle.kts
new file mode 100644
index 000000000..310db4faf
--- /dev/null
+++ b/samples/settings.gradle.kts
@@ -0,0 +1,93 @@
+import org.akhikhl.gretty.GrettyExtension
+import org.akhikhl.gretty.GrettyPlugin
+
+/*
+ * 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.
+ */
+
+dependencyResolutionManagement {
+ versionCatalogs {
+ create("libs") {
+ from(files("../gradle/libs.versions.toml"))
+ }
+ }
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ }
+}
+
+pluginManagement {
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+ plugins {
+ id("org.gretty") version "4.0.3" apply false
+ }
+}
+
+buildscript {
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ gradlePluginPortal()
+ }
+ dependencies.classpath("org.gretty:org.gretty.gradle.plugin:4.0.3")
+}
+
+rootProject.name = "teavmSamples"
+
+include("stdout-helper")
+include("hello")
+include("async")
+include("benchmark")
+include("pi")
+include("kotlin")
+include("scala")
+include("video")
+include("storage")
+
+gradle.allprojects {
+ apply()
+ apply()
+
+ extensions.configure {
+ contextPath = ""
+ }
+
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ }
+}
+
+gradle.afterProject {
+ val java = extensions.findByType()
+ if (java != null) {
+ apply()
+ extensions.configure {
+ toolVersion = extensions.getByType().named("libs")
+ .findVersion("checkstyle").get().requiredVersion
+ configDirectory.set(File(settings.rootDir, "../config/checkstyle"))
+ }
+ java.toolchain {
+ if (!languageVersion.isPresent) {
+ languageVersion.set(JavaLanguageVersion.of(11))
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/stdout-helper/build.gradle.kts b/samples/stdout-helper/build.gradle.kts
new file mode 100644
index 000000000..8a0177664
--- /dev/null
+++ b/samples/stdout-helper/build.gradle.kts
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+plugins {
+ war
+}
+
+configurations {
+ create("war")
+}
+
+artifacts.add("war", tasks.war)
\ No newline at end of file
diff --git a/samples/async/src/main/webapp/teavm/stdout.js b/samples/stdout-helper/src/main/webapp/teavm/stdout.js
similarity index 85%
rename from samples/async/src/main/webapp/teavm/stdout.js
rename to samples/stdout-helper/src/main/webapp/teavm/stdout.js
index 5b72b776e..9158680f6 100644
--- a/samples/async/src/main/webapp/teavm/stdout.js
+++ b/samples/stdout-helper/src/main/webapp/teavm/stdout.js
@@ -1,4 +1,4 @@
-var $rt_stdoutBuffer = "";
+let $rt_stdoutBuffer = "";
function $rt_putStdoutCustom(ch) {
if (ch === 0xA) {
var lineElem = document.createElement("div");
@@ -10,4 +10,5 @@ function $rt_putStdoutCustom(ch) {
} else {
$rt_stdoutBuffer += String.fromCharCode(ch);
}
-}
+}
+this.$rt_putStdoutCustom = $rt_putStdoutCustom;
\ No newline at end of file
diff --git a/samples/storage/build.gradle.kts b/samples/storage/build.gradle.kts
new file mode 100644
index 000000000..b8acd11b5
--- /dev/null
+++ b/samples/storage/build.gradle.kts
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+plugins {
+ java
+ war
+ id("org.teavm")
+}
+
+dependencies {
+ teavm(teavm.libs.jsoApis)
+}
+
+teavm.js {
+ addedToWebApp.set(true)
+ mainClass.set("org.teavm.samples.storage.Application")
+}
diff --git a/samples/storage/pom.xml b/samples/storage/pom.xml
deleted file mode 100644
index 65ab1f66b..000000000
--- a/samples/storage/pom.xml
+++ /dev/null
@@ -1,106 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm-samples
- 0.7.0-SNAPSHOT
-
- teavm-samples-storage
-
- war
-
- TeaVM Web Storage web application
- A sample application that demonstrate how to use Web Storage API.
-
-
-
- org.teavm
- teavm-classlib
- ${project.version}
- provided
-
-
- org.teavm
- teavm-jso-apis
- ${project.version}
- provided
-
-
- javax.servlet
- javax.servlet-api
- 3.1.0
- provided
-
-
-
-
-
-
- maven-war-plugin
- 3.2.3
-
-
-
- ${project.build.directory}/generated/js
-
-
-
-
-
- org.teavm
- teavm-maven-plugin
- ${project.version}
-
-
- web-client
- prepare-package
-
- compile
-
-
- ${project.build.directory}/generated/js/teavm
- org.teavm.samples.storage.Application
- false
- true
- true
- true
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
diff --git a/samples/storage/src/main/webapp/index.html b/samples/storage/src/main/webapp/index.html
index 4cbf27347..13f703379 100644
--- a/samples/storage/src/main/webapp/index.html
+++ b/samples/storage/src/main/webapp/index.html
@@ -18,7 +18,7 @@
Web Storage web application
-
+
Web Storage web application
diff --git a/samples/video/build.gradle.kts b/samples/video/build.gradle.kts
new file mode 100644
index 000000000..e49ec2b02
--- /dev/null
+++ b/samples/video/build.gradle.kts
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+plugins {
+ java
+ war
+ id("org.teavm")
+}
+
+dependencies {
+ teavm(teavm.libs.jsoApis)
+}
+
+teavm.js {
+ addedToWebApp.set(true)
+ mainClass.set("org.teavm.samples.video.Player")
+}
\ No newline at end of file
diff --git a/samples/video/pom.xml b/samples/video/pom.xml
deleted file mode 100644
index 445613f7e..000000000
--- a/samples/video/pom.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm-samples
- 0.7.0-SNAPSHOT
-
- teavm-samples-video
-
- war
-
- TeaVM HTML5 video web application
- A sample application that shows HTML5 video implementation for TeaVM
-
-
-
- org.teavm
- teavm-classlib
- ${project.version}
- provided
-
-
- org.teavm
- teavm-jso-apis
- ${project.version}
- provided
-
-
- javax.servlet
- javax.servlet-api
- 3.1.0
- provided
-
-
-
-
-
-
- maven-war-plugin
- 3.2.3
-
-
-
- ${project.build.directory}/generated/js
-
-
-
-
-
- org.teavm
- teavm-maven-plugin
- ${project.version}
-
-
- web-client
-
- compile
-
-
- ${project.build.directory}/generated/js/teavm
- org.teavm.samples.video.Player
- false
- true
- true
- true
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
diff --git a/samples/video/src/main/webapp/index.html b/samples/video/src/main/webapp/index.html
index 1e78c566d..855ed36de 100644
--- a/samples/video/src/main/webapp/index.html
+++ b/samples/video/src/main/webapp/index.html
@@ -18,7 +18,7 @@
HTML5 Video web application
-
+
diff --git a/settings.gradle.kts b/settings.gradle.kts
new file mode 100644
index 000000000..6106ac00f
--- /dev/null
+++ b/settings.gradle.kts
@@ -0,0 +1,127 @@
+import org.teavm.buildutil.DependencyRelocationExtension
+
+/*
+ * 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.
+ */
+
+pluginManagement {
+ repositories {
+ gradlePluginPortal()
+ }
+ includeBuild("build-logic")
+}
+plugins {
+ id("dependency-relocation")
+}
+
+rootProject.name = "teavm"
+
+include("core")
+include("interop:core")
+include("metaprogramming:api", "metaprogramming:impl")
+include("jso:core", "jso:apis", "jso:impl")
+include("platform")
+include("classlib")
+include("tools:core")
+include("tools:deobfuscator-js")
+include("tools:junit")
+include("tools:devserver")
+include("tools:c-incremental")
+include("tools:chrome-rdp")
+include("tools:cli")
+include("tools:gradle")
+include("tools:ide-deps")
+include("tools:idea")
+include("tools:maven:plugin")
+include("tools:maven:webapp")
+include("tools:classlib-comparison-gen")
+include("tests")
+include("extras-slf4j")
+
+val teavmVersion = providers.gradleProperty("teavm.project.version").get()
+
+gradle.allprojects {
+ repositories {
+ mavenCentral()
+ }
+ version = teavmVersion
+}
+
+gradle.afterProject {
+ val java = extensions.findByType()
+ if (java != null) {
+ apply()
+ extensions.configure {
+ toolVersion = extensions.getByType().named("libs")
+ .findVersion("checkstyle").get().requiredVersion
+ }
+ java.toolchain {
+ if (!languageVersion.isPresent) {
+ languageVersion.set(JavaLanguageVersion.of(11))
+ }
+ }
+ }
+
+ extensions.findByType()?.apply {
+ publications.all {
+ if (this is MavenPublication) {
+ pom { setupPom() }
+ }
+ }
+ }
+}
+
+fun MavenPom.setupPom() {
+ licenses {
+ license {
+ name.set("The Apache Software License, Version 2.0")
+ url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
+ distribution.set("repo")
+ comments.set("A business-friendly OSS license")
+ }
+ }
+ developers {
+ developer {
+ id.set("konsoletyper")
+ name.set("Alexey Andreev")
+ email.set("konsoletyper@gmail.com")
+ timezone.set("Europe/Berlin")
+ }
+ }
+ scm {
+ url.set("https://github.com/konsoletyper/teavm")
+ connection.set("scm:git:git@github.com:konsoletyper/teavm.git")
+ }
+ url.set("https://teavm.org")
+}
+
+extensions.configure {
+ library("libs", "commons-io") {
+ relocate("org.apache.commons", "org.teavm.apachecommons")
+ }
+ for (asmLib in listOf("asm", "asm-tree", "asm-analysis", "asm-commons", "asm-util")) {
+ library("libs", asmLib) {
+ relocate("org.objectweb.asm", "org.teavm.asm")
+ }
+ }
+ library("libs", "rhino") {
+ relocate("org.mozilla", "org.teavm.rhino")
+ }
+ library("libs", "hppc") {
+ relocate("com.carrotsearch.hppc", "org.teavm.hppc")
+ }
+
+ skip(":tools:gradle")
+}
\ No newline at end of file
diff --git a/tests/build.gradle.kts b/tests/build.gradle.kts
new file mode 100644
index 000000000..f9979c57e
--- /dev/null
+++ b/tests/build.gradle.kts
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+}
+
+description = "Tests"
+
+java {
+ toolchain {
+ languageVersion.set(JavaLanguageVersion.of(17))
+ }
+}
+
+dependencies {
+ testImplementation(project(":core"))
+ testImplementation(project(":classlib"))
+ testImplementation(project(":jso:apis"))
+ testImplementation(project(":platform"))
+ testImplementation(project(":metaprogramming:impl"))
+ testImplementation(project(":tools:core"))
+ testImplementation(project(":tools:junit"))
+ testImplementation(libs.hppc)
+ testImplementation(libs.rhino)
+ testImplementation(libs.junit)
+ testImplementation(libs.testng)
+}
+
+tasks.test {
+ systemProperty("teavm.junit.target", "${project.buildDir.absolutePath }/js-tests")
+ systemProperty("teavm.junit.js.runner", "browser-chrome")
+ systemProperty("teavm.junit.threads", "1")
+ systemProperty("teavm.junit.minified", providers.gradleProperty("teavm.tests.minified"))
+ systemProperty("teavm.junit.optimized", providers.gradleProperty("teavm.tests.optimized"))
+ systemProperty("teavm.junit.js.decodeStack", providers.gradleProperty("teavm.tests.decodeStack"))
+ maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
+}
\ No newline at end of file
diff --git a/tests/pom.xml b/tests/pom.xml
deleted file mode 100644
index 4346d2b01..000000000
--- a/tests/pom.xml
+++ /dev/null
@@ -1,154 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
-
- teavm-tests
-
- TeaVM tests
- Project containing TeaVM tests, as it is impossible to test each module separately
-
-
-
- org.teavm
- teavm-core
- ${project.version}
-
-
- org.teavm
- teavm-classlib
- ${project.version}
-
-
- org.teavm
- teavm-platform
- ${project.version}
-
-
- org.teavm
- teavm-jso-apis
- ${project.version}
-
-
- org.teavm
- teavm-metaprogramming-impl
- ${project.version}
-
-
- junit
- junit
- test
-
-
- org.teavm
- teavm-tooling
- ${project.version}
- test
-
-
- org.teavm
- teavm-junit
- ${project.version}
- test
-
-
- com.carrotsearch
- hppc
- test
-
-
- org.ow2.asm
- asm-util
- test
-
-
- org.ow2.asm
- asm-commons
- test
-
-
- org.mozilla
- rhino
- test
-
-
- org.testng
- testng
- test
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
-
- ${java-tests.version}
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- org.apache.maven.surefire
- surefire-junit47
- ${maven-surefire-plugin.version}
-
-
-
- -Xmx512m
- 4
- true
-
- ${project.build.directory}/js-tests
- true
- true
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../checkstyle.xml
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
\ No newline at end of file
diff --git a/tests/src/test/java/org/teavm/dependency/ClassValueTest.java b/tests/src/test/java/org/teavm/dependency/ClassValueTest.java
index aa7dd79c6..4f3045803 100644
--- a/tests/src/test/java/org/teavm/dependency/ClassValueTest.java
+++ b/tests/src/test/java/org/teavm/dependency/ClassValueTest.java
@@ -17,7 +17,7 @@ package org.teavm.dependency;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import org.apache.commons.io.output.ByteArrayOutputStream;
+import java.io.ByteArrayOutputStream;
import org.junit.Test;
import org.teavm.backend.javascript.JavaScriptTarget;
import org.teavm.model.MethodReference;
diff --git a/tools/c-incremental/build.gradle.kts b/tools/c-incremental/build.gradle.kts
new file mode 100644
index 000000000..167ada1e4
--- /dev/null
+++ b/tools/c-incremental/build.gradle.kts
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "Incremental generator of C code"
+
+dependencies {
+ implementation(project(":core"))
+ implementation(project(":tools:core"))
+}
+
+teavmPublish {
+ artifactId = "teavm-c-inremental"
+}
\ No newline at end of file
diff --git a/tools/c-incremental/pom.xml b/tools/c-incremental/pom.xml
deleted file mode 100644
index 986002ddb..000000000
--- a/tools/c-incremental/pom.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- teavm-c-incremental
-
- TeaVM Incremental C builder
- Incremental generator of C code
-
-
-
- commons-io
- commons-io
- true
-
-
- org.ow2.asm
- asm-commons
- true
-
-
- org.ow2.asm
- asm-util
- true
-
-
- com.carrotsearch
- hppc
- true
-
-
- org.mozilla
- rhino
- true
-
-
-
- org.teavm
- teavm-core
- ${project.version}
-
-
- org.teavm
- teavm-tooling
- ${project.version}
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
\ No newline at end of file
diff --git a/tools/chrome-rdp/build.gradle.kts b/tools/chrome-rdp/build.gradle.kts
new file mode 100644
index 000000000..02a3ec947
--- /dev/null
+++ b/tools/chrome-rdp/build.gradle.kts
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "Debugging backend for Google Chrome RDP"
+
+dependencies {
+ implementation(project(":core"))
+ implementation(libs.jetty.server)
+ implementation(libs.jetty.websocket.server)
+ implementation(libs.slf4j)
+ implementation(libs.javax.websocket)
+ implementation(libs.hppc)
+ implementation(libs.jackson.databind)
+}
+
+teavmPublish {
+ artifactId = "teavm-chrome-rdp"
+}
\ No newline at end of file
diff --git a/tools/chrome-rdp/pom.xml b/tools/chrome-rdp/pom.xml
deleted file mode 100644
index 0d817e463..000000000
--- a/tools/chrome-rdp/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- teavm-chrome-rdp
-
- TeaVM debugging backend for Google Chrome RDP
- TeaVM debugging backend for Google Chrome RDP
-
-
-
- org.eclipse.jetty
- jetty-server
-
-
- org.eclipse.jetty.websocket
- javax-websocket-server-impl
-
-
- org.teavm
- teavm-core
- ${project.version}
-
-
- org.slf4j
- slf4j-api
-
-
- javax.websocket
- javax.websocket-api
-
-
- com.carrotsearch
- hppc
- true
-
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
\ No newline at end of file
diff --git a/tools/classlib-comparison-gen/build.gradle.kts b/tools/classlib-comparison-gen/build.gradle.kts
new file mode 100644
index 000000000..4742cda5c
--- /dev/null
+++ b/tools/classlib-comparison-gen/build.gradle.kts
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+plugins {
+ java
+}
+
+description = "Tool that generates HTML report about TeaVM support of classes from Java standard library"
+
+dependencies {
+ implementation(project(":classlib"))
+ implementation(project(":core"))
+ implementation(libs.asm)
+}
diff --git a/tools/classlib-comparison-gen/pom.xml b/tools/classlib-comparison-gen/pom.xml
deleted file mode 100644
index d7eaa870d..000000000
--- a/tools/classlib-comparison-gen/pom.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- teavm-classlib-comparison-gen
-
- Tool that generates HTML report about supported classes in TeaVM
- Tool that generates HTML report about supported classes in TeaVM
-
-
-
- org.teavm
- teavm-classlib
- ${project.version}
- runtime
-
-
-
- org.ow2.asm
- asm-commons
- true
-
-
- org.ow2.asm
- asm-util
- true
-
-
- commons-io
- commons-io
- true
-
-
- com.carrotsearch
- hppc
- 0.7.3
- true
-
-
- org.teavm
- teavm-core
- ${project.version}
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.0
-
-
- 9
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
\ No newline at end of file
diff --git a/tools/classlib-comparison-gen/src/main/java/org/teavm/tools/classlibcomparison/JCLComparisonBuilder.java b/tools/classlib-comparison-gen/src/main/java/org/teavm/tools/classlibcomparison/JCLComparisonBuilder.java
index 8caa68b8a..b5cb9f9ec 100644
--- a/tools/classlib-comparison-gen/src/main/java/org/teavm/tools/classlibcomparison/JCLComparisonBuilder.java
+++ b/tools/classlib-comparison-gen/src/main/java/org/teavm/tools/classlibcomparison/JCLComparisonBuilder.java
@@ -19,18 +19,15 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
import java.io.OutputStreamWriter;
-import java.io.Reader;
import java.io.Writer;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystemNotFoundException;
+import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
@@ -38,7 +35,6 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.commons.io.IOUtils;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Type;
import org.teavm.model.ReferenceCache;
@@ -72,7 +68,7 @@ public class JCLComparisonBuilder {
System.err.println("Usage: -output ");
System.exit(1);
}
- JCLComparisonBuilder builder = new JCLComparisonBuilder();
+ var builder = new JCLComparisonBuilder();
for (int i = 0; i < args.length; ++i) {
if (args[i].equals("-output")) {
@@ -84,7 +80,7 @@ public class JCLComparisonBuilder {
}
public void buildComparisonReport() throws IOException {
- List packages = buildModel();
+ var packages = buildModel();
processModel(packages);
new File(outputDirectory).mkdirs();
copyResource("html/class_obj.png");
@@ -122,19 +118,18 @@ public class JCLComparisonBuilder {
}
private List buildModel() throws IOException {
- Map packageMap = new HashMap<>();
- ClasspathClassHolderSource classSource = new ClasspathClassHolderSource(classLoader, new ReferenceCache());
+ var packageMap = new HashMap();
+ var classSource = new ClasspathClassHolderSource(classLoader, new ReferenceCache());
visitor = new JCLComparisonVisitor(classSource, packageMap);
try {
- Path p = Paths.get(URI.create("jrt:/modules/java.base/java/"));
+ var fs = FileSystems.getFileSystem(URI.create("jrt:/"));
+ var p = fs.getPath("modules/java.base/java");
Files.walkFileTree(p, new SimpleFileVisitor<>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (validateName(file.getFileName().toString())) {
try (InputStream input = Files.newInputStream(file)) {
compareClass(input);
- } catch (IOException e) {
- throw new RuntimeException(e);
}
}
return FileVisitResult.CONTINUE;
@@ -195,25 +190,21 @@ public class JCLComparisonBuilder {
}
private void compareClass(InputStream input) throws IOException {
- byte[] buffer = IOUtils.toByteArray(input);
- ClassReader reader = new ClassReader(buffer);
+ var buffer = input.readAllBytes();
+ var reader = new ClassReader(buffer);
reader.accept(visitor, 0);
}
private void copyResource(String name) throws IOException {
String simpleName = name.substring(name.lastIndexOf('/') + 1);
- try (InputStream input = classLoader.getResourceAsStream(name);
- OutputStream output = new FileOutputStream(new File(outputDirectory, simpleName))) {
- IOUtils.copy(input, output);
+ try (var input = classLoader.getResourceAsStream(name);
+ var output = new FileOutputStream(new File(outputDirectory, simpleName))) {
+ input.transferTo(output);
}
}
private void generateHtml(Writer out, List packages) throws IOException {
- String template;
- try (Reader reader = new InputStreamReader(classLoader.getResourceAsStream("html/jcl.html"),
- StandardCharsets.UTF_8)) {
- template = IOUtils.toString(reader);
- }
+ var template = readResourceString("html/jcl.html");
int placeholderIndex = template.indexOf(TEMPLATE_PLACEHOLDER);
String header = template.substring(0, placeholderIndex);
String footer = template.substring(placeholderIndex + TEMPLATE_PLACEHOLDER.length());
@@ -243,11 +234,7 @@ public class JCLComparisonBuilder {
}
private void generatePackageHtml(Writer out, JCLPackage pkg) throws IOException {
- String template;
- try (Reader reader = new InputStreamReader(classLoader.getResourceAsStream("html/jcl-class.html"),
- StandardCharsets.UTF_8)) {
- template = IOUtils.toString(reader);
- }
+ var template = readResourceString("html/jcl-class.html");
template = template.replace("${CLASSNAME}", pkg.name);
int placeholderIndex = template.indexOf(TEMPLATE_PLACEHOLDER);
String header = template.substring(0, placeholderIndex);
@@ -279,11 +266,7 @@ public class JCLComparisonBuilder {
}
private void generateClassHtml(Writer out, JCLPackage pkg, JCLClass cls) throws IOException {
- String template;
- try (Reader reader = new InputStreamReader(classLoader.getResourceAsStream("html/jcl-class.html"),
- StandardCharsets.UTF_8)) {
- template = IOUtils.toString(reader);
- }
+ var template = readResourceString("html/jcl-class.html");
template = template.replace("${CLASSNAME}", pkg.name + "." + cls.name);
int placeholderIndex = template.indexOf(TEMPLATE_PLACEHOLDER);
String header = template.substring(0, placeholderIndex);
@@ -336,6 +319,12 @@ public class JCLComparisonBuilder {
out.write(footer);
}
+ private String readResourceString(String name) throws IOException {
+ try (var input = classLoader.getResourceAsStream(name)) {
+ return new String(input.readAllBytes(), StandardCharsets.UTF_8);
+ }
+ }
+
private String printType(Type type) {
switch (type.getSort()) {
case Type.VOID:
diff --git a/tools/classlib-comparison-gen/src/main/java/org/teavm/tools/classlibcomparison/JCLComparisonVisitor.java b/tools/classlib-comparison-gen/src/main/java/org/teavm/tools/classlibcomparison/JCLComparisonVisitor.java
index f1a12f0b9..85e08581d 100644
--- a/tools/classlib-comparison-gen/src/main/java/org/teavm/tools/classlibcomparison/JCLComparisonVisitor.java
+++ b/tools/classlib-comparison-gen/src/main/java/org/teavm/tools/classlibcomparison/JCLComparisonVisitor.java
@@ -19,6 +19,7 @@ import java.util.Map;
import org.objectweb.asm.*;
import org.teavm.model.*;
import org.teavm.model.ClassReader;
+import org.teavm.parsing.AsmUtil;
class JCLComparisonVisitor extends ClassVisitor {
private Map packageMap;
@@ -28,7 +29,7 @@ class JCLComparisonVisitor extends ClassVisitor {
private JCLClass jclClass;
public JCLComparisonVisitor(ClassReaderSource classSource, Map packageMap) {
- super(Opcodes.ASM7);
+ super(AsmUtil.API_VERSION);
this.classSource = classSource;
this.packageMap = packageMap;
}
diff --git a/tools/cli/build.gradle.kts b/tools/cli/build.gradle.kts
new file mode 100644
index 000000000..5bd72442b
--- /dev/null
+++ b/tools/cli/build.gradle.kts
@@ -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.
+ */
+
+plugins {
+ `java-library`
+ shadowApply
+}
+
+description = "Command line tools"
+
+dependencies {
+ implementation(project(":tools:core"))
+ implementation(project(":tools:devserver"))
+ implementation(project(":tools:c-incremental"))
+ implementation(libs.commons.cli)
+
+ runtimeOnly(project(":classlib"))
+ runtimeOnly(project(":metaprogramming:impl"))
+ runtimeOnly(project(":jso:impl"))
+}
+
+tasks {
+ shadowJar {
+ mergeServiceFiles()
+ manifest {
+ attributes(
+ "Main-Class" to "org.teavm.cli.TeaVMRunner"
+ )
+ }
+ }
+ assemble {
+ dependsOn(shadowJar)
+ }
+}
\ No newline at end of file
diff --git a/tools/cli/pom.xml b/tools/cli/pom.xml
deleted file mode 100644
index 7a2f556bd..000000000
--- a/tools/cli/pom.xml
+++ /dev/null
@@ -1,170 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- teavm-cli
-
- TeaVM CLI
- TeaVM command line tools
-
-
-
- org.teavm
- teavm-tooling
- ${project.version}
-
-
- commons-cli
- commons-cli
-
-
- org.teavm
- teavm-classlib
- ${project.version}
- runtime
-
-
- org.teavm
- teavm-metaprogramming-api
- ${project.version}
- runtime
-
-
- org.teavm
- teavm-metaprogramming-impl
- ${project.version}
- runtime
-
-
- org.teavm
- teavm-devserver
- ${project.version}
-
-
- org.teavm
- teavm-c-incremental
- ${project.version}
-
-
- org.teavm
- teavm-jso-impl
- ${project.version}
- runtime
-
-
-
- commons-io
- commons-io
- true
-
-
- org.ow2.asm
- asm-commons
- true
-
-
- org.ow2.asm
- asm-util
- true
-
-
- com.carrotsearch
- hppc
- true
-
-
- org.mozilla
- rhino
- true
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
- package
-
- shade
-
-
-
-
- junit:junit
- com.fasterxml.jackson.core:jackson-annotations
- org.mozilla:rhino
- joda-time:joda-time
-
-
-
-
-
- org.teavm.cli.TeaVMRunner
-
-
-
-
- org.objectweb.asm
- org.teavm.asm
-
-
- org.mozilla
- org.teavm.rhino
-
-
- com.carrotsearch.hppc
- org.teavm.hppc
-
-
- org.apache.commons
- org.teavm.apachecommons
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tools/core/build.gradle.kts b/tools/core/build.gradle.kts
new file mode 100644
index 000000000..dbb34a34d
--- /dev/null
+++ b/tools/core/build.gradle.kts
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "API that helps to create tooling"
+
+dependencies {
+ compileOnly(libs.jackson.annotations)
+ compileOnly(project(":jso:apis"))
+
+ api(project(":core"))
+
+ implementation(libs.commons.io)
+}
+
+teavmPublish {
+ artifactId = "teavm-tooling"
+}
\ No newline at end of file
diff --git a/tools/core/pom.xml b/tools/core/pom.xml
deleted file mode 100644
index d85bc5819..000000000
--- a/tools/core/pom.xml
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- teavm-tooling
-
- TeaVM tooling core
- TeaVM API that helps to create tooling
-
-
-
- org.teavm
- teavm-core
- ${project.version}
-
-
- com.fasterxml.jackson.core
- jackson-annotations
- true
-
-
- commons-io
- commons-io
- true
-
-
- org.teavm
- teavm-jso-apis
- ${project.version}
- provided
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
- package
-
- shade
-
-
-
-
- org.teavm:teavm-tooling
-
-
-
-
- org.objectweb.asm
- org.teavm.asm
-
-
- org.mozilla
- org.teavm.rhino
-
-
- com.carrotsearch.hppc
- org.teavm.hppc
-
-
- org.apache.commons
- org.teavm.apachecommons
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tools/deobfuscator-js/build.gradle.kts b/tools/deobfuscator-js/build.gradle.kts
new file mode 100644
index 000000000..11acb0b4c
--- /dev/null
+++ b/tools/deobfuscator-js/build.gradle.kts
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+}
+
+description = "JavaScript deobfuscator"
+
+configurations {
+ val teavmCompile = create("teavmCompile")
+ compileClasspath.configure {
+ extendsFrom(teavmCompile)
+ }
+ create("js")
+}
+
+dependencies {
+ compileOnly(project(":jso:apis"))
+ "teavmCompile"(project(":classlib"))
+ "teavmCompile"(project(":tools:core"))
+}
+
+val generateJs by tasks.register("generateJs") {
+ outputs.dir(File(buildDir, "teavm"))
+ dependsOn(tasks.classes)
+ classpath += configurations["teavmCompile"]
+ classpath += java.sourceSets.main.get().output.classesDirs
+ mainClass.set("org.teavm.tooling.deobfuscate.js.Compiler")
+ args(
+ "org.teavm.tooling.deobfuscate.js.Deobfuscator",
+ "\$teavm_deobfuscator",
+ File(buildDir, "teavm").absolutePath,
+ "deobfuscator.js"
+ )
+}
+
+val generateLibJs by tasks.register("generateLibJs") {
+ outputs.dir(File(buildDir, "teavm-lib"))
+ dependsOn(tasks.classes)
+ classpath += configurations["teavmCompile"]
+ classpath += java.sourceSets.main.get().output.classesDirs
+ mainClass.set("org.teavm.tooling.deobfuscate.js.Compiler")
+ args(
+ "org.teavm.tooling.deobfuscate.js.DeobfuscatorLib",
+ "\$teavm_deobfuscator",
+ File(buildDir, "teavm-lib").absolutePath,
+ "deobfuscator-lib.js",
+ )
+}
+
+val zipWithJs by tasks.register("zipWithJs") {
+ dependsOn(generateJs, generateLibJs)
+ archiveClassifier.set("js")
+ from(File(buildDir, "teavm"), File(buildDir, "teavm-lib"))
+ entryCompression = ZipEntryCompression.DEFLATED
+}
+
+tasks.assemble.configure {
+ dependsOn(zipWithJs)
+}
+
+artifacts.add("js", zipWithJs)
\ No newline at end of file
diff --git a/tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/Compiler.java b/tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/Compiler.java
new file mode 100644
index 000000000..c47b0a35c
--- /dev/null
+++ b/tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/Compiler.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.tooling.deobfuscate.js;
+
+import java.io.File;
+import org.teavm.tooling.ConsoleTeaVMToolLog;
+import org.teavm.tooling.TeaVMProblemRenderer;
+import org.teavm.tooling.TeaVMTargetType;
+import org.teavm.tooling.TeaVMTool;
+import org.teavm.tooling.TeaVMToolException;
+import org.teavm.vm.TeaVMOptimizationLevel;
+
+public final class Compiler {
+ private Compiler() {
+ }
+
+ public static void main(String[] args) throws TeaVMToolException {
+ var tool = new TeaVMTool();
+ var log = new ConsoleTeaVMToolLog(false);
+ tool.setTargetType(TeaVMTargetType.JAVASCRIPT);
+ tool.setMainClass(args[0]);
+ tool.setEntryPointName(args[1]);
+ tool.setTargetDirectory(new File(args[2]));
+ tool.setTargetFileName(args[3]);
+ tool.setObfuscated(true);
+ tool.setOptimizationLevel(TeaVMOptimizationLevel.ADVANCED);
+
+ tool.generate();
+ TeaVMProblemRenderer.describeProblems(tool.getDependencyInfo().getCallGraph(), tool.getProblemProvider(), log);
+ if (!tool.getProblemProvider().getSevereProblems().isEmpty()) {
+ System.exit(1);
+ }
+ }
+}
diff --git a/tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscateFunction.java b/tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscateFunction.java
similarity index 100%
rename from tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscateFunction.java
rename to tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscateFunction.java
diff --git a/tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/Deobfuscator.java b/tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/Deobfuscator.java
similarity index 100%
rename from tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/Deobfuscator.java
rename to tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/Deobfuscator.java
diff --git a/tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscatorCallback.java b/tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscatorCallback.java
similarity index 100%
rename from tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscatorCallback.java
rename to tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscatorCallback.java
diff --git a/tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscatorJs.java b/tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscatorJs.java
similarity index 100%
rename from tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscatorJs.java
rename to tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscatorJs.java
diff --git a/tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscatorLib.java b/tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscatorLib.java
similarity index 100%
rename from tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscatorLib.java
rename to tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/DeobfuscatorLib.java
diff --git a/tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/Frame.java b/tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/Frame.java
similarity index 100%
rename from tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/Frame.java
rename to tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/Frame.java
diff --git a/tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/Int8ArrayInputStream.java b/tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/Int8ArrayInputStream.java
similarity index 100%
rename from tools/core/src/main/java/org/teavm/tooling/deobfuscate/js/Int8ArrayInputStream.java
rename to tools/deobfuscator-js/src/main/java/org/teavm/tooling/deobfuscate/js/Int8ArrayInputStream.java
diff --git a/tools/devserver/build.gradle.kts b/tools/devserver/build.gradle.kts
new file mode 100644
index 000000000..197f51f16
--- /dev/null
+++ b/tools/devserver/build.gradle.kts
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "Development server that builds and serves JavaScript files"
+
+configurations {
+ create("js")
+}
+
+dependencies {
+ implementation(project(":core"))
+ implementation(project(":tools:core"))
+ implementation(libs.jetty.server)
+ implementation(libs.jetty.websocket.server)
+ implementation(libs.jetty.websocket.client)
+ implementation(libs.javax.servlet)
+ implementation(libs.jackson.databind)
+ implementation(libs.httpclient)
+ implementation(libs.commons.io)
+
+ "js"(project(":tools:deobfuscator-js", "js"))
+}
+
+tasks.withType().configureEach {
+ if (name == "relocateJar") {
+ dependsOn(configurations["js"])
+ from(provider { configurations["js"].map { zipTree(it) } }) {
+ include("deobfuscator.js")
+ into("teavm/devserver")
+ }
+ }
+}
+
+teavmPublish {
+ artifactId = "teavm-devserver"
+}
\ No newline at end of file
diff --git a/tools/devserver/pom.xml b/tools/devserver/pom.xml
deleted file mode 100644
index 13568b7eb..000000000
--- a/tools/devserver/pom.xml
+++ /dev/null
@@ -1,155 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- teavm-devserver
-
- TeaVM Dev Sever
- TeaVM development server that builds and serves JavaScript files
-
-
-
- commons-io
- commons-io
- true
-
-
- org.ow2.asm
- asm-commons
- true
-
-
- org.ow2.asm
- asm-util
- true
-
-
- com.carrotsearch
- hppc
- true
-
-
- org.mozilla
- rhino
- true
-
-
-
- org.teavm
- teavm-core
- ${project.version}
-
-
- org.teavm
- teavm-tooling
- ${project.version}
-
-
-
- org.eclipse.jetty
- jetty-server
-
-
- org.eclipse.jetty.websocket
- javax-websocket-server-impl
-
-
- org.eclipse.jetty.websocket
- websocket-client
-
-
- javax.servlet
- javax.servlet-api
- 3.1.0
-
-
-
- com.fasterxml.jackson.core
- jackson-databind
- true
-
-
-
- org.apache.httpcomponents
- httpclient
- 4.5.6
-
-
-
-
-
-
- org.teavm
- teavm-maven-plugin
- ${project.version}
-
-
- org.teavm
- teavm-jso-impl
- ${project.version}
-
-
- org.teavm
- teavm-classlib
- ${project.version}
-
-
-
-
- compile-deobfuscator
-
- compile
-
- process-classes
-
- ${project.build.directory}/classes/teavm/devserver
- deobfuscator.js
- true
- ADVANCED
- org.teavm.tooling.deobfuscate.js.Deobfuscator
- $teavm_deobfuscator
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
-
\ No newline at end of file
diff --git a/tools/eclipse/core-plugin/dep-pom.xml b/tools/eclipse/core-plugin/dep-pom.xml
deleted file mode 100644
index baed2fb43..000000000
--- a/tools/eclipse/core-plugin/dep-pom.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-
-
- 4.0.0
-
- org.teavm
- teavm-eclipse-core-deps
- 0.6.0-SNAPSHOT
- pom
-
- TeaVM dependencies for Eclipse plugin
-
-
- 9.2.1.v20140609
-
-
-
-
- javax.interceptor
- javax.interceptor-api
- 1.2
-
-
- javax.enterprise
- cdi-api
- 1.2
-
-
- javax.transaction
- javax.transaction-api
- 1.2
-
-
- javax.annotation
- javax.annotation-api
- 1.2
-
-
- org.apache.aries.spifly
- org.apache.aries.spifly.dynamic.bundle
- 1.0.1
-
-
- org.eclipse.jetty.websocket
- javax-websocket-server-impl
- ${jetty.version}
-
-
- org.ow2.asm
- asm
-
-
- org.ow2.asm
- asm-common
-
-
-
-
- ch.qos.logback
- logback-classic
- 1.1.2
-
-
- org.teavm
- teavm-core
- ${project.version}
-
-
- org.teavm
- teavm-tooling
- ${project.version}
-
-
- org.teavm
- teavm-chrome-rdp
- ${project.version}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
- 2.9
-
-
- copy-dependencies
- prepare-package
-
- copy-dependencies
-
-
- ${project.basedir}/lib
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tools/eclipse/core-plugin/pom.xml b/tools/eclipse/core-plugin/pom.xml
deleted file mode 100644
index 8d091de95..000000000
--- a/tools/eclipse/core-plugin/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm-eclipse
- 0.6.0-SNAPSHOT
-
- teavm-eclipse-core-plugin
- eclipse-plugin
-
- TeaVM core packages for Eclipse
- A core plugin for Eclipse that contains TeaVM itself
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- 1.3.2
-
-
- copy-dependencies
- process-sources
-
- exec
-
-
- mvn
-
- -f
- dep-pom.xml
- clean
- package
- -Dmaven.repo.local=${settings.localRepository}
- -B
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tools/eclipse/feature/pom.xml b/tools/eclipse/feature/pom.xml
deleted file mode 100644
index 851f1e5d8..000000000
--- a/tools/eclipse/feature/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.teavm
- teavm-eclipse
- 0.6.0-SNAPSHOT
-
- teavm-eclipse-feature
-
- eclipse-feature
-
-
-
- org.teavm
- teavm-eclipse-core-plugin
- ${project.version}
-
-
- org.teavm
- teavm-eclipse-plugin
- ${project.version}
-
-
-
\ No newline at end of file
diff --git a/tools/eclipse/m2e-feature/pom.xml b/tools/eclipse/m2e-feature/pom.xml
deleted file mode 100644
index 5463a2175..000000000
--- a/tools/eclipse/m2e-feature/pom.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.teavm
- teavm-eclipse
- 0.6.0-SNAPSHOT
-
- teavm-eclipse-m2e-feature
-
- eclipse-feature
-
-
-
- org.teavm
- teavm-eclipse-m2e-plugin
- ${project.version}
-
-
-
\ No newline at end of file
diff --git a/tools/eclipse/m2e-plugin/pom.xml b/tools/eclipse/m2e-plugin/pom.xml
deleted file mode 100644
index 696d8ffda..000000000
--- a/tools/eclipse/m2e-plugin/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.teavm
- teavm-eclipse
- 0.6.0-SNAPSHOT
-
- teavm-eclipse-m2e-plugin
-
- eclipse-plugin
-
- TeaVM m2e plugin
- Contains plugin that automatically configures TeaVM builder from pom.xml
-
-
-
- org.teavm
- teavm-eclipse-plugin
- ${project.version}
-
-
-
-
\ No newline at end of file
diff --git a/tools/eclipse/plugin/pom.xml b/tools/eclipse/plugin/pom.xml
deleted file mode 100644
index b168931e4..000000000
--- a/tools/eclipse/plugin/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.teavm
- teavm-eclipse
- 0.6.0-SNAPSHOT
-
- teavm-eclipse-plugin
-
- eclipse-plugin
-
- TeaVM Eclipse plugin
- Contains TeaVM builder and TeaVM debugger for Eclipse
-
-
-
- org.teavm
- teavm-eclipse-core-plugin
- ${project.version}
-
-
-
-
diff --git a/tools/eclipse/pom.xml b/tools/eclipse/pom.xml
deleted file mode 100644
index 0cecb0bcd..000000000
--- a/tools/eclipse/pom.xml
+++ /dev/null
@@ -1,108 +0,0 @@
-
-
- 4.0.0
-
- org.teavm
- teavm-eclipse
- pom
- 0.6.0-SNAPSHOT
-
- TeaVM Eclipse integration
- Aggregate project containing all plugins for integration TeaVM with Eclipse
-
-
- http://download.eclipse.org/releases/mars
- 1.0.0
-
-
-
- core-plugin
- plugin
- m2e-plugin
- feature
- m2e-feature
- updatesite
-
-
-
-
- eclipse
- ${p2-repo.url}
- p2
-
-
-
-
-
-
-
- org.eclipse.tycho
- tycho-versions-plugin
- ${tycho.version}
-
-
-
-
-
- org.eclipse.tycho
- tycho-maven-plugin
- ${tycho.version}
- true
-
-
- org.eclipse.tycho
- tycho-packaging-plugin
- ${tycho.version}
-
-
- org.eclipse.tycho
- target-platform-configuration
- ${tycho.version}
-
-
-
- linux
- gtk
- x86
-
-
- linux
- gtk
- x86_64
-
-
- win32
- win32
- x86
-
-
- win32
- win32
- x86_64
-
-
- macosx
- cocoa
- x86_64
-
-
-
-
-
-
-
diff --git a/tools/eclipse/updatesite/pom.xml b/tools/eclipse/updatesite/pom.xml
deleted file mode 100644
index 3ee433121..000000000
--- a/tools/eclipse/updatesite/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
- 4.0.0
-
-
- org.teavm
- teavm-eclipse
- 0.6.0-SNAPSHOT
-
- teavm-eclipse-updatesite
-
- eclipse-repository
-
-
-
- org.teavm
- teavm-eclipse-feature
- ${project.version}
-
-
- org.teavm
- teavm-eclipse-m2e-feature
- ${project.version}
-
-
-
\ No newline at end of file
diff --git a/tools/gradle/build.gradle.kts b/tools/gradle/build.gradle.kts
new file mode 100644
index 000000000..546c63345
--- /dev/null
+++ b/tools/gradle/build.gradle.kts
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-gradle-plugin`
+ publishing
+ `maven-publish`
+}
+
+dependencies {
+ implementation(project(":core"))
+ implementation(project(":tools:core"))
+}
+
+gradlePlugin {
+ plugins {
+ create("TeaVMPlugin") {
+ id = "org.teavm"
+ implementationClass = "org.teavm.gradle.TeaVMPlugin"
+ }
+ create("TeaVMLibraryPlugin") {
+ id = "org.teavm.library"
+ implementationClass = "org.teavm.gradle.TeaVMLibraryPlugin"
+ }
+ }
+}
+
+fun findArtifactCoordinates(path: String): String {
+ val project = project(path)
+ val publishing = project.extensions.findByType()
+ return publishing
+ ?.publications
+ ?.filterIsInstance()
+ ?.firstOrNull()
+ ?.let { "${it.groupId}:${it.artifactId}:${it.version}" }
+ ?: "${project.group}:${project.name}:${project.version}"
+}
+
+val configPath = project.layout.buildDirectory.dir("generated/sources/config")
+
+val createConfig by tasks.registering {
+ outputs.dir(configPath)
+ val baseDir = configPath.get().asFile
+ val jso = findArtifactCoordinates(":jso:core")
+ val jsoApis = findArtifactCoordinates(":jso:apis")
+ val interop = findArtifactCoordinates(":interop:core")
+ val metaprogramming = findArtifactCoordinates(":metaprogramming:api")
+ val classlib = findArtifactCoordinates(":classlib")
+ val jsoImpl = findArtifactCoordinates(":jso:impl")
+ val metaprogrammingImpl = findArtifactCoordinates(":metaprogramming:impl")
+ val tools = findArtifactCoordinates(":tools:core")
+ val junit = findArtifactCoordinates(":tools:junit")
+ doLast {
+ val file = File(baseDir, "org/teavm/gradle/config/ArtifactCoordinates.java")
+ file.parentFile.mkdirs()
+ file.writeText("""
+ package org.teavm.gradle.config;
+
+ public final class ArtifactCoordinates {
+ public static final String JSO = "$jso";
+ public static final String JSO_APIS = "$jsoApis";
+ public static final String INTEROP = "$interop";
+ public static final String METAPROGRAMMING = "$metaprogramming";
+
+ public static final String CLASSLIB = "$classlib";
+ public static final String JSO_IMPL = "$jsoImpl";
+ public static final String METAPROGRAMMING_IMPL = "$metaprogrammingImpl";
+ public static final String JUNIT = "$junit";
+
+ public static final String TOOLS = "$tools";
+
+ private ArtifactCoordinates() {
+ }
+ }
+ """.trimIndent())
+ }
+}
+
+tasks.compileJava.configure { dependsOn(createConfig) }
+
+sourceSets.main.configure { java.srcDir(configPath) }
+
+tasks.withType {
+ exclude("org/teavm/gradle/config/*")
+}
+
+publishing {
+ publications {
+ create("pluginMaven") {
+ groupId = "org.teavm"
+ artifactId = "teavm-gradle-plugin"
+ }
+ }
+ repositories {
+ mavenLocal()
+ }
+}
+
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/GenerateCTask.java b/tools/gradle/src/main/java/org/teavm/gradle/GenerateCTask.java
new file mode 100644
index 000000000..cde3fc95f
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/GenerateCTask.java
@@ -0,0 +1,58 @@
+/*
+ * 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.provider.Property;
+import org.gradle.api.tasks.Input;
+import org.teavm.tooling.TeaVMTargetType;
+import org.teavm.tooling.builder.BuildStrategy;
+
+public abstract class GenerateCTask extends TeaVMTask {
+ private static final int MB = 1024 * 1024;
+
+ public GenerateCTask() {
+ getMinHeapSize().convention(1);
+ getMaxHeapSize().convention(16);
+ getHeapDump().convention(false);
+ getShortFileNames().convention(true);
+ getObfuscated().convention(true);
+ }
+
+ @Input
+ public abstract Property getMinHeapSize();
+
+ @Input
+ public abstract Property getMaxHeapSize();
+
+ @Input
+ public abstract Property getHeapDump();
+
+ @Input
+ public abstract Property getShortFileNames();
+
+ @Input
+ public abstract Property getObfuscated();
+
+ @Override
+ protected void setupBuilder(BuildStrategy builder) {
+ builder.setTargetType(TeaVMTargetType.C);
+ builder.setMinHeapSize(getMinHeapSize().get() * MB);
+ builder.setMaxHeapSize(getMaxHeapSize().get() * MB);
+ builder.setHeapDump(getHeapDump().get());
+ builder.setShortFileNames(getShortFileNames().get());
+ builder.setObfuscated(getObfuscated().get());
+ }
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/GenerateJavaScriptTask.java b/tools/gradle/src/main/java/org/teavm/gradle/GenerateJavaScriptTask.java
new file mode 100644
index 000000000..1131193e1
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/GenerateJavaScriptTask.java
@@ -0,0 +1,56 @@
+/*
+ * 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.provider.Property;
+import org.gradle.api.tasks.Input;
+import org.gradle.api.tasks.Optional;
+import org.teavm.tooling.TeaVMTargetType;
+import org.teavm.tooling.builder.BuildStrategy;
+
+public abstract class GenerateJavaScriptTask extends TeaVMTask {
+ public GenerateJavaScriptTask() {
+ getObfuscated().convention(true);
+ getStrict().convention(false);
+ getSourceMap().convention(false);
+ getEntryPointName().convention("main");
+ }
+
+ @Input
+ @Optional
+ public abstract Property getObfuscated();
+
+ @Input
+ @Optional
+ public abstract Property getStrict();
+
+ @Input
+ @Optional
+ public abstract Property getSourceMap();
+
+ @Input
+ @Optional
+ public abstract Property getEntryPointName();
+
+ @Override
+ protected void setupBuilder(BuildStrategy builder) {
+ builder.setTargetType(TeaVMTargetType.JAVASCRIPT);
+ builder.setObfuscated(getObfuscated().get());
+ builder.setStrict(getStrict().get());
+ builder.setSourceMapsFileGenerated(getSourceMap().get());
+ builder.setEntryPointName(getEntryPointName().get());
+ }
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/GenerateWasiTask.java b/tools/gradle/src/main/java/org/teavm/gradle/GenerateWasiTask.java
new file mode 100644
index 000000000..b18934b84
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/GenerateWasiTask.java
@@ -0,0 +1,43 @@
+/*
+ * 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.provider.Property;
+import org.gradle.api.tasks.Input;
+import org.teavm.tooling.TeaVMTargetType;
+import org.teavm.tooling.builder.BuildStrategy;
+
+public abstract class GenerateWasiTask extends TeaVMTask {
+ private static final int MB = 1024 * 1024;
+
+ public GenerateWasiTask() {
+ getMinHeapSize().convention(1);
+ getMaxHeapSize().convention(16);
+ }
+
+ @Input
+ public abstract Property getMinHeapSize();
+
+ @Input
+ public abstract Property getMaxHeapSize();
+
+ @Override
+ protected void setupBuilder(BuildStrategy builder) {
+ builder.setTargetType(TeaVMTargetType.WEBASSEMBLY_WASI);
+ builder.setMinHeapSize(getMinHeapSize().get() * MB);
+ builder.setMaxHeapSize(getMaxHeapSize().get() * MB);
+ }
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/GenerateWasmTask.java b/tools/gradle/src/main/java/org/teavm/gradle/GenerateWasmTask.java
new file mode 100644
index 000000000..cdf38d187
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/GenerateWasmTask.java
@@ -0,0 +1,43 @@
+/*
+ * 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.provider.Property;
+import org.gradle.api.tasks.Input;
+import org.teavm.tooling.TeaVMTargetType;
+import org.teavm.tooling.builder.BuildStrategy;
+
+public abstract class GenerateWasmTask extends TeaVMTask {
+ private static final int MB = 1024 * 1024;
+
+ public GenerateWasmTask() {
+ getMinHeapSize().convention(1);
+ getMaxHeapSize().convention(16);
+ }
+
+ @Input
+ public abstract Property getMinHeapSize();
+
+ @Input
+ public abstract Property getMaxHeapSize();
+
+ @Override
+ protected void setupBuilder(BuildStrategy builder) {
+ builder.setTargetType(TeaVMTargetType.WEBASSEMBLY);
+ builder.setMinHeapSize(getMinHeapSize().get() * MB);
+ builder.setMaxHeapSize(getMaxHeapSize().get() * MB);
+ }
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/GradleTeaVMToolLog.java b/tools/gradle/src/main/java/org/teavm/gradle/GradleTeaVMToolLog.java
new file mode 100644
index 000000000..7611c9e66
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/GradleTeaVMToolLog.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2015 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.logging.Logger;
+import org.teavm.tooling.TeaVMToolLog;
+
+public class GradleTeaVMToolLog implements TeaVMToolLog {
+ private Logger log;
+
+ public GradleTeaVMToolLog(Logger log) {
+ this.log = log;
+ }
+
+ @Override
+ public void info(String text) {
+ log.info(text);
+ }
+
+ @Override
+ public void debug(String text) {
+ log.debug(text);
+ }
+
+ @Override
+ public void warning(String text) {
+ log.warn(text);
+ }
+
+ @Override
+ public void error(String text) {
+ log.error(text);
+ }
+
+ @Override
+ public void info(String text, Throwable e) {
+ log.info(text, e);
+ }
+
+ @Override
+ public void debug(String text, Throwable e) {
+ log.debug(text, e);
+ }
+
+ @Override
+ public void warning(String text, Throwable e) {
+ log.warn(text, e);
+ }
+
+ @Override
+ public void error(String text, Throwable e) {
+ log.error(text, e);
+ }
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/OptimizationLevel.java b/tools/gradle/src/main/java/org/teavm/gradle/OptimizationLevel.java
new file mode 100644
index 000000000..480e11d9c
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/OptimizationLevel.java
@@ -0,0 +1,22 @@
+/*
+ * 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;
+
+public enum OptimizationLevel {
+ NONE,
+ BALANCED,
+ AGGRESSIVE
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtension.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtension.java
new file mode 100644
index 000000000..c1d54b21b
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtension.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;
+
+import org.gradle.api.provider.Provider;
+
+public interface TeaVMBaseExtension {
+ TeaVMLibraries getLibs();
+
+ Provider property(String name);
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtensionImpl.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtensionImpl.java
new file mode 100644
index 000000000..6282c3b40
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMBaseExtensionImpl.java
@@ -0,0 +1,105 @@
+/*
+ * 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 java.io.FileReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Properties;
+import javax.inject.Inject;
+import org.gradle.api.Project;
+import org.gradle.api.artifacts.Dependency;
+import org.gradle.api.provider.Provider;
+import org.teavm.gradle.config.ArtifactCoordinates;
+
+public class TeaVMBaseExtensionImpl implements TeaVMBaseExtension {
+ protected Project project;
+ private Provider properties;
+
+ @Inject
+ public TeaVMBaseExtensionImpl(Project project) {
+ this.project = project;
+ properties = project.provider(() -> {
+ var result = new Properties();
+ var p = project;
+ while (p != null) {
+ var dir = p.getProjectDir();
+ append(result, new File(dir, "teavm-local.properties"));
+ append(result, new File(dir, "teavm.properties"));
+ p = p.getParent();
+ }
+ return result;
+ });
+ }
+
+ private void append(Properties target, File source) throws IOException {
+ if (!source.isFile()) {
+ return;
+ }
+ var props = new Properties();
+ try (var input = new FileReader(source, StandardCharsets.UTF_8)) {
+ props.load(input);
+ }
+ append(target, props);
+ }
+
+ private void append(Properties target, Properties source) {
+ for (var key : source.stringPropertyNames()) {
+ if (!target.containsKey(key)) {
+ target.setProperty(key, source.getProperty(key));
+ }
+ }
+ }
+
+ @Override
+ public TeaVMLibraries getLibs() {
+ return libs;
+ }
+
+ private TeaVMLibraries libs = new TeaVMLibraries() {
+ @Override
+ public Dependency getJso() {
+ return project.getDependencies().create(ArtifactCoordinates.JSO);
+ }
+
+ @Override
+ public Dependency getJsoApis() {
+ return project.getDependencies().create(ArtifactCoordinates.JSO_APIS);
+ }
+
+ @Override
+ public Dependency getInterop() {
+ return project.getDependencies().create(ArtifactCoordinates.INTEROP);
+ }
+
+ @Override
+ public Dependency getMetaprogramming() {
+ return project.getDependencies().create(ArtifactCoordinates.METAPROGRAMMING);
+ }
+ };
+
+ @Override
+ public Provider property(String name) {
+ return properties.map(p -> {
+ var result = p.getProperty(name);
+ if (result != null) {
+ return result;
+ }
+ return project.getProviders().gradleProperty("teavm." + name).getOrElse(null);
+ });
+ }
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMCConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMCConfiguration.java
new file mode 100644
index 000000000..2f7c13cdd
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMCConfiguration.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;
+
+import org.gradle.api.provider.Property;
+
+public interface TeaVMCConfiguration extends TeaVMConfiguration, TeaVMNativeBaseConfiguration {
+ Property getHeapDump();
+
+ Property getShortFileNames();
+
+ Property getObfuscated();
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMCommonConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMCommonConfiguration.java
new file mode 100644
index 000000000..787f374c4
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMCommonConfiguration.java
@@ -0,0 +1,41 @@
+/*
+ * 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.provider.ListProperty;
+import org.gradle.api.provider.MapProperty;
+import org.gradle.api.provider.Property;
+
+public interface TeaVMCommonConfiguration {
+ Property getMainClass();
+
+ Property getDebugInformation();
+
+ Property getFastGlobalAnalysis();
+
+ Property getOptimization();
+
+ MapProperty getProperties();
+
+ ListProperty getPreservedClasses();
+
+ Property getOutOfProcess();
+
+ Property getProcessMemory();
+
+ Property getOutputDir();
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMConfiguration.java
new file mode 100644
index 000000000..2434c49a0
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMConfiguration.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;
+
+import org.gradle.api.provider.Property;
+
+public interface TeaVMConfiguration extends TeaVMCommonConfiguration {
+ Property getRelativePathInOutputDir();
+
+ Property getSkip();
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtension.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtension.java
new file mode 100644
index 000000000..3a9aef486
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtension.java
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+public interface TeaVMExtension extends TeaVMBaseExtension {
+ TeaVMJSConfiguration getJs();
+
+ void js(Action action);
+
+ TeaVMWasmConfiguration getWasm();
+
+ void wasm(Action action);
+
+ TeaVMWasiConfiguration getWasi();
+
+ void wasi(Action action);
+
+ TeaVMCConfiguration getC();
+
+ void c(Action action);
+
+ TeaVMCommonConfiguration getAll();
+
+ void all(Action action);
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtensionImpl.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtensionImpl.java
new file mode 100644
index 000000000..84e8ce605
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMExtensionImpl.java
@@ -0,0 +1,166 @@
+/*
+ * 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 javax.inject.Inject;
+import org.gradle.api.Action;
+import org.gradle.api.Project;
+import org.gradle.api.model.ObjectFactory;
+
+public 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);
+ js = objectFactory.newInstance(TeaVMJSConfiguration.class);
+ wasm = objectFactory.newInstance(TeaVMWasmConfiguration.class);
+ wasi = objectFactory.newInstance(TeaVMWasiConfiguration.class);
+ c = objectFactory.newInstance(TeaVMCConfiguration.class);
+ all = objectFactory.newInstance(TeaVMCommonConfiguration.class);
+ inherit(js, all);
+ inherit(wasm, all);
+ inherit(wasi, all);
+ inherit(c, all);
+ setupDefaults();
+ }
+
+ private void setupDefaults() {
+ setupJsDefaults();
+ setupWasmDefaults();
+ setupWasiDefaults();
+ setupCDefaults();
+ setupAllDefaults();
+ }
+
+ private void setupJsDefaults() {
+ js.getRelativePathInOutputDir().convention("js");
+ js.getObfuscated().convention(property("js.obfuscated").map(Boolean::parseBoolean).orElse(true));
+ js.getSourceMap().convention(property("js.sourceMap").map(Boolean::parseBoolean).orElse(false));
+ js.getStrict().convention(property("js.strict").map(Boolean::parseBoolean).orElse(false));
+ js.getEntryPointName().convention("main");
+ js.getTargetFileName().convention(project.provider(() -> project.getName() + ".js"));
+ js.getAddedToWebApp().convention(property("js.addedToWebApp").map(Boolean::parseBoolean).orElse(false));
+ js.getOptimization().convention(property("js.optimization").map(OptimizationLevel::valueOf)
+ .orElse(OptimizationLevel.AGGRESSIVE));
+ }
+
+ private void setupWasmDefaults() {
+ wasm.getRelativePathInOutputDir().convention("wasm");
+ wasm.getMinHeapSize().convention(1);
+ wasm.getMaxHeapSize().convention(16);
+ wasm.getOptimization().convention(property("wasm.optimization").map(OptimizationLevel::valueOf)
+ .orElse(OptimizationLevel.AGGRESSIVE));
+ wasm.getTargetFileName().convention(project.provider(() -> project.getName() + ".wasm"));
+ wasm.getAddedToWebApp().convention(property("wasm.addedToWebApp").map(Boolean::parseBoolean).orElse(false));
+ }
+
+ private void setupWasiDefaults() {
+ wasi.getRelativePathInOutputDir().convention("wasi");
+ wasi.getMinHeapSize().convention(1);
+ wasi.getMaxHeapSize().convention(16);
+ wasi.getOptimization().convention(property("wasi.optimization").map(OptimizationLevel::valueOf)
+ .orElse(OptimizationLevel.AGGRESSIVE));
+ wasi.getTargetFileName().convention(project.provider(() -> project.getName() + ".wasm"));
+ }
+
+ private void setupCDefaults() {
+ c.getRelativePathInOutputDir().convention("c");
+ c.getMinHeapSize().convention(1);
+ c.getMaxHeapSize().convention(16);
+ c.getHeapDump().convention(property("c.heapDump").map(Boolean::parseBoolean).orElse(false));
+ c.getShortFileNames().convention(property("c.shortFileName").map(Boolean::parseBoolean).orElse(true));
+ c.getOptimization().convention(property("c.optimization").map(OptimizationLevel::valueOf)
+ .orElse(OptimizationLevel.AGGRESSIVE));
+ c.getObfuscated().convention(true);
+ }
+
+ private void setupAllDefaults() {
+ all.getOutputDir().convention(new File(project.getBuildDir(), "generated/teavm"));
+ all.getDebugInformation().convention(property("debugInformation").map(Boolean::parseBoolean).orElse(false));
+ all.getOptimization().convention(OptimizationLevel.BALANCED);
+ all.getFastGlobalAnalysis().convention(property("fastGlobalAnalysis").map(Boolean::parseBoolean).orElse(false));
+ all.getOutOfProcess().convention(property("outOfProcess").map(Boolean::parseBoolean).orElse(false));
+ all.getProcessMemory().convention(property("processMemory").map(Integer::parseInt).orElse(512));
+ }
+
+ @Override
+ public TeaVMJSConfiguration getJs() {
+ return js;
+ }
+
+ @Override
+ public void js(Action action) {
+ action.execute(getJs());
+ }
+
+ @Override
+ public TeaVMWasmConfiguration getWasm() {
+ return wasm;
+ }
+
+ @Override
+ public void wasm(Action action) {
+ action.execute(getWasm());
+ }
+
+ @Override
+ public TeaVMWasiConfiguration getWasi() {
+ return wasi;
+ }
+
+ @Override
+ public void wasi(Action action) {
+ action.execute(wasi);
+ }
+
+ @Override
+ public TeaVMCConfiguration getC() {
+ return c;
+ }
+
+ @Override
+ public void c(Action action) {
+ action.execute(c);
+ }
+
+ @Override
+ public TeaVMCommonConfiguration getAll() {
+ return all;
+ }
+
+ @Override
+ public void all(Action action) {
+ action.execute(getAll());
+ }
+
+ private void inherit(TeaVMCommonConfiguration target, TeaVMCommonConfiguration source) {
+ target.getMainClass().convention(source.getMainClass());
+ target.getOutputDir().convention(source.getOutputDir());
+ target.getDebugInformation().convention(source.getDebugInformation());
+ target.getFastGlobalAnalysis().convention(source.getFastGlobalAnalysis());
+ target.getOptimization().convention(source.getOptimization());
+ target.getProperties().putAll(source.getProperties());
+
+ target.getOutOfProcess().convention(source.getOutOfProcess());
+ target.getProcessMemory().convention(source.getProcessMemory());
+ }
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMJSConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMJSConfiguration.java
new file mode 100644
index 000000000..021fa0fdc
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMJSConfiguration.java
@@ -0,0 +1,30 @@
+/*
+ * 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.provider.Property;
+
+public interface TeaVMJSConfiguration extends TeaVMWebConfiguration {
+ Property getObfuscated();
+
+ Property getStrict();
+
+ Property getSourceMap();
+
+ Property getEntryPointName();
+
+ Property getTargetFileName();
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraries.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraries.java
new file mode 100644
index 000000000..2dc31139a
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraries.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;
+
+import org.gradle.api.artifacts.Dependency;
+
+public interface TeaVMLibraries {
+ Dependency getJso();
+
+ Dependency getJsoApis();
+
+ Dependency getInterop();
+
+ Dependency getMetaprogramming();
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraryPlugin.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraryPlugin.java
new file mode 100644
index 000000000..14f173992
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMLibraryPlugin.java
@@ -0,0 +1,40 @@
+/*
+ * 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 javax.inject.Inject;
+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.config.ArtifactCoordinates;
+
+public class TeaVMLibraryPlugin implements Plugin {
+ private ObjectFactory objectFactory;
+
+ @Inject
+ public TeaVMLibraryPlugin(ObjectFactory objectFactory) {
+ this.objectFactory = objectFactory;
+ }
+
+ @Override
+ public void apply(Project project) {
+ var extension = objectFactory.newInstance(TeaVMBaseExtensionImpl.class);
+ 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);
+ }
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMNativeBaseConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMNativeBaseConfiguration.java
new file mode 100644
index 000000000..ce439b334
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMNativeBaseConfiguration.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;
+
+import org.gradle.api.provider.Property;
+
+public interface TeaVMNativeBaseConfiguration extends TeaVMCommonConfiguration {
+ Property getMinHeapSize();
+
+ Property getMaxHeapSize();
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMPlugin.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMPlugin.java
new file mode 100644
index 000000000..e78a528b4
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMPlugin.java
@@ -0,0 +1,213 @@
+/*
+ * 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 javax.inject.Inject;
+import org.gradle.api.Plugin;
+import org.gradle.api.Project;
+import org.gradle.api.artifacts.Configuration;
+import org.gradle.api.file.DuplicatesStrategy;
+import org.gradle.api.model.ObjectFactory;
+import org.gradle.api.plugins.JavaPlugin;
+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.config.ArtifactCoordinates;
+
+public class TeaVMPlugin implements Plugin {
+ public static final String EXTENSION_NAME = "teavm";
+ public static final String SOURCE_SET_NAME = "teavm";
+ public static final String JS_TASK_NAME = "generateJavaScript";
+ public static final String WASM_TASK_NAME = "generateWasm";
+ public static final String WASI_TASK_NAME = "generateWasi";
+ public static final String C_TASK_NAME = "generateC";
+ public static final String CONFIGURATION_NAME = "teavm";
+ public static final String CLASSPATH_CONFIGURATION_NAME = "teavmClasspath";
+ private ObjectFactory objectFactory;
+
+ @Inject
+ public TeaVMPlugin(ObjectFactory objectFactory) {
+ this.objectFactory = objectFactory;
+ }
+
+ @Override
+ public void apply(Project project) {
+ registerExtension(project);
+ registerConfiguration(project);
+ registerSourceSet(project);
+ registerTasks(project);
+ addDependencies(project);
+ setupWarTask(project);
+ }
+
+ private void registerExtension(Project project) {
+ var extension = objectFactory.newInstance(TeaVMExtensionImpl.class);
+ project.getExtensions().add(TeaVMExtension.class, EXTENSION_NAME, extension);
+ }
+
+ private void registerConfiguration(Project project) {
+ var teavm = project.getConfigurations().create(CONFIGURATION_NAME);
+ var teavmClasspath = project.getConfigurations().create(CLASSPATH_CONFIGURATION_NAME);
+ project.getConfigurations().configureEach(config -> {
+ if (config.getName().equals(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)) {
+ teavmClasspath.extendsFrom(config);
+ }
+ if (config.getName().equals(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME)) {
+ config.extendsFrom(teavm);
+ }
+ });
+ teavmClasspath.extendsFrom(teavm);
+ }
+
+ private void registerSourceSet(Project project) {
+ var sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
+ var sourceSet = sourceSets.create(SOURCE_SET_NAME);
+ var main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput();
+ sourceSet.setRuntimeClasspath(sourceSet.getRuntimeClasspath().plus(main)
+ .plus(project.getConfigurations().getByName(CLASSPATH_CONFIGURATION_NAME)));
+ sourceSet.setCompileClasspath(sourceSet.getCompileClasspath().plus(main)
+ .plus(project.getConfigurations().getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME)));
+ sourceSet.java(java -> { });
+ }
+
+ private void registerTasks(Project project) {
+ var compilerConfig = project.getConfigurations().detachedConfiguration(
+ project.getDependencies().create(ArtifactCoordinates.TOOLS));
+ registerJsTask(project, compilerConfig);
+ registerWasmTask(project, compilerConfig);
+ registerWasiTask(project, compilerConfig);
+ registerCTask(project, compilerConfig);
+ }
+
+ private void registerJsTask(Project project, Configuration configuration) {
+ var extension = project.getExtensions().getByType(TeaVMExtension.class);
+ project.getTasks().create(JS_TASK_NAME, GenerateJavaScriptTask.class, task -> {
+ var js = extension.getJs();
+ applyToTask(js, task, configuration);
+ task.getObfuscated().convention(js.getObfuscated());
+ task.getSourceMap().convention(js.getSourceMap());
+ task.getTargetFileName().convention(js.getTargetFileName());
+ task.getStrict().convention(js.getStrict());
+ task.getEntryPointName().convention(js.getEntryPointName());
+ });
+ }
+
+ private void registerWasmTask(Project project, Configuration configuration) {
+ var extension = project.getExtensions().getByType(TeaVMExtension.class);
+ project.getTasks().create(WASM_TASK_NAME, GenerateWasmTask.class, task -> {
+ var wasm = extension.getWasm();
+ applyToTask(wasm, task, configuration);
+ task.getTargetFileName().convention(wasm.getTargetFileName());
+ task.getMinHeapSize().convention(wasm.getMinHeapSize());
+ task.getMaxHeapSize().convention(wasm.getMaxHeapSize());
+ });
+ }
+
+ private void registerWasiTask(Project project, Configuration configuration) {
+ var extension = project.getExtensions().getByType(TeaVMExtension.class);
+ project.getTasks().create(WASI_TASK_NAME, GenerateWasiTask.class, task -> {
+ var wasi = extension.getWasi();
+ applyToTask(wasi, task, configuration);
+ task.getTargetFileName().convention(wasi.getTargetFileName());
+ task.getMinHeapSize().convention(wasi.getMinHeapSize());
+ task.getMaxHeapSize().convention(wasi.getMaxHeapSize());
+ });
+ }
+
+ private void registerCTask(Project project, Configuration configuration) {
+ var extension = project.getExtensions().getByType(TeaVMExtension.class);
+ project.getTasks().create(C_TASK_NAME, GenerateCTask.class, task -> {
+ var c = extension.getC();
+ applyToTask(c, task, configuration);
+ task.getMinHeapSize().convention(c.getMinHeapSize());
+ task.getMaxHeapSize().convention(c.getMaxHeapSize());
+ task.getHeapDump().convention(c.getHeapDump());
+ task.getShortFileNames().convention(c.getShortFileNames());
+ task.getObfuscated().convention(c.getObfuscated());
+ });
+ }
+
+ private void addDependencies(Project project) {
+ project.getDependencies().add(CONFIGURATION_NAME, ArtifactCoordinates.CLASSLIB);
+ project.getDependencies().add(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME, ArtifactCoordinates.JUNIT);
+ }
+
+ private void setupWarTask(Project project) {
+ var extension = project.getExtensions().getByType(TeaVMExtension.class);
+
+ project.getTasks().withType(War.class).configureEach(task -> {
+ if (task.getName().equals(WarPlugin.WAR_TASK_NAME)) {
+ var jsAddedToWebApp = extension.getJs().getAddedToWebApp().get();
+ var wasmAddedToWebApp = extension.getWasm().getAddedToWebApp().get();
+ if (jsAddedToWebApp) {
+ task.dependsOn(project.getTasks().named(JS_TASK_NAME));
+ var outDir = extension.getJs().getOutputDir();
+ var relPath = extension.getJs().getRelativePathInOutputDir();
+ task.with(project.copySpec(spec -> {
+ spec.into(relPath);
+ spec.from(project.files(outDir.map(dir -> new File(dir, relPath.get()))));
+ spec.setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE);
+ }));
+ task.with(project.copySpec(spec -> {
+ spec.into(relPath.map(path -> joinPath("WEB-INF", path)));
+ spec.include("*.teavmdbg");
+ spec.from(project.files(outDir.map(dir -> new File(dir, relPath.get()))));
+ spec.setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE);
+ }));
+ }
+ if (wasmAddedToWebApp) {
+ task.dependsOn(project.getTasks().named(WASM_TASK_NAME));
+ var outDir = extension.getWasm().getOutputDir();
+ var relPath = extension.getWasm().getRelativePathInOutputDir();
+ task.with(project.copySpec(spec -> {
+ spec.into(relPath);
+ spec.from(project.files(outDir.map(dir -> new File(dir, relPath.get()))));
+ }));
+ }
+ }
+ });
+ }
+
+ private static String joinPath(String first, String second) {
+ if (first.endsWith("/") || first.isEmpty()) {
+ return first + second;
+ } else {
+ return first + "/" + second;
+ }
+ }
+
+ private void applyToTask(TeaVMConfiguration configuration, TeaVMTask task, Configuration toolsConfiguration) {
+ task.getMainClass().convention(configuration.getMainClass());
+ task.getClasspath().from(task.getProject().getConfigurations().getByName(CLASSPATH_CONFIGURATION_NAME));
+ task.getPreservedClasses().addAll(configuration.getPreservedClasses());
+ task.getDebugInformation().convention(configuration.getDebugInformation());
+ task.getFastGlobalAnalysis().convention(configuration.getFastGlobalAnalysis());
+ task.getOutOfProcess().convention(configuration.getOutOfProcess());
+ task.getProcessMemory().convention(configuration.getProcessMemory());
+ task.getProperties().putAll(configuration.getProperties());
+ task.getDaemonClasspath().from(toolsConfiguration);
+ task.getOutputDir().convention(configuration.getOutputDir().map(
+ d -> new File(d, configuration.getRelativePathInOutputDir().get())));
+
+ var project = task.getProject();
+
+ var sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
+ task.getClasspath().from(sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput());
+ task.getClasspath().from(sourceSets.getByName(SOURCE_SET_NAME).getOutput());
+ }
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTask.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTask.java
new file mode 100644
index 000000000..e30ff6904
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTask.java
@@ -0,0 +1,192 @@
+/*
+ * 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 java.io.IOException;
+import java.net.URLClassLoader;
+import java.rmi.NotBoundException;
+import java.rmi.registry.LocateRegistry;
+import java.util.ArrayList;
+import java.util.Properties;
+import org.gradle.api.DefaultTask;
+import org.gradle.api.GradleException;
+import org.gradle.api.file.ConfigurableFileCollection;
+import org.gradle.api.provider.ListProperty;
+import org.gradle.api.provider.MapProperty;
+import org.gradle.api.provider.Property;
+import org.gradle.api.tasks.Classpath;
+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.tooling.TeaVMProblemRenderer;
+import org.teavm.tooling.builder.BuildException;
+import org.teavm.tooling.builder.BuildStrategy;
+import org.teavm.tooling.builder.InProcessBuildStrategy;
+import org.teavm.tooling.builder.RemoteBuildStrategy;
+import org.teavm.tooling.daemon.BuildDaemon;
+import org.teavm.tooling.daemon.DaemonLog;
+import org.teavm.tooling.daemon.RemoteBuildService;
+import org.teavm.vm.TeaVMOptimizationLevel;
+
+public abstract class TeaVMTask extends DefaultTask {
+ public TeaVMTask() {
+ setGroup("TeaVM");
+ getDebugInformation().convention(false);
+ getTargetFileName().convention("bundle");
+ getOptimization().convention(OptimizationLevel.BALANCED);
+ getFastGlobalAnalysis().convention(false);
+ getOutOfProcess().convention(false);
+ getProcessMemory().convention(512);
+ }
+
+ @Classpath
+ public abstract ConfigurableFileCollection getClasspath();
+
+ @Input
+ @Optional
+ public abstract Property getDebugInformation();
+
+ @Input
+ @Optional
+ public abstract Property getTargetFileName();
+
+ @Input
+ @Optional
+ public abstract Property getOptimization();
+
+ @Input
+ @Optional
+ public abstract Property getFastGlobalAnalysis();
+
+ @Input
+ @Optional
+ public abstract MapProperty getProperties();
+
+ @Input
+ @Optional
+ public abstract ListProperty getPreservedClasses();
+
+ @OutputDirectory
+ public abstract Property getOutputDir();
+
+ @Input
+ public abstract Property getMainClass();
+
+ @Input
+ @Optional
+ public abstract Property getOutOfProcess();
+
+ @Input
+ @Optional
+ public abstract Property getProcessMemory();
+
+ @Classpath
+ public abstract ConfigurableFileCollection getDaemonClasspath();
+
+ @TaskAction
+ public void execute() throws BuildException, IOException, NotBoundException {
+ if (getOutOfProcess().get()) {
+ executeInSeparateProcess();
+ } else {
+ executeWithBuilder(new InProcessBuildStrategy(URLClassLoader::new));
+ }
+ }
+
+ private void executeInSeparateProcess() throws BuildException, IOException, NotBoundException {
+ var daemon = BuildDaemon.start(false, getProcessMemory().get(), new DaemonLogImpl(),
+ createDaemonClassPath());
+
+ try {
+ var registry = LocateRegistry.getRegistry("localhost", daemon.getPort());
+ var buildService = (RemoteBuildService) registry.lookup(RemoteBuildService.ID);
+ var builder = new RemoteBuildStrategy(buildService);
+ executeWithBuilder(builder);
+ } finally {
+ daemon.getProcess().destroy();
+ }
+ }
+
+ private void executeWithBuilder(BuildStrategy builder) throws BuildException {
+ builder.init();
+ var toolLog = new GradleTeaVMToolLog(getLogger());
+ builder.setLog(toolLog);
+ builder.setMainClass(getMainClass().get());
+ builder.setDebugInformationGenerated(getDebugInformation().get());
+ var classPathStrings = new ArrayList();
+ for (var file : getClasspath()) {
+ classPathStrings.add(file.getAbsolutePath());
+ }
+ builder.setClassPathEntries(classPathStrings);
+ builder.setTargetFileName(getTargetFileName().get());
+ builder.setOptimizationLevel(map(getOptimization().get()));
+ builder.setFastDependencyAnalysis(getFastGlobalAnalysis().get());
+ builder.setTargetDirectory(getOutputDir().get().getAbsolutePath());
+ builder.setClassesToPreserve(getPreservedClasses().get().toArray(new String[0]));
+ if (getProperties().isPresent()) {
+ var properties = new Properties();
+ for (var entry : getProperties().get().entrySet()) {
+ properties.setProperty(entry.getKey(), entry.getValue());
+ }
+ builder.setProperties(properties);
+ }
+ setupBuilder(builder);
+ var result = builder.build();
+ TeaVMProblemRenderer.describeProblems(result.getCallGraph(), result.getProblems(), toolLog);
+ if (!result.getProblems().getSevereProblems().isEmpty()) {
+ throw new GradleException("Errors occurred during TeaVM build");
+ }
+ }
+
+ private static TeaVMOptimizationLevel map(OptimizationLevel level) {
+ switch (level) {
+ case AGGRESSIVE:
+ return TeaVMOptimizationLevel.FULL;
+ case BALANCED:
+ return TeaVMOptimizationLevel.ADVANCED;
+ default:
+ return TeaVMOptimizationLevel.SIMPLE;
+ }
+ }
+
+ protected abstract void setupBuilder(BuildStrategy builder);
+
+ private String[] createDaemonClassPath() {
+ var result = new ArrayList();
+ for (var file : getDaemonClasspath()) {
+ result.add(file.getAbsolutePath());
+ }
+ return result.toArray(new String[0]);
+ }
+
+ class DaemonLogImpl implements DaemonLog {
+ @Override
+ public void error(String message) {
+ getLogger().error(message);
+ }
+
+ @Override
+ public void error(String message, Throwable e) {
+ getLogger().error(message, e);
+ }
+
+ @Override
+ public void info(String message) {
+ getLogger().info(message);
+ }
+ }
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasiConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasiConfiguration.java
new file mode 100644
index 000000000..a5d7203e4
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasiConfiguration.java
@@ -0,0 +1,19 @@
+/*
+ * 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;
+
+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/TeaVMWasmBaseConfiguration.java
new file mode 100644
index 000000000..62cbac84d
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmBaseConfiguration.java
@@ -0,0 +1,22 @@
+/*
+ * 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.provider.Property;
+
+public interface TeaVMWasmBaseConfiguration extends TeaVMCommonConfiguration, TeaVMNativeBaseConfiguration {
+ Property getTargetFileName();
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmConfiguration.java
new file mode 100644
index 000000000..d53af9cca
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmConfiguration.java
@@ -0,0 +1,19 @@
+/*
+ * 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;
+
+public interface TeaVMWasmConfiguration extends TeaVMWebConfiguration, TeaVMWasmBaseConfiguration {
+}
diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWebConfiguration.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWebConfiguration.java
new file mode 100644
index 000000000..436a2af2b
--- /dev/null
+++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWebConfiguration.java
@@ -0,0 +1,22 @@
+/*
+ * 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.provider.Property;
+
+public interface TeaVMWebConfiguration extends TeaVMConfiguration {
+ Property getAddedToWebApp();
+}
diff --git a/tools/ide-deps/build.gradle.kts b/tools/ide-deps/build.gradle.kts
new file mode 100644
index 000000000..d04874d10
--- /dev/null
+++ b/tools/ide-deps/build.gradle.kts
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ shadowApply
+}
+
+description = "All-in one JAR file that used by IDE plugins"
+
+dependencies {
+ implementation(project(path = ":tools:core"))
+ implementation(project(path = ":tools:devserver"))
+ implementation(project(path = ":classlib"))
+ implementation(project(path = ":tools:chrome-rdp"))
+}
+
+tasks.shadowJar {
+ archiveFileName.set("teavm.jar")
+ mergeServiceFiles()
+}
\ No newline at end of file
diff --git a/tools/ide-deps/pom.xml b/tools/ide-deps/pom.xml
deleted file mode 100644
index d8db62ff9..000000000
--- a/tools/ide-deps/pom.xml
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
-
-
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- 4.0.0
-
- teavm-ide-deps
- TeaVM fat JAR for IDEs
-
-
-
- org.teavm
- teavm-tooling
- ${project.version}
-
-
- org.teavm
- teavm-devserver
- ${project.version}
-
-
- org.teavm
- teavm-classlib
- ${project.version}
-
-
- org.teavm
- teavm-chrome-rdp
- ${project.version}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- ${maven-shade-plugin.version}
-
-
- package
-
- shade
-
-
-
-
- com.jetbrains.intellij.idea:ideaIC:zip:*
- joda-time:joda-time
-
-
- true
-
-
- com.google.gson
- org.teavm.shade.gson
-
-
- com.jcraft.jzlib
- org.teavm.shade.jzlib
-
-
- org.eclipse.jetty
- org.teavm.shade.jetty
-
-
- org.joda.time
- org.teavm.shade.jodatime
-
-
- org.objectweb.asm
- org.teavm.shade.jetty.asm
-
-
- org.slf4j
- org.teavm.shade.slf4j
-
-
- org.apache.commons
- org.teavm.apachecommons
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tools/idea/.gitignore b/tools/idea/.gitignore
deleted file mode 100644
index bb64e44d1..000000000
--- a/tools/idea/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.gradle
-build/
-!gradle/wrapper/gradle-wrapper.jar
-!**/src/main/**/build/
-!**/src/test/**/build/
diff --git a/tools/idea/build.gradle.kts b/tools/idea/build.gradle.kts
index 6f5a83ba5..6a31b4694 100644
--- a/tools/idea/build.gradle.kts
+++ b/tools/idea/build.gradle.kts
@@ -15,44 +15,36 @@
*/
plugins {
- id("java")
- id("checkstyle")
- id("org.jetbrains.intellij") version "1.10.1"
-}
-
-group = "org.teavm"
-version = "0.7.0-SNAPSHOT"
-
-repositories {
- mavenCentral()
- mavenLocal()
+ java
+ alias(libs.plugins.intellij)
}
intellij {
- version.set("2020.1.4")
- type.set("IC") // Target IDE Platform
+ version.set(libs.versions.idea.asProvider().get())
+ type.set("IC")
+
+ plugins.set(listOf(
+ "java",
+ "org.intellij.scala:${libs.versions.idea.scala.get()}",
+ "org.jetbrains.kotlin"
+ ))
- plugins.set(listOf("java", "org.intellij.scala:2020.1.43", "org.jetbrains.kotlin"))
-}
-checkstyle {
- toolVersion = "8.41"
- configFile = File("../../checkstyle.xml")
}
dependencies {
- implementation(group = "org.teavm", name = "teavm-ide-deps", version = project.version.toString(),
- classifier = "shaded")
+ implementation(project(path = ":tools:ide-deps", configuration = "shadow").setTransitive(false))
}
tasks {
- withType {
- sourceCompatibility = "11"
- targetCompatibility = "11"
- }
-
patchPluginXml {
sinceBuild.set("201")
untilBuild.set("231.*")
}
+ jar {
+ archiveFileName.set("teavm-plugin.jar")
+ }
+ buildSearchableOptions {
+ enabled = false
+ }
}
diff --git a/tools/idea/settings.gradle.kts b/tools/idea/settings.gradle.kts
deleted file mode 100644
index 6c9e76d8f..000000000
--- a/tools/idea/settings.gradle.kts
+++ /dev/null
@@ -1 +0,0 @@
-rootProject.name = "teavm-idea"
\ No newline at end of file
diff --git a/tools/idea/src/main/java/org/teavm/idea/DaemonUtil.java b/tools/idea/src/main/java/org/teavm/idea/DaemonUtil.java
index 0bc56cef1..d75876f7b 100644
--- a/tools/idea/src/main/java/org/teavm/idea/DaemonUtil.java
+++ b/tools/idea/src/main/java/org/teavm/idea/DaemonUtil.java
@@ -29,8 +29,7 @@ import org.teavm.idea.devserver.DevServerRunner;
import org.teavm.tooling.daemon.BuildDaemon;
public final class DaemonUtil {
- private static final Set PLUGIN_FILES = new HashSet<>(Arrays.asList("teavm-jps-common.jar",
- "teavm-plugin.jar", "teavm.jar"));
+ private static final Set PLUGIN_FILES = new HashSet<>(Arrays.asList("teavm-plugin.jar", "teavm.jar"));
private static final String DAEMON_CLASS = BuildDaemon.class.getName().replace('.', '/') + ".class";
private static final String DEV_SERVER_CLASS = DevServerRunner.class.getName().replace('.', '/') + ".class";
private static final int DAEMON_CLASS_DEPTH;
diff --git a/tools/idea/src/main/resources/META-INF/plugin.xml b/tools/idea/src/main/resources/META-INF/plugin.xml
index 3c2697f9a..42ccd03f9 100644
--- a/tools/idea/src/main/resources/META-INF/plugin.xml
+++ b/tools/idea/src/main/resources/META-INF/plugin.xml
@@ -25,11 +25,6 @@
-
-
diff --git a/tools/junit/build.gradle.kts b/tools/junit/build.gradle.kts
new file mode 100644
index 000000000..8e5aa10d7
--- /dev/null
+++ b/tools/junit/build.gradle.kts
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+plugins {
+ `java-library`
+ `teavm-publish`
+}
+
+description = "Test runner for JUnit and TestNG annotations"
+
+configurations {
+ create("js")
+}
+
+dependencies {
+ compileOnly(libs.junit)
+ compileOnly(libs.testng)
+ compileOnly(project(":jso:core"))
+ compileOnly(project(":classlib"))
+
+ implementation(project(":core"))
+ implementation(project(":tools:core"))
+ implementation(libs.rhino)
+ implementation(libs.htmlunit)
+ implementation(libs.jackson.annotations)
+ implementation(libs.jackson.databind)
+ implementation(libs.javax.servlet)
+ implementation(libs.jetty.server)
+ implementation(libs.jetty.websocket.server)
+ implementation(libs.jetty.websocket.client)
+ implementation(libs.jetty.websocket.client)
+
+ "js"(project(":tools:deobfuscator-js", "js"))
+}
+
+tasks.withType().configureEach {
+ if (name == "relocateJar") {
+ dependsOn(configurations["js"])
+ from(project.provider { configurations["js"].map { zipTree(it) } }) {
+ include("deobfuscator-lib.js")
+ into("test-server")
+ rename { "deobfuscator.js" }
+ }
+ }
+}
+
+teavmPublish {
+ artifactId = "teavm-junit"
+}
\ No newline at end of file
diff --git a/tools/junit/pom.xml b/tools/junit/pom.xml
deleted file mode 100644
index 4b1ba85e3..000000000
--- a/tools/junit/pom.xml
+++ /dev/null
@@ -1,188 +0,0 @@
-
-
-
-
- teavm
- org.teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- 4.0.0
-
- teavm-junit
- TeaVM JUnit runner
- TeaVM implementation of JUnit API
-
-
-
- junit
- junit
- provided
-
-
- org.testng
- testng
- provided
-
-
- org.teavm
- teavm-tooling
- ${project.version}
-
-
- org.teavm
- teavm-classlib
- ${project.version}
-
-
- net.sourceforge.htmlunit
- htmlunit
- 2.33
-
-
-
- org.eclipse.jetty
- jetty-server
-
-
- org.eclipse.jetty.websocket
- javax-websocket-server-impl
-
-
- org.eclipse.jetty.websocket
- websocket-client
-
-
-
- com.fasterxml.jackson.core
- jackson-annotations
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
-
- javax.servlet
- javax.servlet-api
- 3.1.0
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../checkstyle.xml
- config_loc=${basedir}/../..
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
-
- org.teavm
- teavm-maven-plugin
- ${project.version}
-
-
- org.teavm
- teavm-jso-impl
- ${project.version}
-
-
- org.teavm
- teavm-classlib
- ${project.version}
-
-
-
-
- compile-deobfuscator
-
- compile
-
- process-classes
-
- ${project.build.directory}/classes/test-server
- deobfuscator.js
- true
- ADVANCED
- org.teavm.tooling.deobfuscate.js.DeobfuscatorLib
- deobfuscator
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
- package
-
- shade
-
-
-
-
- org.eclipse.jetty:*
- org.eclipse.jetty.websocket:*
- com.fasterxml.jackson.core:*
- javax.servlet:*
-
-
-
-
- *:*
-
- **/module-info.class
-
-
-
-
-
- org.eclipse.jetty
- org.teavm.jetty
-
-
- javax.servlet
- org.teavm.javaxservlet
-
-
- com.fasterxml.jackson
- org.teavm.jackson
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/tools/junit/src/main/java/org/teavm/junit/BrowserRunStrategy.java b/tools/junit/src/main/java/org/teavm/junit/BrowserRunStrategy.java
index e3fca5e49..723a7979b 100644
--- a/tools/junit/src/main/java/org/teavm/junit/BrowserRunStrategy.java
+++ b/tools/junit/src/main/java/org/teavm/junit/BrowserRunStrategy.java
@@ -53,7 +53,7 @@ import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
-public class BrowserRunStrategy implements TestRunStrategy {
+class BrowserRunStrategy implements TestRunStrategy {
private boolean decodeStack = Boolean.parseBoolean(System.getProperty(TeaVMTestRunner.JS_DECODE_STACK, "true"));
private final File baseDir;
private final String type;
diff --git a/tools/maven/plugin/build.gradle.kts b/tools/maven/plugin/build.gradle.kts
new file mode 100644
index 000000000..30501557d
--- /dev/null
+++ b/tools/maven/plugin/build.gradle.kts
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+plugins {
+ mavenPlugin
+ publishing
+ `teavm-publish`
+}
+
+description = "A set of mojos that allow to include TeaVM compiler into maven build process"
+
+dependencies {
+ implementation(project(":core"))
+ implementation(project(":tools:core"))
+}
+
+teavmPublish {
+ artifactId = "teavm-maven-plugin"
+}
\ No newline at end of file
diff --git a/tools/maven/plugin/pom.xml b/tools/maven/plugin/pom.xml
deleted file mode 100644
index 915bc1e54..000000000
--- a/tools/maven/plugin/pom.xml
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm-maven
- 0.7.0-SNAPSHOT
-
- teavm-maven-plugin
- maven-plugin
-
- TeaVM maven plugin
- A set of mojos that allow to include TeaVM compiler into maven build process
-
-
-
- org.apache.maven
- maven-plugin-api
-
-
- org.apache.maven.plugin-tools
- maven-plugin-annotations
- provided
-
-
- org.apache.maven
- maven-core
- provided
-
-
- org.apache.maven
- maven-artifact
- provided
-
-
- org.teavm
- teavm-tooling
- ${project.version}
-
-
- commons-io
- commons-io
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
- net.sourceforge.htmlunit
- htmlunit
- 2.18
-
-
- junit
- junit
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-plugin-plugin
- 3.6.4
-
- true
- teavm
-
-
-
- default-descriptor
-
- descriptor
-
- process-classes
-
-
-
-
- org.apache.maven.plugins
- maven-source-plugin
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
- ../../../checkstyle.xml
- config_loc=${basedir}/../../..
-
-
-
-
-
diff --git a/tools/maven/plugin/src/test/java/.gitignore b/tools/maven/plugin/src/test/java/.gitignore
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tools/maven/plugin/src/test/resources/.gitignore b/tools/maven/plugin/src/test/resources/.gitignore
deleted file mode 100644
index e69de29bb..000000000
diff --git a/tools/maven/pom.xml b/tools/maven/pom.xml
deleted file mode 100644
index 161fcb831..000000000
--- a/tools/maven/pom.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
- 4.0.0
-
-
- org.teavm
- teavm
- 0.7.0-SNAPSHOT
- ../../pom.xml
-
- teavm-maven
-
- pom
-
- TeaVM maven
- TeaVM maven integration aggregate project
- http://teavm.org
-
-
- plugin
- webapp
-
-
diff --git a/tools/maven/webapp/build.gradle.kts b/tools/maven/webapp/build.gradle.kts
new file mode 100644
index 000000000..f8eaa3abb
--- /dev/null
+++ b/tools/maven/webapp/build.gradle.kts
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+plugins {
+ java
+ publishing
+ `teavm-publish`
+}
+
+description = "An archetype that creates a simple web application with enabled TeaVM"
+
+tasks.processResources {
+ expand(
+ "teavmVersion" to version,
+ )
+}
+
+teavmPublish {
+ artifactId = "teavm-maven-webapp"
+}
\ No newline at end of file
diff --git a/tools/maven/webapp/pom.xml b/tools/maven/webapp/pom.xml
deleted file mode 100644
index 4724dce19..000000000
--- a/tools/maven/webapp/pom.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
- 4.0.0
-
-
- org.teavm
- teavm-maven
- 0.7.0-SNAPSHOT
-
- teavm-maven-webapp
- TeaVM maven web application archetype
-
- maven-archetype
-
- An archetype that creates a simple web application with enabled TeaVM
-
-
-
-
- org.apache.maven.archetype
- archetype-packaging
- 2.2
-
-
-
-
-
- org.apache.maven.plugins
- maven-archetype-plugin
- 2.2
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- 2.5
-
- \
-
-
-
-
-
-
-
- src/main/resources
- true
-
- archetype-resources/pom.xml
-
-
-
- src/main/resources
- false
-
- archetype-resources/pom.xml
-
-
-
-
-
\ No newline at end of file
diff --git a/tools/maven/webapp/src/main/resources/archetype-resources/pom.xml b/tools/maven/webapp/src/main/resources/archetype-resources/pom.xml
index f2bc95a2d..355d3f96a 100644
--- a/tools/maven/webapp/src/main/resources/archetype-resources/pom.xml
+++ b/tools/maven/webapp/src/main/resources/archetype-resources/pom.xml
@@ -9,7 +9,7 @@
1.8
- ${project.version}
+ ${teavmVersion}UTF-8
diff --git a/tools/maven/webapp/src/main/resources/archetype-resources/src/main/java/Client.java b/tools/maven/webapp/src/main/resources/archetype-resources/src/main/java/Client.java
index 3be6f6dfa..3ffcb3c72 100644
--- a/tools/maven/webapp/src/main/resources/archetype-resources/src/main/java/Client.java
+++ b/tools/maven/webapp/src/main/resources/archetype-resources/src/main/java/Client.java
@@ -1,12 +1,11 @@
-package ${package};
+package \${package};
import org.teavm.jso.dom.html.HTMLDocument;
-import org.teavm.jso.dom.html.HTMLElement;
public class Client {
public static void main(String[] args) {
- HTMLDocument document = HTMLDocument.current();
- HTMLElement div = document.createElement("div");
+ var document = HTMLDocument.current();
+ var div = document.createElement("div");
div.appendChild(document.createTextNode("TeaVM generated element"));
document.getBody().appendChild(div);
}