mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
@@ -12,8 +12,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import io.quarkus.bootstrap.model.AppModel;
|
||||
|
||||
/**
|
||||
* Object that is used to pass context data from the plugin doing the invocation
|
||||
* into the dev mode process using java serialization.
|
||||
@@ -45,8 +43,6 @@ public class DevModeContext implements Serializable {
|
||||
private List<String> compilerPluginArtifacts;
|
||||
private List<String> compilerPluginsOptions;
|
||||
|
||||
private AppModel appModel;
|
||||
|
||||
public boolean isLocalProjectDiscovery() {
|
||||
return localProjectDiscovery;
|
||||
}
|
||||
@@ -173,15 +169,6 @@ public class DevModeContext implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public AppModel getAppModel() {
|
||||
return appModel;
|
||||
}
|
||||
|
||||
public DevModeContext setAppModel(AppModel appModel) {
|
||||
this.appModel = appModel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class ModuleInfo implements Serializable {
|
||||
|
||||
private final String name;
|
||||
|
||||
@@ -154,11 +154,16 @@ public class IsolatedDevModeMain implements BiConsumer<CuratedApplication, Map<S
|
||||
}
|
||||
}
|
||||
QuarkusConfigFactory.setConfig(null);
|
||||
final ConfigProviderResolver cpr = ConfigProviderResolver.instance();
|
||||
|
||||
ClassLoader old = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
|
||||
try {
|
||||
final ConfigProviderResolver cpr = ConfigProviderResolver.instance();
|
||||
cpr.releaseConfig(cpr.getConfig());
|
||||
} catch (Throwable ignored) {
|
||||
// just means no config was installed, which is fine
|
||||
} finally {
|
||||
Thread.currentThread().setContextClassLoader(old);
|
||||
}
|
||||
runner = null;
|
||||
}
|
||||
@@ -242,7 +247,7 @@ public class IsolatedDevModeMain implements BiConsumer<CuratedApplication, Map<S
|
||||
synchronized (DevModeMain.class) {
|
||||
if (runner != null) {
|
||||
try {
|
||||
runner.close();
|
||||
stop();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ import java.net.Socket;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -28,6 +30,7 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@@ -39,6 +42,7 @@ import org.gradle.api.artifacts.Dependency;
|
||||
import org.gradle.api.artifacts.DependencySet;
|
||||
import org.gradle.api.artifacts.ProjectDependency;
|
||||
import org.gradle.api.artifacts.ResolvedDependency;
|
||||
import org.gradle.api.file.FileCollection;
|
||||
import org.gradle.api.plugins.Convention;
|
||||
import org.gradle.api.plugins.JavaPlugin;
|
||||
import org.gradle.api.plugins.JavaPluginConvention;
|
||||
@@ -51,6 +55,7 @@ import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.api.tasks.compile.JavaCompile;
|
||||
import org.gradle.api.tasks.options.Option;
|
||||
|
||||
import io.quarkus.bootstrap.BootstrapConstants;
|
||||
import io.quarkus.bootstrap.model.AppArtifact;
|
||||
import io.quarkus.bootstrap.model.AppArtifactKey;
|
||||
import io.quarkus.bootstrap.model.AppDependency;
|
||||
@@ -293,8 +298,45 @@ public class QuarkusDev extends QuarkusTask {
|
||||
sourcePaths.add(sourceDir.getAbsolutePath());
|
||||
}
|
||||
|
||||
String classesPaths = mainSourceSet.getOutput().getClassesDirs().getAsPath();
|
||||
String resourcePaths = mainSourceSet.getResources().getSourceDirectories().getAsPath();
|
||||
FileCollection classesDirs = mainSourceSet.getOutput().getClassesDirs();
|
||||
final String classesPaths;
|
||||
Set<File> classDirFiles = classesDirs.getFiles();
|
||||
if (classDirFiles.size() == 1) {
|
||||
classesPaths = classesDirs.getAsPath();
|
||||
} else {
|
||||
//there does not seem to be any sane way of dealing with multiple output dirs, as there does not seem
|
||||
//to be a way to map them. We will need to address this at some point, but for now we just stick them
|
||||
//all in a temp dir
|
||||
|
||||
Path path = getTemporaryDir().toPath();
|
||||
classesPaths = path.toAbsolutePath().toString();
|
||||
for (File c : classDirFiles) {
|
||||
Path cd = c.toPath();
|
||||
if (!Files.exists(cd)) {
|
||||
continue;
|
||||
}
|
||||
try (Stream<Path> stream = Files.walk(cd)) {
|
||||
stream.forEach(s -> {
|
||||
try {
|
||||
if (Files.isDirectory(s)) {
|
||||
return;
|
||||
}
|
||||
final Path file = cd.relativize(path);
|
||||
final Path targetPath = path.resolve(file.toString());
|
||||
Files.createDirectories(targetPath.getParent());
|
||||
byte[] data = Files.readAllBytes(s);
|
||||
Files.write(targetPath, data);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String resourcePaths = mainSourceSet.getResources().getSourceDirectories().getSingleFile().getAbsolutePath(); //TODO: multiple resource directories
|
||||
|
||||
DevModeContext.ModuleInfo wsModuleInfo = new DevModeContext.ModuleInfo(
|
||||
dependencyProject.getName(),
|
||||
@@ -351,6 +393,13 @@ public class QuarkusDev extends QuarkusTask {
|
||||
obj.writeObject(context);
|
||||
obj.close();
|
||||
out.write(bytes.toByteArray());
|
||||
|
||||
out.putNextEntry(new ZipEntry(BootstrapConstants.SERIALIZED_APP_MODEL));
|
||||
bytes = new ByteArrayOutputStream();
|
||||
obj = new ObjectOutputStream(new DataOutputStream(bytes));
|
||||
obj.writeObject(appModel);
|
||||
obj.close();
|
||||
out.write(bytes.toByteArray());
|
||||
}
|
||||
|
||||
extension.outputDirectory().mkdirs();
|
||||
|
||||
@@ -213,10 +213,10 @@ public class BootstrapAppModelFactory {
|
||||
}
|
||||
|
||||
public CurationResult resolveAppModel() throws BootstrapException {
|
||||
if (test) {
|
||||
//gradle tests encode the result on the class path
|
||||
if (test || devMode) {
|
||||
//gradle tests and dev encode the result on the class path
|
||||
|
||||
try (InputStream existing = getClass().getResourceAsStream(BootstrapConstants.SERIALIZED_APP_MODEL)){
|
||||
try (InputStream existing = getClass().getClassLoader().getResourceAsStream(BootstrapConstants.SERIALIZED_APP_MODEL)){
|
||||
if(existing != null ) {
|
||||
AppModel appModel = (AppModel) new ObjectInputStream(existing).readObject();
|
||||
return new CurationResult(appModel);
|
||||
|
||||
@@ -26,7 +26,6 @@ import io.quarkus.bootstrap.model.AppArtifact;
|
||||
import io.quarkus.bootstrap.model.AppArtifactKey;
|
||||
import io.quarkus.bootstrap.model.AppDependency;
|
||||
import io.quarkus.bootstrap.model.AppModel;
|
||||
import io.quarkus.bootstrap.resolver.AppModelResolver;
|
||||
|
||||
/**
|
||||
* The result of the curate step that is done by QuarkusBootstrap.
|
||||
|
||||
Reference in New Issue
Block a user