Skip to content

Commit

Permalink
update to teavm 0.10,
Browse files Browse the repository at this point in the history
undo maxTopLevelNames removal (was added again to teavm)
  • Loading branch information
xvik committed May 1, 2024
1 parent 226d913 commit f9af496
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 39 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
* Update to teavm 0.9.1
- Removed maxTopLevelNames option
* Update to teavm 0.10.0
- Add jsModuleType option
- Add sourceFilesCopiedAsLocalLinks dev option (in teavm enum used for 3 options: no, copy, links)
- Removed extra debug output (generated classes, used resources) - compiler does not provide it anymore

Teavm behavior change: sourceFilesCopied option now works only when sourceMapsGenerated enabled
Plugin is not compatible with teavm 0.9.0 (due to new compiler options)
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ to declare custom plugins repository:
*/
assertionsRemoved = false
/**
* Top-level names limit. ONLY for JS target.
*/
maxTopLevelNames = 80000
/**
* Minimal heap size (in mb). ONLY for WASM and C targets.
*/
Expand Down Expand Up @@ -471,7 +475,8 @@ Options list:
shortFileNames =
heapDump =
fastDependencyAnalysis =
assertionsRemoved =
assertionsRemoved =
maxTopLevelNames =
minHeapSize =
maxHeapSize =
optimizationLevel =
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ wrapper {
}

ext {
teavm = '0.9.1'
teavm = '0.10.0'
}

repositories { mavenLocal(); mavenCentral(); gradlePluginPortal() }
repositories { mavenLocal(); mavenCentral(); gradlePluginPortal(); maven { url "https://teavm.org/maven/repository" } }
dependencies {
compileOnly 'com.github.spotbugs:spotbugs-annotations:4.8.3'

Expand Down
2 changes: 1 addition & 1 deletion examples/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

ext {
teavm = '0.9.0'
teavm = '0.9.1'
}

repositories {
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/ru/vyarus/gradle/plugin/teavm/TeavmExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class TeavmExtension extends DevOptions {
/**
* Teavm version to use. Ignored when {@link #autoVersion} enabled.
*/
private String version = "0.9.1";
private String version = "0.10.0";

/**
* Source sets to compile js from. By default, java, kotlin and scala supported.
Expand Down Expand Up @@ -120,6 +120,10 @@ public class TeavmExtension extends DevOptions {
*/
private boolean stopOnErrors = true;

/**
* Top-level names limit. ONLY for JS target.
*/
private int maxTopLevelNames = 80_000;
/**
* Minimal heap size (in mb). ONLY for WASM and C targets.
*/
Expand Down Expand Up @@ -318,6 +322,14 @@ public void setStopOnErrors(final boolean stopOnErrors) {
this.stopOnErrors = stopOnErrors;
}

public int getMaxTopLevelNames() {
return maxTopLevelNames;
}

public void setMaxTopLevelNames(final int maxTopLevelNames) {
this.maxTopLevelNames = maxTopLevelNames;
}

public int getMinHeapSize() {
return minHeapSize;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ private void configureTask(final Project project, final TeavmExtension extension
task.getStopOnErrors().convention(extension.isStopOnErrors());
configureDevOptions(task, options);

task.getMaxTopLevelNames().convention(extension.getMaxTopLevelNames());
task.getMinHeapSize().convention(extension.getMinHeapSize());
task.getMaxHeapSize().convention(extension.getMaxHeapSize());
task.getTransformers().convention(extension.getTransformers());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ public interface CompileParameters extends WorkParameters {
*/
Property<Boolean> getAssertionsRemoved();

/**
* @return max top level names (JS target only)
*/
Property<Integer> getMaxTopLevelNames();

/**
* @return min heap size (WASM and C targets)
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ru.vyarus.gradle.plugin.teavm.task;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.io.FileUtils;
import org.gradle.workers.WorkAction;
import org.teavm.tooling.TeaVMProblemRenderer;
import org.teavm.tooling.TeaVMSourceFilePolicy;
Expand All @@ -21,7 +20,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;

/**
* TeaVM compilation worker. Worker used to execute teavm inside custom classpath (dynamic teavm version selection).
Expand Down Expand Up @@ -61,6 +59,7 @@ private void configure(final BuildStrategy build) {
build.setClassPathEntries(getParameters().getClassPathEntries().get());
build.setObfuscated(getParameters().getObfuscated().get());
build.setStrict(getParameters().getStrict().get());
build.setMaxTopLevelNames(getParameters().getMaxTopLevelNames().get());
build.setTargetDirectory(getParameters().getTargetDirectory().get().getAsFile().getAbsolutePath());

if (getParameters().getTransformers().isPresent()) {
Expand Down Expand Up @@ -123,19 +122,6 @@ private void run(final BuildStrategy build) throws Exception {
}

if (result.getProblems() == null || result.getProblems().getSevereProblems().isEmpty()) {
System.out.println("Resources used: " + result.getUsedResources().size());
if (getParameters().getDebug().get()) {
System.out.println(result.getUsedResources().stream()
.map(s -> "\t" + s).sorted().collect(Collectors.joining("\n")));

System.out.println("Generated files: " + result.getGeneratedFiles().size());
System.out.println(result.getGeneratedFiles().stream()
.map(s -> "\t" + s.replace(getParameters().getTargetDirectory().get().getAsFile()
.getAbsolutePath() + File.separator, "") + " ("
+ FileUtils.byteCountToDisplaySize(new File(s).length()) + ")")
.sorted()
.collect(Collectors.joining("\n ")));
}
System.out.println("Overall time: " + DurationFormatter.format(time));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ public abstract class TeavmCompileTask extends DefaultTask {
@Input
public abstract Property<Boolean> getAssertionsRemoved();

/**
* @return max top level names (JS target only)
*/
@Input
public abstract Property<Integer> getMaxTopLevelNames();

/**
* @return min heap size (WASM and C targets)
*/
Expand Down Expand Up @@ -312,6 +318,7 @@ private void runCompilation(final WorkQueue workQueue, final File resultFile) {
parameters.getFastDependencyAnalysis().set(getFastDependencyAnalysis());
parameters.getAssertionsRemoved().set(getAssertionsRemoved());

parameters.getMaxTopLevelNames().set(getMaxTopLevelNames());
parameters.getMinHeapSize().set(getMinHeapSize());
parameters.getMaxHeapSize().set(getMaxHeapSize());
parameters.getOptimizationLevel().set(getOptimizationLevel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,5 @@ Extra source directories:
\tsrc/foo/java
""")
out.contains('Resolved source artifacts for configuration\'runtimeClasspath\':')

out.contains("""Resources used: 29
\texample/Main.java
""")
out.contains("""Generated files: 2
\tclasses.js (12 KB)
\tclasses.js.map (2 KB)
""")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ class TeavmPluginTest extends AbstractTest {

task.getClassPath().get().collect { project.relativePath(it.asFile).replace(File.separator, '/')} as Set == [
'build/classes/java/main', 'build/resources/main', 'build/classes/foo'] as Set
task.dependencies.files.collect { it.getName()}.contains('teavm-classlib-0.9.1.jar')
task.dependencies.files.collect { it.getName()}.contains('teavm-classlib-0.10.0.jar')

task.getSources().get().collect { project.relativePath(it.asFile).replace(File.separator, '/')} as Set == [
'src/main/java', 'src/main/resources', 'src/foo/java'] as Set
task.sourceDependencies.files.collect { it.getName()}.contains('teavm-classlib-0.9.1-sources.jar')
task.sourceDependencies.files.collect { it.getName()}.contains('teavm-classlib-0.10.0-sources.jar')

project.relativePath(task.getTargetDir().get().asFile).replace(File.separator, '/') == 'build/teavm'
project.relativePath(task.getCacheDir().get().asFile).replace(File.separator, '/') == 'build/teavm-cache'
Expand All @@ -81,6 +81,7 @@ class TeavmPluginTest extends AbstractTest {
task.jsModuleType.get() == JSModuleType.ES2015
task.wasmVersion.get() == WasmBinaryVersion.V_0x1
task.stopOnErrors.get() == true
task.maxTopLevelNames.get() == 80000
task.minHeapSize.get() == 4
task.maxHeapSize.get() == 128
task.transformers.get() == ['com.bar.Other']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import org.gradle.testkit.runner.TaskOutcome
*/
class UpstreamKitTest extends AbstractKitTest {

String GRADLE_VERSION = '8.6'
String GRADLE_VERSION = '8.7'
// https://teavm.org/maven/repository/org/teavm/teavm-classlib/
String TEAVM_RECENT = '0.10.0-dev-8'
String TEAVM_RECENT = '0.10.0-dev-12'

def "Check plugin execution for the latest gradle"() {
setup:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import spock.lang.IgnoreIf
@IgnoreIf({ System.getenv('APPVEYOR') })
class VersionDetectionKitTest extends AbstractKitTest {

@Ignore // todo no compatible dev versions yet
def "Check teavm version auto detection from classpath"() {
setup:
build """
Expand All @@ -28,7 +27,7 @@ class VersionDetectionKitTest extends AbstractKitTest {
}
dependencies {
implementation "org.teavm:teavm-classlib:0.10.0-dev-5"
implementation "org.teavm:teavm-classlib:0.10.0-dev-12"
}
teavm {
Expand All @@ -54,7 +53,7 @@ public class Main {

then: "task successful"
result.task(':compileTeavm').outcome == TaskOutcome.SUCCESS
result.output.contains('TeaVM compiler version: 0.10.0-dev-5 (auto-detected)')
result.output.contains('TeaVM compiler version: 0.10.0-dev-12 (auto-detected)')
result.output.contains('Output file successfully built')
}

Expand All @@ -72,7 +71,7 @@ public class Main {
}
dependencies {
implementation "org.teavm:teavm-classlib:0.10.0-dev-5"
implementation "org.teavm:teavm-classlib:0.10.0-dev-12"
}
teavm {
Expand All @@ -98,7 +97,7 @@ public class Main {

then: "task successful"
result.task(':compileTeavm').outcome == TaskOutcome.SUCCESS
result.output.contains('TeaVM compiler version: 0.9.1')
result.output.contains('TeaVM compiler version: 0.10.0')
result.output.contains('Output file successfully built')
}
}

0 comments on commit f9af496

Please sign in to comment.