use of io.quarkus.bootstrap.BootstrapException 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.BootstrapException in project quarkus by quarkusio.
the class QuarkusGenerateCode method prepareQuarkus.
@TaskAction
public void prepareQuarkus() {
LaunchMode launchMode = test ? LaunchMode.TEST : devMode ? LaunchMode.DEVELOPMENT : LaunchMode.NORMAL;
final ApplicationModel appModel = extension().getApplicationModel(launchMode);
final Properties realProperties = getBuildSystemProperties(appModel.getAppArtifact());
Path buildDir = getProject().getBuildDir().toPath();
try (CuratedApplication appCreationContext = QuarkusBootstrap.builder().setBaseClassLoader(getClass().getClassLoader()).setExistingModel(appModel).setTargetDirectory(buildDir).setBaseName(extension().finalName()).setBuildSystemProperties(realProperties).setAppArtifact(appModel.getAppArtifact()).setLocalProjectDiscovery(false).setIsolateDeployment(true).build().bootstrap()) {
final JavaPluginConvention javaConvention = getProject().getConvention().findPlugin(JavaPluginConvention.class);
if (javaConvention != null) {
final String generateSourcesDir = test ? QUARKUS_TEST_GENERATED_SOURCES : QUARKUS_GENERATED_SOURCES;
final SourceSet generatedSources = javaConvention.getSourceSets().findByName(generateSourcesDir);
List<Path> paths = new ArrayList<>();
generatedSources.getOutput().filter(f -> f.getName().equals(generateSourcesDir)).forEach(f -> paths.add(f.toPath()));
if (paths.isEmpty()) {
throw new GradleException("Failed to create quarkus-generated-sources");
}
getLogger().debug("Will trigger preparing sources for source directory: {} buildDir: {}", sourcesDirectories, getProject().getBuildDir().getAbsolutePath());
QuarkusClassLoader deploymentClassLoader = appCreationContext.createDeploymentClassLoader();
Class<?> codeGenerator = deploymentClassLoader.loadClass(CodeGenerator.class.getName());
Optional<Method> initAndRun = Arrays.stream(codeGenerator.getMethods()).filter(m -> m.getName().equals(INIT_AND_RUN)).findAny();
if (initAndRun.isEmpty()) {
throw new GradleException("Failed to find " + INIT_AND_RUN + " method in " + CodeGenerator.class.getName());
}
initAndRun.get().invoke(null, deploymentClassLoader, PathList.from(sourcesDirectories), paths.get(0), buildDir, sourceRegistrar, appCreationContext.getApplicationModel(), realProperties, launchMode.name(), test);
}
} catch (BootstrapException | IllegalAccessException | InvocationTargetException | ClassNotFoundException e) {
throw new GradleException("Failed to generate sources in the QuarkusPrepare task", e);
}
}
Aggregations