use of io.quarkus.bootstrap.resolver.AppModelResolverException in project quarkus by quarkusio.
the class BootstrapUtils method deserializeQuarkusModel.
public static ApplicationModel deserializeQuarkusModel(Path modelPath) throws AppModelResolverException {
if (Files.exists(modelPath)) {
try (InputStream existing = Files.newInputStream(modelPath);
ObjectInputStream object = new ObjectInputStream(existing)) {
ApplicationModel model = (ApplicationModel) object.readObject();
IoUtils.recursiveDelete(modelPath);
return model;
} catch (IOException | ClassNotFoundException e) {
throw new AppModelResolverException("Failed to deserialize quarkus model", e);
}
}
throw new AppModelResolverException("Unable to locate quarkus model");
}
use of io.quarkus.bootstrap.resolver.AppModelResolverException in project quarkus by quarkusio.
the class IDEDevModeMain method accept.
@Override
public void accept(CuratedApplication curatedApplication, Map<String, Object> stringObjectMap) {
Path appClasses = (Path) stringObjectMap.get("app-classes");
DevModeContext devModeContext = new DevModeContext();
devModeContext.setArgs((String[]) stringObjectMap.get("args"));
ApplicationModel appModel = null;
try {
if (BuildToolHelper.isMavenProject(appClasses)) {
appModel = curatedApplication.getApplicationModel();
} else {
appModel = BootstrapUtils.deserializeQuarkusModel((Path) stringObjectMap.get(BootstrapConstants.SERIALIZED_APP_MODEL));
}
if (appModel != null) {
for (ResolvedDependency project : DependenciesFilter.getReloadableModules(appModel)) {
final ModuleInfo module = toModule(project);
if (project.getKey().equals(appModel.getAppArtifact().getKey()) && project.getVersion().equals(appModel.getAppArtifact().getVersion())) {
devModeContext.setApplicationRoot(module);
} else {
devModeContext.getAdditionalModules().add(module);
devModeContext.getLocalArtifacts().add(project.getKey());
}
}
}
} catch (AppModelResolverException e) {
log.error("Failed to load workspace, hot reload will not be available", e);
}
terminateIfRunning();
delegate = new IsolatedDevModeMain();
Map<String, Object> params = new HashMap<>();
params.put(DevModeContext.class.getName(), devModeContext);
params.put(DevModeType.class.getName(), DevModeType.LOCAL);
delegate.accept(curatedApplication, params);
}
use of io.quarkus.bootstrap.resolver.AppModelResolverException in project quarkus by quarkusio.
the class AppModelGradleResolver method resolveArtifact.
private ResolvedDependency resolveArtifact(ArtifactCoords appArtifact) throws AppModelResolverException {
if (ResolvedDependency.class.isAssignableFrom(appArtifact.getClass())) {
final ResolvedDependency resolved = (ResolvedDependency) appArtifact;
if (resolved.isResolved()) {
return resolved;
}
}
final DefaultDependencyArtifact dep = new DefaultDependencyArtifact();
dep.setExtension(appArtifact.getType());
dep.setType(appArtifact.getType());
dep.setName(appArtifact.getArtifactId());
if (appArtifact.getClassifier() != null) {
dep.setClassifier(appArtifact.getClassifier());
}
final DefaultExternalModuleDependency gradleDep = new DefaultExternalModuleDependency(appArtifact.getGroupId(), appArtifact.getArtifactId(), appArtifact.getVersion(), null);
gradleDep.addArtifact(dep);
final Configuration detachedConfig = project.getConfigurations().detachedConfiguration(gradleDep);
final ResolvedConfiguration rc = detachedConfig.getResolvedConfiguration();
Set<ResolvedArtifact> resolvedArtifacts;
try {
resolvedArtifacts = rc.getResolvedArtifacts();
} catch (ResolveException e) {
throw new AppModelResolverException("Failed to resolve " + appArtifact, e);
}
for (ResolvedArtifact a : resolvedArtifacts) {
if (appArtifact.getArtifactId().equals(a.getName()) && appArtifact.getType().equals(a.getType()) && (a.getClassifier() == null ? appArtifact.getClassifier() == null : a.getClassifier().equals(appArtifact.getClassifier())) && appArtifact.getGroupId().equals(a.getModuleVersion().getId().getGroup())) {
final String version = appArtifact.getVersion().equals(a.getModuleVersion().getId().getVersion()) ? appArtifact.getVersion() : a.getModuleVersion().getId().getVersion();
return new ResolvedArtifactDependency(appArtifact.getGroupId(), appArtifact.getArtifactId(), appArtifact.getClassifier(), appArtifact.getType(), version, a.getFile().toPath());
}
}
throw new AppModelResolverException("Failed to resolve " + appArtifact);
}
use of io.quarkus.bootstrap.resolver.AppModelResolverException in project quarkus by quarkusio.
the class QuarkusBuild method buildQuarkus.
@TaskAction
public void buildQuarkus() {
final ApplicationModel appModel;
try {
appModel = extension().getAppModelResolver().resolveModel(new GACTV(getProject().getGroup().toString(), getProject().getName(), getProject().getVersion().toString()));
} catch (AppModelResolverException e) {
throw new GradleException("Failed to resolve Quarkus application model for " + getProject().getPath(), e);
}
final Properties effectiveProperties = getBuildSystemProperties(appModel.getAppArtifact());
if (ignoredEntries != null && ignoredEntries.size() > 0) {
String joinedEntries = String.join(",", ignoredEntries);
effectiveProperties.setProperty("quarkus.package.user-configured-ignored-entries", joinedEntries);
}
exportCustomManifestProperties(effectiveProperties);
try (CuratedApplication appCreationContext = QuarkusBootstrap.builder().setBaseClassLoader(getClass().getClassLoader()).setExistingModel(appModel).setTargetDirectory(getProject().getBuildDir().toPath()).setBaseName(extension().finalName()).setBuildSystemProperties(effectiveProperties).setAppArtifact(appModel.getAppArtifact()).setLocalProjectDiscovery(false).setIsolateDeployment(true).build().bootstrap()) {
// Processes launched from within the build task of Gradle (daemon) lose content
// generated on STDOUT/STDERR by the process (see https://github.com/gradle/gradle/issues/13522).
// We overcome this by letting build steps know that the STDOUT/STDERR should be explicitly
// streamed, if they need to make available that generated data.
// The io.quarkus.deployment.pkg.builditem.ProcessInheritIODisabled$Factory
// does the necessary work to generate such a build item which the build step(s) can rely on
appCreationContext.createAugmentor("io.quarkus.deployment.pkg.builditem.ProcessInheritIODisabled$Factory", Collections.emptyMap()).createProductionApplication();
} catch (BootstrapException e) {
throw new GradleException("Failed to build a runnable JAR", e);
}
}
use of io.quarkus.bootstrap.resolver.AppModelResolverException in project quarkus by quarkusio.
the class GradleApplicationModelBuilder method resolvePlatformImports.
private PlatformImports resolvePlatformImports(Project project, List<org.gradle.api.artifacts.Dependency> deploymentDeps) {
final Configuration boms = project.getConfigurations().detachedConfiguration(deploymentDeps.toArray(new org.gradle.api.artifacts.Dependency[0]));
final PlatformImportsImpl platformImports = new PlatformImportsImpl();
boms.getResolutionStrategy().eachDependency(d -> {
final String group = d.getTarget().getGroup();
final String name = d.getTarget().getName();
if (name.endsWith(BootstrapConstants.PLATFORM_DESCRIPTOR_ARTIFACT_ID_SUFFIX)) {
platformImports.addPlatformDescriptor(group, name, d.getTarget().getVersion(), "json", d.getTarget().getVersion());
} else if (name.endsWith(BootstrapConstants.PLATFORM_PROPERTIES_ARTIFACT_ID_SUFFIX)) {
final DefaultDependencyArtifact dep = new DefaultDependencyArtifact();
dep.setExtension("properties");
dep.setType("properties");
dep.setName(name);
final DefaultExternalModuleDependency gradleDep = new DefaultExternalModuleDependency(group, name, d.getTarget().getVersion(), null);
gradleDep.addArtifact(dep);
for (ResolvedArtifact a : project.getConfigurations().detachedConfiguration(gradleDep).getResolvedConfiguration().getResolvedArtifacts()) {
if (a.getName().equals(name)) {
try {
platformImports.addPlatformProperties(group, name, null, "properties", d.getTarget().getVersion(), a.getFile().toPath());
} catch (AppModelResolverException e) {
throw new GradleException("Failed to import platform properties " + a.getFile(), e);
}
break;
}
}
}
});
boms.getResolvedConfiguration();
return platformImports;
}
Aggregations