mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Trying to fix problem with locked files on Windows
This commit is contained in:
parent
efe15e323b
commit
071a5d90fb
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Copyright 2018 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.builder;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
public interface ClassLoaderFactory {
|
||||
ClassLoader create(URL[] urls, ClassLoader innerClassLoader);
|
||||
}
|
|
@ -16,14 +16,15 @@
|
|||
package org.teavm.tooling.builder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.teavm.backend.wasm.render.WasmBinaryVersion;
|
||||
import org.teavm.callgraph.CallGraph;
|
||||
|
@ -40,7 +41,6 @@ import org.teavm.vm.TeaVMOptimizationLevel;
|
|||
import org.teavm.vm.TeaVMProgressListener;
|
||||
|
||||
public class InProcessBuildStrategy implements BuildStrategy {
|
||||
private final ClassLoaderFactory classLoaderFactory;
|
||||
private List<String> classPathEntries = new ArrayList<>();
|
||||
private TeaVMTargetType targetType;
|
||||
private String mainClass;
|
||||
|
@ -71,10 +71,6 @@ public class InProcessBuildStrategy implements BuildStrategy {
|
|||
private boolean shortFileNames;
|
||||
private boolean assertionsRemoved;
|
||||
|
||||
public InProcessBuildStrategy(ClassLoaderFactory classLoaderFactory) {
|
||||
this.classLoaderFactory = classLoaderFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
sourceFileProviders.clear();
|
||||
|
@ -242,7 +238,8 @@ public class InProcessBuildStrategy implements BuildStrategy {
|
|||
tool.setEntryPointName(entryPointName);
|
||||
tool.setTargetDirectory(new File(targetDirectory));
|
||||
tool.setTargetFileName(targetFileName);
|
||||
tool.setClassLoader(buildClassLoader());
|
||||
var classLoader = buildClassLoader();
|
||||
tool.setClassLoader(classLoader);
|
||||
tool.setOptimizationLevel(optimizationLevel);
|
||||
tool.setFastDependencyAnalysis(fastDependencyAnalysis);
|
||||
|
||||
|
@ -273,11 +270,12 @@ public class InProcessBuildStrategy implements BuildStrategy {
|
|||
|
||||
try {
|
||||
tool.generate();
|
||||
} catch (TeaVMToolException | RuntimeException | Error e) {
|
||||
classLoader.close();
|
||||
} catch (TeaVMToolException | RuntimeException | Error | IOException e) {
|
||||
throw new BuildException(e);
|
||||
}
|
||||
|
||||
Set<String> generatedFiles = tool.getGeneratedFiles().stream()
|
||||
var generatedFiles = tool.getGeneratedFiles().stream()
|
||||
.map(File::getAbsolutePath)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
|
@ -285,7 +283,7 @@ public class InProcessBuildStrategy implements BuildStrategy {
|
|||
tool.getProblemProvider(), tool.getClasses(), tool.getUsedResources(), generatedFiles);
|
||||
}
|
||||
|
||||
private ClassLoader buildClassLoader() {
|
||||
private URLClassLoader buildClassLoader() {
|
||||
URL[] urls = classPathEntries.stream().map(entry -> {
|
||||
try {
|
||||
return new File(entry).toURI().toURL();
|
||||
|
@ -294,7 +292,7 @@ public class InProcessBuildStrategy implements BuildStrategy {
|
|||
}
|
||||
}).toArray(URL[]::new);
|
||||
|
||||
return classLoaderFactory.create(urls, InProcessBuildStrategy.class.getClassLoader());
|
||||
return new URLClassLoader(urls, InProcessBuildStrategy.class.getClassLoader());
|
||||
}
|
||||
|
||||
static class InProcessBuildResult implements BuildResult {
|
||||
|
|
|
@ -17,7 +17,6 @@ package org.teavm.gradle.tasks;
|
|||
|
||||
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;
|
||||
|
@ -104,7 +103,7 @@ public abstract class TeaVMTask extends DefaultTask {
|
|||
if (getOutOfProcess().get()) {
|
||||
executeInSeparateProcess();
|
||||
} else {
|
||||
executeWithBuilder(new InProcessBuildStrategy(URLClassLoader::new));
|
||||
executeWithBuilder(new InProcessBuildStrategy());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package org.teavm.maven;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URLClassLoader;
|
||||
import java.rmi.NotBoundException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.registry.LocateRegistry;
|
||||
|
@ -251,7 +250,7 @@ public class TeaVMCompileMojo extends AbstractMojo {
|
|||
if (outOfProcess) {
|
||||
executeInSeparateProcess();
|
||||
} else {
|
||||
executeWithBuilder(new InProcessBuildStrategy(URLClassLoader::new));
|
||||
executeWithBuilder(new InProcessBuildStrategy());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user