diff --git a/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java b/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java index 6a9c5fe76..953b980cc 100644 --- a/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java +++ b/tools/core/src/main/java/org/teavm/tooling/TeaVMTool.java @@ -101,6 +101,7 @@ public class TeaVMTool implements BaseTeaVMTool { private JavaScriptTarget javaScriptTarget; private WasmTarget webAssemblyTarget; private WasmBinaryVersion wasmVersion = WasmBinaryVersion.V_0x1; + private Set generatedFiles = new HashSet<>(); public File getTargetDirectory() { return targetDirectory; @@ -276,6 +277,10 @@ public class TeaVMTool implements BaseTeaVMTool { return vm != null ? vm.getClasses() : Collections.emptyList(); } + public Set getGeneratedFiles() { + return generatedFiles; + } + public Collection getUsedResources() { if (vm == null) { return Collections.emptyList(); @@ -443,6 +448,9 @@ public class TeaVMTool implements BaseTeaVMTool { TeaVMProblemRenderer.describeProblems(vm, log); } + File outputFile = new File(targetDirectory, outputName); + generatedFiles.add(outputFile); + if (targetType == TeaVMTargetType.JAVASCRIPT) { try (OutputStream output = new FileOutputStream(new File(targetDirectory, outputName), true)) { try (Writer writer = new OutputStreamWriter(output, "UTF-8")) { @@ -488,10 +496,11 @@ public class TeaVMTool implements BaseTeaVMTool { if (debugInformationGenerated) { assert debugEmitter != null; DebugInformation debugInfo = debugEmitter.getDebugInformation(); - try (OutputStream debugInfoOut = new BufferedOutputStream(new FileOutputStream(new File(targetDirectory, - getResolvedTargetFileName() + ".teavmdbg")))) { + File debugSymbolFile = new File(targetDirectory, getResolvedTargetFileName() + ".teavmdbg"); + try (OutputStream debugInfoOut = new BufferedOutputStream(new FileOutputStream(debugSymbolFile))) { debugInfo.write(debugInfoOut); } + generatedFiles.add(debugSymbolFile); log.info("Debug information successfully written"); } if (sourceMapsFileGenerated) { @@ -499,8 +508,8 @@ public class TeaVMTool implements BaseTeaVMTool { DebugInformation debugInfo = debugEmitter.getDebugInformation(); String sourceMapsFileName = getResolvedTargetFileName() + ".map"; writer.append("\n//# sourceMappingURL=").append(sourceMapsFileName); - try (Writer sourceMapsOut = new OutputStreamWriter(new FileOutputStream( - new File(targetDirectory, sourceMapsFileName)), "UTF-8")) { + File sourceMapsFile = new File(targetDirectory, sourceMapsFileName); + try (Writer sourceMapsOut = new OutputStreamWriter(new FileOutputStream(sourceMapsFile), "UTF-8")) { debugInfo.writeAsSourceMaps(sourceMapsOut, "src", getResolvedTargetFileName()); } log.info("Source maps successfully written"); @@ -548,9 +557,11 @@ public class TeaVMTool implements BaseTeaVMTool { private void resourceToFile(String resource, String fileName) throws IOException { try (InputStream input = TeaVMTool.class.getClassLoader().getResourceAsStream(resource)) { - try (OutputStream output = new FileOutputStream(new File(targetDirectory, fileName))) { + File outputFile = new File(targetDirectory, fileName); + try (OutputStream output = new FileOutputStream(outputFile)) { IOUtils.copy(input, output); } + generatedFiles.add(outputFile); } } diff --git a/tools/idea/jps-common/src/main/java/org/teavm/idea/jps/model/TeaVMBuildResult.java b/tools/idea/jps-common/src/main/java/org/teavm/idea/jps/model/TeaVMBuildResult.java index ea89cdecb..e0a291f82 100644 --- a/tools/idea/jps-common/src/main/java/org/teavm/idea/jps/model/TeaVMBuildResult.java +++ b/tools/idea/jps-common/src/main/java/org/teavm/idea/jps/model/TeaVMBuildResult.java @@ -29,4 +29,6 @@ public interface TeaVMBuildResult { Collection getUsedResources(); Collection getClasses(); + + Collection getGeneratedFiles(); } diff --git a/tools/idea/jps-common/src/main/java/org/teavm/idea/jps/remote/TeaVMRemoteBuildResponse.java b/tools/idea/jps-common/src/main/java/org/teavm/idea/jps/remote/TeaVMRemoteBuildResponse.java index 5cad11c0c..0fddf69a5 100644 --- a/tools/idea/jps-common/src/main/java/org/teavm/idea/jps/remote/TeaVMRemoteBuildResponse.java +++ b/tools/idea/jps-common/src/main/java/org/teavm/idea/jps/remote/TeaVMRemoteBuildResponse.java @@ -30,4 +30,5 @@ public class TeaVMRemoteBuildResponse implements Serializable { public final List severeProblems = new ArrayList<>(); public final Set usedResources = new HashSet<>(); public final Set classes = new HashSet<>(); + public final Set generatedFiles = new HashSet<>(); } diff --git a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/InProcessBuildStrategy.java b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/InProcessBuildStrategy.java index 6465005fc..430e0b9ef 100644 --- a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/InProcessBuildStrategy.java +++ b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/InProcessBuildStrategy.java @@ -21,6 +21,8 @@ import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; import org.jetbrains.jps.incremental.CompileContext; import org.jetbrains.jps.incremental.messages.CompilerMessage; import org.teavm.callgraph.CallGraph; @@ -137,8 +139,12 @@ public class InProcessBuildStrategy implements TeaVMBuildStrategy { errorOccurred = true; } + Set generatedFiles = tool.getGeneratedFiles().stream() + .map(File::getAbsolutePath) + .collect(Collectors.toSet()); + return new InProcessBuildResult(tool.getDependencyInfo().getCallGraph(), errorOccurred, - tool.getProblemProvider(), tool.getClasses(), tool.getUsedResources()); + tool.getProblemProvider(), tool.getClasses(), tool.getUsedResources(), generatedFiles); } private ClassLoader buildClassLoader() { @@ -161,14 +167,16 @@ public class InProcessBuildStrategy implements TeaVMBuildStrategy { private ProblemProvider problemProvider; private Collection classes; private Collection usedResources; + private Collection generatedFiles; InProcessBuildResult(CallGraph callGraph, boolean errorOccurred, ProblemProvider problemProvider, - Collection classes, Collection usedResources) { + Collection classes, Collection usedResources, Collection generatedFiles) { this.callGraph = callGraph; this.errorOccurred = errorOccurred; this.problemProvider = problemProvider; this.classes = classes; this.usedResources = usedResources; + this.generatedFiles = generatedFiles; } @Override @@ -195,5 +203,10 @@ public class InProcessBuildStrategy implements TeaVMBuildStrategy { public Collection getUsedResources() { return usedResources; } + + @Override + public Collection getGeneratedFiles() { + return generatedFiles; + } } } diff --git a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/RemoteBuildStrategy.java b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/RemoteBuildStrategy.java index f4b28d833..b4287cec9 100644 --- a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/RemoteBuildStrategy.java +++ b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/RemoteBuildStrategy.java @@ -142,6 +142,11 @@ public class RemoteBuildStrategy implements TeaVMBuildStrategy { public Collection getClasses() { return response.classes; } + + @Override + public Collection getGeneratedFiles() { + return response.generatedFiles; + } }; } diff --git a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java index 718fce5f8..421891eaf 100644 --- a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java +++ b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuild.java @@ -34,8 +34,8 @@ import java.util.Objects; import java.util.Queue; import java.util.Set; import java.util.stream.Stream; +import org.jetbrains.jps.builders.BuildOutputConsumer; import org.jetbrains.jps.incremental.CompileContext; -import org.jetbrains.jps.incremental.ModuleBuildTarget; import org.jetbrains.jps.incremental.messages.BuildMessage; import org.jetbrains.jps.incremental.messages.CompilerMessage; import org.jetbrains.jps.incremental.messages.ProgressMessage; @@ -65,50 +65,35 @@ import org.teavm.model.CallLocation; import org.teavm.model.MethodReference; import org.teavm.model.TextLocation; import org.teavm.model.ValueType; -import org.teavm.tooling.TeaVMTargetType; import org.teavm.vm.TeaVMPhase; import org.teavm.vm.TeaVMProgressFeedback; import org.teavm.vm.TeaVMProgressListener; class TeaVMBuild { private final CompileContext context; - private final TeaVMStorageProvider jsStorageProvider = new TeaVMStorageProvider("js"); - private final TeaVMStorageProvider wasmStorageProvider = new TeaVMStorageProvider("wasm"); private final List classPathEntries = new ArrayList<>(); private List directoryClassPathEntries; - private Map storages = new HashMap<>(); + private TeaVMStorage storage; private final TeaVMBuilderAssistant assistant; private final Map sourceFileCache = new HashMap<>(); private final Map fileLineCache = new HashMap<>(); private TeaVMBuildStrategy buildStrategy; + private BuildOutputConsumer outputConsumer; - TeaVMBuild(CompileContext context, TeaVMBuilderAssistant assistant, TeaVMBuildStrategy buildStrategy) { + TeaVMBuild(CompileContext context, TeaVMBuilderAssistant assistant, TeaVMBuildStrategy buildStrategy, + BuildOutputConsumer outputConsumer) { this.context = context; this.assistant = assistant; this.buildStrategy = buildStrategy; + this.outputConsumer = outputConsumer; } - boolean perform(JpsModule module, ModuleBuildTarget target) throws IOException { - storages.put(TeaVMTargetType.JAVASCRIPT, context.getProjectDescriptor().dataManager.getStorage( - target, jsStorageProvider)); - storages.put(TeaVMTargetType.WEBASSEMBLY, context.getProjectDescriptor().dataManager.getStorage( - target, wasmStorageProvider)); + boolean perform(JpsModule module, TeaVMBuildTarget target) throws IOException { + TeaVMStorageProvider storageProvider = new TeaVMStorageProvider( + target.getConfiguration().getTargetType().name()); + storage = context.getProjectDescriptor().dataManager.getStorage(target, storageProvider); - boolean doneSomething = false; - for (TeaVMJpsConfiguration config : TeaVMJpsConfiguration.getAll(module)) { - if (performForSubsystem(module, target, config)) { - doneSomething = true; - } - } - - return doneSomething; - } - - private boolean performForSubsystem(JpsModule module, ModuleBuildTarget target, TeaVMJpsConfiguration config) - throws IOException { - if (config == null) { - return false; - } + TeaVMJpsConfiguration config = target.getConfiguration(); classPathEntries.clear(); buildStrategy.init(); @@ -116,7 +101,7 @@ class TeaVMBuild { directoryClassPathEntries = classPathEntries.stream().filter(name -> new File(name).isDirectory()) .collect(toList()); - if (!hasChanges(target, config.getTargetType())) { + if (!hasChanges(target)) { return false; } @@ -131,11 +116,15 @@ class TeaVMBuild { TeaVMBuildResult buildResult = buildStrategy.build(); if (!buildResult.isErrorOccurred() && buildResult.getProblems().getSevereProblems().isEmpty()) { - updateStorage(buildResult, config.getTargetType()); + updateStorage(buildResult); } reportProblems(buildResult.getProblems(), buildResult.getCallGraph()); + for (String fileName : buildResult.getGeneratedFiles()) { + outputConsumer.registerOutputFile(new File(fileName), Collections.emptyList()); + } + return true; } @@ -410,13 +399,13 @@ class TeaVMBuild { return lines.getAll(); } - private boolean hasChanges(ModuleBuildTarget target, TeaVMTargetType targetType) { + private boolean hasChanges(TeaVMBuildTarget target) { if (!context.getScope().isBuildIncrementally(target.getTargetType()) || context.getScope().isBuildForced(target)) { return true; } - List filesToWatch = storages.get(targetType).getParticipatingFiles(); + List filesToWatch = storage.getParticipatingFiles(); if (filesToWatch == null) { return true; } @@ -430,7 +419,7 @@ class TeaVMBuild { return false; } - private void updateStorage(TeaVMBuildResult buildResult, TeaVMTargetType targetType) { + private void updateStorage(TeaVMBuildResult buildResult) { Set resources = Stream.concat(buildResult.getClasses().stream() .map(cls -> cls.replace('.', '/') + ".class"), buildResult.getUsedResources().stream()) .sorted() @@ -443,7 +432,7 @@ class TeaVMBuild { .filter(Objects::nonNull) .collect(toList()); - storages.get(targetType).setParticipatingFiles(participatingFiles); + storage.setParticipatingFiles(participatingFiles); } private Long getTimestamp(String path) { diff --git a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuildTarget.java b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuildTarget.java new file mode 100644 index 000000000..06a9f0d99 --- /dev/null +++ b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuildTarget.java @@ -0,0 +1,93 @@ +/* + * Copyright 2017 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.idea.jps; + +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jps.builders.BuildRootDescriptor; +import org.jetbrains.jps.builders.BuildRootIndex; +import org.jetbrains.jps.builders.BuildTarget; +import org.jetbrains.jps.builders.BuildTargetRegistry; +import org.jetbrains.jps.builders.ModuleBasedTarget; +import org.jetbrains.jps.builders.TargetOutputIndex; +import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType; +import org.jetbrains.jps.builders.storage.BuildDataPaths; +import org.jetbrains.jps.incremental.CompileContext; +import org.jetbrains.jps.incremental.ModuleBuildTarget; +import org.jetbrains.jps.indices.IgnoredFileIndex; +import org.jetbrains.jps.indices.ModuleExcludeIndex; +import org.jetbrains.jps.model.JpsModel; +import org.jetbrains.jps.model.module.JpsModule; +import org.teavm.idea.jps.model.TeaVMJpsConfiguration; + +public class TeaVMBuildTarget extends ModuleBasedTarget { + private TeaVMJpsConfiguration configuration; + + public TeaVMBuildTarget(TeaVMBuildTargetType targetType, @NotNull JpsModule module, + @NotNull TeaVMJpsConfiguration configuration) { + super(targetType, module); + this.configuration = configuration; + } + + @Override + public boolean isTests() { + return false; + } + + @Override + public String getId() { + return getModule().getName() + "-" + configuration.getTargetType().name(); + } + + @Override + public Collection> computeDependencies(BuildTargetRegistry targetRegistry, + TargetOutputIndex outputIndex) { + return Collections.singleton(new ModuleBuildTarget(myModule, JavaModuleBuildTargetType.PRODUCTION)); + } + + @NotNull + @Override + public List computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, + IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) { + return Collections.emptyList(); + } + + @Nullable + @Override + public BuildRootDescriptor findRootDescriptor(String rootId, BuildRootIndex rootIndex) { + return null; + } + + @NotNull + @Override + public String getPresentableName() { + return "TeaVM configuration '" + getModule().getName() + "' - " + configuration.getTargetType(); + } + + @NotNull + @Override + public Collection getOutputRoots(CompileContext context) { + return Collections.singleton(new File(configuration.getTargetDirectory())); + } + + public TeaVMJpsConfiguration getConfiguration() { + return configuration; + } +} diff --git a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuildTargetType.java b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuildTargetType.java new file mode 100644 index 000000000..f4d4fad7d --- /dev/null +++ b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuildTargetType.java @@ -0,0 +1,97 @@ +/* + * Copyright 2017 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.idea.jps; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jps.builders.BuildTargetLoader; +import org.jetbrains.jps.builders.ModuleBasedBuildTargetType; +import org.jetbrains.jps.model.JpsModel; +import org.jetbrains.jps.model.module.JpsModule; +import org.teavm.idea.jps.model.TeaVMJpsConfiguration; +import org.teavm.tooling.TeaVMTargetType; + +public class TeaVMBuildTargetType extends ModuleBasedBuildTargetType { + public static final String ID = "teavm"; + public static final TeaVMBuildTargetType INSTANCE = new TeaVMBuildTargetType(); + + private TeaVMBuildTargetType() { + super(ID); + } + + @NotNull + @Override + public List computeAllTargets(@NotNull JpsModel model) { + List targets = new ArrayList<>(); + for (JpsModule module : model.getProject().getModules()) { + for (TeaVMJpsConfiguration config : TeaVMJpsConfiguration.getAll(module)) { + targets.add(new TeaVMBuildTarget(this, module, config)); + } + } + return targets; + } + + @NotNull + @Override + public BuildTargetLoader createLoader(@NotNull JpsModel model) { + return new Loader(model); + } + + class Loader extends BuildTargetLoader { + private final Map modules; + + public Loader(JpsModel model) { + modules = new HashMap<>(); + for (JpsModule module : model.getProject().getModules()) { + for (TeaVMJpsConfiguration config : TeaVMJpsConfiguration.getAll(module)) { + modules.put(module.getName() + "-" + config.getTargetType().name(), + new Configuration(module, config.getTargetType())); + } + } + } + + @Nullable + @Override + public TeaVMBuildTarget createTarget(@NotNull String targetId) { + Configuration configuration = modules.get(targetId); + if (configuration == null) { + return null; + } + + for (TeaVMJpsConfiguration jpsConfig : TeaVMJpsConfiguration.getAll(configuration.module)) { + if (jpsConfig.getTargetType() == configuration.type) { + return new TeaVMBuildTarget(TeaVMBuildTargetType.this, configuration.module, jpsConfig); + } + } + + return null; + } + } + + class Configuration { + final JpsModule module; + final TeaVMTargetType type; + + public Configuration(@NotNull JpsModule module, @NotNull TeaVMTargetType type) { + this.module = module; + this.type = type; + } + } +} diff --git a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuilder.java b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuilder.java index 3db7a635e..934255721 100644 --- a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuilder.java +++ b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuilder.java @@ -21,28 +21,26 @@ import java.rmi.NotBoundException; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; +import java.util.Collections; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jps.ModuleChunk; +import org.jetbrains.jps.builders.BuildOutputConsumer; +import org.jetbrains.jps.builders.BuildRootDescriptor; import org.jetbrains.jps.builders.DirtyFilesHolder; -import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor; -import org.jetbrains.jps.incremental.BuilderCategory; import org.jetbrains.jps.incremental.CompileContext; -import org.jetbrains.jps.incremental.ModuleBuildTarget; -import org.jetbrains.jps.incremental.ModuleLevelBuilder; import org.jetbrains.jps.incremental.ProjectBuildException; +import org.jetbrains.jps.incremental.TargetBuilder; import org.jetbrains.jps.incremental.messages.BuildMessage; import org.jetbrains.jps.incremental.messages.CompilerMessage; -import org.jetbrains.jps.model.module.JpsModule; import org.teavm.idea.jps.model.TeaVMBuildStrategy; import org.teavm.idea.jps.remote.TeaVMBuilderAssistant; import org.teavm.idea.jps.remote.TeaVMRemoteBuildService; -public class TeaVMBuilder extends ModuleLevelBuilder { +public class TeaVMBuilder extends TargetBuilder { private TeaVMBuilderAssistant assistant; private TeaVMRemoteBuildService buildService; public TeaVMBuilder() { - super(BuilderCategory.CLASS_POST_PROCESSOR); + super(Collections.singletonList(TeaVMBuildTargetType.INSTANCE)); String portString = System.getProperty(REMOTE_PORT); if (portString != null) { @@ -66,28 +64,21 @@ public class TeaVMBuilder extends ModuleLevelBuilder { } @Override - public ExitCode build(CompileContext context, ModuleChunk chunk, - DirtyFilesHolder dirtyFilesHolder, - OutputConsumer outputConsumer) throws ProjectBuildException, IOException { + public void build(@NotNull TeaVMBuildTarget target, + @NotNull DirtyFilesHolder holder, + @NotNull BuildOutputConsumer outputConsumer, @NotNull CompileContext context) throws ProjectBuildException, + IOException { if (assistant == null) { context.processMessage(new CompilerMessage("TeaVM", BuildMessage.Kind.WARNING, "No TeaVM builder assistant available. Diagnostic messages will be less informative")); } - boolean doneSomething = false; - TeaVMBuildStrategy buildStrategy = buildService != null ? new RemoteBuildStrategy(buildService) : new InProcessBuildStrategy(context); - TeaVMBuild build = new TeaVMBuild(context, assistant, buildStrategy); - for (JpsModule module : chunk.getModules()) { - doneSomething |= build.perform(module, chunk.representativeTarget()); - if (context.getCancelStatus().isCanceled()) { - return ExitCode.ABORT; - } - } + TeaVMBuild build = new TeaVMBuild(context, assistant, buildStrategy, outputConsumer); - return doneSomething ? ExitCode.OK : ExitCode.NOTHING_DONE; + build.perform(target.getModule(), target); } @NotNull diff --git a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuilderService.java b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuilderService.java index 96725390c..ba84a0a7e 100644 --- a/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuilderService.java +++ b/tools/idea/jps-plugin/src/main/java/org/teavm/idea/jps/TeaVMBuilderService.java @@ -15,38 +15,24 @@ */ package org.teavm.idea.jps; -import java.io.IOException; -import java.net.URL; import java.util.Arrays; import java.util.Collections; -import java.util.Enumeration; import java.util.List; import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.builders.BuildTargetType; import org.jetbrains.jps.incremental.BuilderService; -import org.jetbrains.jps.incremental.ModuleLevelBuilder; import org.jetbrains.jps.incremental.TargetBuilder; public class TeaVMBuilderService extends BuilderService { @NotNull @Override - public List createModuleLevelBuilders() { - try { - Enumeration resources = TeaVMBuilderService.class.getClassLoader().getResources( - "org/objectweb/asm/ClassVisitor.class"); - while (resources.hasMoreElements()) { - URL url = resources.nextElement(); - System.out.println(url); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - System.out.println(); + public List> createBuilders() { return Arrays.asList(new TeaVMBuilder()); } @NotNull @Override - public List> createBuilders() { - return Collections.emptyList(); + public List> getTargetTypes() { + return Collections.singletonList(TeaVMBuildTargetType.INSTANCE); } } diff --git a/tools/idea/plugin/src/main/java/org/teavm/idea/daemon/TeaVMBuildDaemon.java b/tools/idea/plugin/src/main/java/org/teavm/idea/daemon/TeaVMBuildDaemon.java index 66abe2d94..361d19205 100644 --- a/tools/idea/plugin/src/main/java/org/teavm/idea/daemon/TeaVMBuildDaemon.java +++ b/tools/idea/plugin/src/main/java/org/teavm/idea/daemon/TeaVMBuildDaemon.java @@ -142,6 +142,9 @@ public class TeaVMBuildDaemon extends UnicastRemoteObject implements TeaVMRemote response.severeProblems.addAll(tool.getProblemProvider().getSevereProblems()); response.classes.addAll(tool.getClasses()); response.usedResources.addAll(tool.getUsedResources()); + response.generatedFiles.addAll(tool.getGeneratedFiles().stream() + .map(File::getAbsolutePath) + .collect(Collectors.toSet())); return response; }