use of com.google.cloud.tools.jib.cli.jar.StandardPackagedProcessor in project jib by google.
the class ArtifactProcessors method fromJar.
/**
* Creates a {@link ArtifactProcessor} instance based on jar type and processing mode.
*
* @param jarPath path to the jar
* @param cacheDirectories the location of the relevant caches
* @param jarOptions jar cli options
* @param commonContainerConfigCliOptions common cli options shared between jar and war command
* @return ArtifactProcessor
* @throws IOException if I/O error occurs when opening the jar file
*/
public static ArtifactProcessor fromJar(Path jarPath, CacheDirectories cacheDirectories, Jar jarOptions, CommonContainerConfigCliOptions commonContainerConfigCliOptions) throws IOException {
Integer jarJavaVersion = determineJavaMajorVersion(jarPath);
if (jarJavaVersion > 17 && !commonContainerConfigCliOptions.getFrom().isPresent()) {
throw new IllegalStateException(String.format("The input JAR (%s) is compiled with Java %d, but the default base image only " + "supports versions up to Java 17. Specify a custom base image with --from.", jarPath, jarJavaVersion));
}
String jarType = determineJarType(jarPath);
ProcessingMode mode = jarOptions.getMode();
if (jarType.equals(SPRING_BOOT) && mode.equals(ProcessingMode.packaged)) {
return new SpringBootPackagedProcessor(jarPath, jarJavaVersion);
} else if (jarType.equals(SPRING_BOOT) && mode.equals(ProcessingMode.exploded)) {
return new SpringBootExplodedProcessor(jarPath, cacheDirectories.getExplodedArtifactDirectory(), jarJavaVersion);
} else if (jarType.equals(STANDARD) && mode.equals(ProcessingMode.packaged)) {
return new StandardPackagedProcessor(jarPath, jarJavaVersion);
} else {
return new StandardExplodedProcessor(jarPath, cacheDirectories.getExplodedArtifactDirectory(), jarJavaVersion);
}
}
use of com.google.cloud.tools.jib.cli.jar.StandardPackagedProcessor in project jib by GoogleContainerTools.
the class ArtifactProcessors method fromJar.
/**
* Creates a {@link ArtifactProcessor} instance based on jar type and processing mode.
*
* @param jarPath path to the jar
* @param cacheDirectories the location of the relevant caches
* @param jarOptions jar cli options
* @param commonContainerConfigCliOptions common cli options shared between jar and war command
* @return ArtifactProcessor
* @throws IOException if I/O error occurs when opening the jar file
*/
public static ArtifactProcessor fromJar(Path jarPath, CacheDirectories cacheDirectories, Jar jarOptions, CommonContainerConfigCliOptions commonContainerConfigCliOptions) throws IOException {
Integer jarJavaVersion = determineJavaMajorVersion(jarPath);
if (jarJavaVersion > 17 && !commonContainerConfigCliOptions.getFrom().isPresent()) {
throw new IllegalStateException(String.format("The input JAR (%s) is compiled with Java %d, but the default base image only " + "supports versions up to Java 17. Specify a custom base image with --from.", jarPath, jarJavaVersion));
}
String jarType = determineJarType(jarPath);
ProcessingMode mode = jarOptions.getMode();
if (jarType.equals(SPRING_BOOT) && mode.equals(ProcessingMode.packaged)) {
return new SpringBootPackagedProcessor(jarPath, jarJavaVersion);
} else if (jarType.equals(SPRING_BOOT) && mode.equals(ProcessingMode.exploded)) {
return new SpringBootExplodedProcessor(jarPath, cacheDirectories.getExplodedArtifactDirectory(), jarJavaVersion);
} else if (jarType.equals(STANDARD) && mode.equals(ProcessingMode.packaged)) {
return new StandardPackagedProcessor(jarPath, jarJavaVersion);
} else {
return new StandardExplodedProcessor(jarPath, cacheDirectories.getExplodedArtifactDirectory(), jarJavaVersion);
}
}
Aggregations