From 611758fbd3dcf0e18ce4113b491fcabfc24b6d18 Mon Sep 17 00:00:00 2001 From: Eric Bottard Date: Mon, 19 Aug 2019 14:35:27 +0200 Subject: [PATCH] Support exploded directories in addition to jar files. --- .../deployer/FunctionDeployerConfiguration.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionDeployerConfiguration.java b/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionDeployerConfiguration.java index d1363a9a8..7f68381af 100644 --- a/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionDeployerConfiguration.java +++ b/spring-cloud-function-deployer/src/main/java/org/springframework/cloud/function/deployer/FunctionDeployerConfiguration.java @@ -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);