emptyList();
}
+ public void addSourceFileProvider(SourceFileProvider sourceFileProvider) {
+ sourceFileProviders.add(sourceFileProvider);
+ }
+
public void generate() throws TeaVMToolException {
try {
cancelled = false;
@@ -295,10 +309,14 @@ public class TeaVMTool {
writer.append("\n//# sourceMappingURL=").append(sourceMapsFileName);
try (Writer sourceMapsOut = new OutputStreamWriter(new FileOutputStream(
new File(targetDirectory, sourceMapsFileName)), "UTF-8")) {
- debugInfo.writeAsSourceMaps(sourceMapsOut, targetFileName);
+ debugInfo.writeAsSourceMaps(sourceMapsOut, "src", targetFileName);
}
log.info("Source maps successfully written");
}
+ if (sourceFilesCopied) {
+ copySourceFiles();
+ log.info("Source files successfully written");
+ }
if (incremental) {
programCache.flush();
astCache.flush();
@@ -335,6 +353,16 @@ public class TeaVMTool {
vm.checkForMissingItems();
}
+ private void copySourceFiles() {
+ if (vm.getWrittenClasses() == null) {
+ return;
+ }
+ SourceFilesCopier copier = new SourceFilesCopier(sourceFileProviders);
+ copier.addClasses(vm.getWrittenClasses());
+ copier.setLog(log);
+ copier.copy(new File(targetDirectory, "src"));
+ }
+
private AbstractRendererListener runtimeInjector = new AbstractRendererListener() {
@Override
public void begin(RenderingContext context, BuildTarget buildTarget) throws IOException {
diff --git a/teavm-core/src/main/java/org/teavm/vm/TeaVM.java b/teavm-core/src/main/java/org/teavm/vm/TeaVM.java
index 5d17956dc..74dbfc46f 100644
--- a/teavm-core/src/main/java/org/teavm/vm/TeaVM.java
+++ b/teavm-core/src/main/java/org/teavm/vm/TeaVM.java
@@ -85,6 +85,7 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
private boolean incremental;
private TeaVMProgressListener progressListener;
private boolean cancelled;
+ private ListableClassHolderSource writtenClasses;
TeaVM(ClassReaderSource classSource, ClassLoader classLoader) {
this.classSource = classSource;
@@ -312,6 +313,14 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
return dependencyChecker.getAchievableClasses();
}
+ public DependencyInfo getDependencyInfo() {
+ return dependencyChecker;
+ }
+
+ public ListableClassReaderSource getWrittenClasses() {
+ return writtenClasses;
+ }
+
/**
* After building checks whether the build has failed due to some missing items (classes, methods and fields).
* If it has failed, throws exception, containing report on all missing items.
@@ -378,6 +387,7 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
return;
}
ListableClassHolderSource classSet = link(dependencyChecker);
+ writtenClasses = classSet;
if (wasCancelled()) {
return;
}
diff --git a/teavm-maven/teavm-maven-plugin/pom.xml b/teavm-maven/teavm-maven-plugin/pom.xml
index 109a66204..f689cc002 100644
--- a/teavm-maven/teavm-maven-plugin/pom.xml
+++ b/teavm-maven/teavm-maven-plugin/pom.xml
@@ -43,6 +43,11 @@
maven-core
provided