Support exploded directories in addition to jar files.

This commit is contained in:
Eric Bottard
2019-08-19 14:35:27 +02:00
committed by Oleg Zhurakousky
parent 591b3bf531
commit 611758fbd3

View File

@@ -31,6 +31,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.loader.archive.Archive;
import org.springframework.boot.loader.archive.ExplodedArchive;
import org.springframework.boot.loader.archive.JarFileArchive;
import org.springframework.cloud.function.context.FunctionRegistry;
import org.springframework.context.SmartLifecycle;
@@ -63,7 +64,16 @@ public class FunctionDeployerConfiguration {
Archive archive = null;
try {
archive = new JarFileArchive(new File(functionProperties.getLocation()));
File file = new File(functionProperties.getLocation());
if (!file.exists()) {
throw new IllegalStateException("Failed to create archive: " + functionProperties.getLocation() + " does not exist");
}
else if (file.isDirectory()) {
archive = new ExplodedArchive(file);
}
else {
archive = new JarFileArchive(file);
}
}
catch (IOException e) {
throw new IllegalStateException("Failed to create archive: " + functionProperties.getLocation(), e);