use of io.quarkus.deployment.pkg.builditem.NativeImageSourceJarBuildItem in project quarkus by quarkusio.
the class JarResultBuildStep method buildNativeImageJar.
/**
* Native images are built from a specially created jar file. This allows for changes in how the jar file is generated.
*/
@BuildStep
public NativeImageSourceJarBuildItem buildNativeImageJar(CurateOutcomeBuildItem curateOutcomeBuildItem, OutputTargetBuildItem outputTargetBuildItem, TransformedClassesBuildItem transformedClasses, ApplicationArchivesBuildItem applicationArchivesBuildItem, ApplicationInfoBuildItem applicationInfo, PackageConfig packageConfig, List<GeneratedClassBuildItem> generatedClasses, List<GeneratedNativeImageClassBuildItem> nativeImageResources, List<GeneratedResourceBuildItem> generatedResources, MainClassBuildItem mainClassBuildItem, List<UberJarRequiredBuildItem> uberJarRequired, List<UberJarMergedResourceBuildItem> mergeResources, ClassLoadingConfig classLoadingConfig, List<UberJarIgnoredResourceBuildItem> ignoreResources) throws Exception {
Path targetDirectory = outputTargetBuildItem.getOutputDirectory().resolve(outputTargetBuildItem.getBaseName() + "-native-image-source-jar");
IoUtils.createOrEmptyDir(targetDirectory);
List<GeneratedClassBuildItem> allClasses = new ArrayList<>(generatedClasses);
allClasses.addAll(nativeImageResources.stream().map((s) -> new GeneratedClassBuildItem(true, s.getName(), s.getClassData())).collect(Collectors.toList()));
if (SystemUtils.IS_OS_WINDOWS) {
log.warn("Uber JAR strategy is used for native image source JAR generation on Windows. This is done " + "for the time being to work around a current GraalVM limitation on Windows concerning the " + "maximum command length (see https://github.com/oracle/graal/issues/2387).");
// Native image source jar generation with the uber jar strategy is provided as a workaround for Windows and
// will be removed once https://github.com/oracle/graal/issues/2387 is fixed.
final NativeImageSourceJarBuildItem nativeImageSourceJarBuildItem = buildNativeImageUberJar(curateOutcomeBuildItem, outputTargetBuildItem, transformedClasses, applicationArchivesBuildItem, packageConfig, applicationInfo, allClasses, generatedResources, mergeResources, ignoreResources, mainClassBuildItem, targetDirectory, classLoadingConfig);
// additionally copy any json config files to a location accessible by native-image tool during
// native-image generation
copyJsonConfigFiles(applicationArchivesBuildItem, targetDirectory);
return nativeImageSourceJarBuildItem;
} else {
return buildNativeImageThinJar(curateOutcomeBuildItem, outputTargetBuildItem, transformedClasses, applicationArchivesBuildItem, applicationInfo, packageConfig, allClasses, generatedResources, mainClassBuildItem, targetDirectory, classLoadingConfig);
}
}
use of io.quarkus.deployment.pkg.builditem.NativeImageSourceJarBuildItem in project quarkus by quarkusio.
the class JarResultBuildStep method buildNativeImageUberJar.
private NativeImageSourceJarBuildItem buildNativeImageUberJar(CurateOutcomeBuildItem curateOutcomeBuildItem, OutputTargetBuildItem outputTargetBuildItem, TransformedClassesBuildItem transformedClasses, ApplicationArchivesBuildItem applicationArchivesBuildItem, PackageConfig packageConfig, ApplicationInfoBuildItem applicationInfo, List<GeneratedClassBuildItem> generatedClasses, List<GeneratedResourceBuildItem> generatedResources, List<UberJarMergedResourceBuildItem> mergeResources, List<UberJarIgnoredResourceBuildItem> ignoreResources, MainClassBuildItem mainClassBuildItem, Path targetDirectory, ClassLoadingConfig classLoadingConfig) throws Exception {
// we use the -runner jar name, unless we are building both types
Path runnerJar = targetDirectory.resolve(outputTargetBuildItem.getBaseName() + packageConfig.runnerSuffix + ".jar");
buildUberJar0(curateOutcomeBuildItem, outputTargetBuildItem, transformedClasses, applicationArchivesBuildItem, packageConfig, applicationInfo, generatedClasses, generatedResources, mergeResources, ignoreResources, mainClassBuildItem, classLoadingConfig, runnerJar);
return new NativeImageSourceJarBuildItem(runnerJar, null);
}
use of io.quarkus.deployment.pkg.builditem.NativeImageSourceJarBuildItem in project quarkus by quarkusio.
the class JarResultBuildStep method buildNativeImageThinJar.
private NativeImageSourceJarBuildItem buildNativeImageThinJar(CurateOutcomeBuildItem curateOutcomeBuildItem, OutputTargetBuildItem outputTargetBuildItem, TransformedClassesBuildItem transformedClasses, ApplicationArchivesBuildItem applicationArchivesBuildItem, ApplicationInfoBuildItem applicationInfo, PackageConfig packageConfig, List<GeneratedClassBuildItem> allClasses, List<GeneratedResourceBuildItem> generatedResources, MainClassBuildItem mainClassBuildItem, Path targetDirectory, ClassLoadingConfig classLoadingConfig) throws Exception {
copyJsonConfigFiles(applicationArchivesBuildItem, targetDirectory);
Path runnerJar = targetDirectory.resolve(outputTargetBuildItem.getBaseName() + packageConfig.runnerSuffix + ".jar");
Path libDir = targetDirectory.resolve(LIB);
Files.createDirectories(libDir);
try (FileSystem runnerZipFs = ZipUtils.newZip(runnerJar)) {
log.info("Building native image source jar: " + runnerJar);
doLegacyThinJarGeneration(curateOutcomeBuildItem, outputTargetBuildItem, transformedClasses, applicationArchivesBuildItem, applicationInfo, packageConfig, generatedResources, libDir, allClasses, runnerZipFs, mainClassBuildItem, classLoadingConfig);
}
runnerJar.toFile().setReadable(true, false);
return new NativeImageSourceJarBuildItem(runnerJar, libDir);
}
Aggregations