mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-09 08:24:10 -08:00
maven: add archetype for WebAssembly GC target
This commit is contained in:
parent
47c136ccc1
commit
ff35ad3ed8
|
@ -49,6 +49,7 @@ include("tools:ide-deps")
|
||||||
include("tools:idea")
|
include("tools:idea")
|
||||||
include("tools:maven:plugin")
|
include("tools:maven:plugin")
|
||||||
include("tools:maven:webapp")
|
include("tools:maven:webapp")
|
||||||
|
include("tools:maven:webapp-wasm-gc")
|
||||||
include("tools:classlib-comparison-gen")
|
include("tools:classlib-comparison-gen")
|
||||||
include("tools:wasm-disassembly")
|
include("tools:wasm-disassembly")
|
||||||
include("tests")
|
include("tests")
|
||||||
|
|
34
tools/maven/webapp-wasm-gc/build.gradle.kts
Normal file
34
tools/maven/webapp-wasm-gc/build.gradle.kts
Normal file
|
@ -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
|
||||||
|
publishing
|
||||||
|
`teavm-publish`
|
||||||
|
}
|
||||||
|
|
||||||
|
description = "An archetype that creates a simple Wasm GC web application"
|
||||||
|
|
||||||
|
tasks.processResources {
|
||||||
|
expand(
|
||||||
|
"teavmVersion" to version,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
teavmPublish {
|
||||||
|
artifactId = "teavm-maven-webapp-wasm-gc"
|
||||||
|
packaging = "maven-archetype"
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<archetype-descriptor xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0
|
||||||
|
http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
|
||||||
|
name="TeaVM web application" partial="false">
|
||||||
|
<fileSets>
|
||||||
|
<fileSet filtered="true" packaged="true" encoding="UTF-8">
|
||||||
|
<directory>src/main/java</directory>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet filtered="true" packaged="false" encoding="UTF-8">
|
||||||
|
<directory>.</directory>
|
||||||
|
<includes>
|
||||||
|
<include>pom.xml</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
|
<fileSet filtered="true" packaged="false" encoding="UTF-8">
|
||||||
|
<directory>src/main/webapp</directory>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets>
|
||||||
|
</archetype-descriptor>
|
|
@ -0,0 +1,122 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>\${groupId}</groupId>
|
||||||
|
<artifactId>\${artifactId}</artifactId>
|
||||||
|
<version>\${version}</version>
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>11</java.version>
|
||||||
|
<teavm.version>${teavmVersion}</teavm.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- Emulator of Java class library for TeaVM -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-classlib</artifactId>
|
||||||
|
<version>\${teavm.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- JavaScriptObjects (JSO) - a JavaScript binding for TeaVM -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-jso-apis</artifactId>
|
||||||
|
<version>\${teavm.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Servlet specification -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.servlet</groupId>
|
||||||
|
<artifactId>jakarta.servlet-api</artifactId>
|
||||||
|
<version>6.0.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<!-- Configure Java compiler to use Java 8 syntax -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.13.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>\${java.version}</source>
|
||||||
|
<target>\${java.version}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Configure WAR plugin to include JavaScript files generated by TeaVM -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<version>3.4.0</version>
|
||||||
|
<configuration>
|
||||||
|
<webResources>
|
||||||
|
<resource>
|
||||||
|
<directory>\${project.build.directory}/generated/wasm</directory>
|
||||||
|
</resource>
|
||||||
|
</webResources>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Configure TeaVM -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-maven-plugin</artifactId>
|
||||||
|
<version>\${teavm.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>web-client-wasm</id>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<!-- Directory where TeaVM should put generated files. This configuration conforms to the settings
|
||||||
|
of the WAR plugin -->
|
||||||
|
<targetDirectory>\${project.build.directory}/generated/wasm/teavm</targetDirectory>
|
||||||
|
|
||||||
|
<targetType>WEBASSEMBLY_GC</targetType>
|
||||||
|
|
||||||
|
<!-- Main class, containing static void main(String[]) -->
|
||||||
|
<mainClass>\${package}.Client</mainClass>
|
||||||
|
|
||||||
|
<!-- Optimization level. Valid values are: SIMPLE, ADVANCED, FULL -->
|
||||||
|
<optimizationLevel>ADVANCED</optimizationLevel>
|
||||||
|
|
||||||
|
<!-- Whether TeaVM should produce Wasm file without `name` section. Reduces size
|
||||||
|
of wasm file, but makes it much more difficult to debug.
|
||||||
|
Disable during development, enable for production -->
|
||||||
|
<minifying>true</minifying>
|
||||||
|
|
||||||
|
<!-- Whether TeaVM should produce debug information for its built-in debugger.
|
||||||
|
Disuble for production -->
|
||||||
|
<debugInformationGenerated>true</debugInformationGenerated>
|
||||||
|
|
||||||
|
<!-- Whether TeaVM should produce source maps file.
|
||||||
|
Disuble for production -->-->
|
||||||
|
<sourceMapsGenerated>true</sourceMapsGenerated>
|
||||||
|
|
||||||
|
<!-- Whether TeaVM should also put source files into output directory,
|
||||||
|
for compatibility with source maps. Disable for production. -->
|
||||||
|
<sourceFilesCopied>true</sourceFilesCopied>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>web-client-runtime</id>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-webassembly-gc-runtime</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<targetDirectory>\${project.build.directory}/generated/wasm/teavm</targetDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,12 @@
|
||||||
|
package \${package};
|
||||||
|
|
||||||
|
import org.teavm.jso.dom.html.HTMLDocument;
|
||||||
|
|
||||||
|
public class Client {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
var document = HTMLDocument.current();
|
||||||
|
var div = document.createElement("div");
|
||||||
|
div.appendChild(document.createTextNode("TeaVM generated element"));
|
||||||
|
document.getBody().appendChild(div);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Main page</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||||
|
<script type="text/javascript" charset="utf-8" src="teavm/classes.wasm-runtime.js"></script>
|
||||||
|
<script>
|
||||||
|
async function main() {
|
||||||
|
let teavm = await TeaVM.wasmGC.load("teavm/classes.wasm", {
|
||||||
|
stackDeobfuscator: {
|
||||||
|
// set to true during development phase, as well as `debugInformationGenerated`
|
||||||
|
// option in pom.xml to get clear stack traces. Don't forget
|
||||||
|
// to disable for production.
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
teavm.exports.main([]);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body onload="main()">
|
||||||
|
<!-- TODO: add HTML content -->
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -44,7 +44,7 @@
|
||||||
<!-- Configure Java compiler to use Java 8 syntax -->
|
<!-- Configure Java compiler to use Java 8 syntax -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.1</version>
|
<version>3.13.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>\${java.version}</source>
|
<source>\${java.version}</source>
|
||||||
<target>\${java.version}</target>
|
<target>\${java.version}</target>
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
<!-- Configure WAR plugin to include JavaScript files generated by TeaVM -->
|
<!-- Configure WAR plugin to include JavaScript files generated by TeaVM -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<version>3.3.2</version>
|
<version>3.4.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<webResources>
|
<webResources>
|
||||||
<resource>
|
<resource>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user