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