Skip to content

Commit 5d9ff6d

Browse files
authored
Correctly resolve function runtime classpath in Maven plugin. Fixes #30 (#32)
* Correctly resolve function runtime classpath. Fixes #30
1 parent a854c95 commit 5d9ff6d

File tree

1 file changed

+6
-5
lines changed
  • invoker/function-maven-plugin/src/main/java/com/google/cloud/functions/plugin

1 file changed

+6
-5
lines changed

invoker/function-maven-plugin/src/main/java/com/google/cloud/functions/plugin/RunFunction.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@
3939
*/
4040
@Mojo(name = "run",
4141
defaultPhase = LifecyclePhase.GENERATE_RESOURCES,
42-
requiresDependencyResolution = ResolutionScope.COMPILE,
43-
requiresDependencyCollection = ResolutionScope.COMPILE)
42+
requiresDependencyResolution = ResolutionScope.RUNTIME,
43+
requiresDependencyCollection = ResolutionScope.RUNTIME)
4444
@Execute(phase = LifecyclePhase.COMPILE)
4545
public class RunFunction extends AbstractMojo {
4646

47+
4748
/**
4849
* The name of the function to run. This is the name of a class that implements one of the
4950
* interfaces in {@code com.google.cloud.functions}.
@@ -61,11 +62,11 @@ public class RunFunction extends AbstractMojo {
6162
* Used to determine what classpath needs to be used to load the function. This parameter is
6263
* injected by Maven and can't be set explicitly in a pom.xml file.
6364
*/
64-
@Parameter(defaultValue = "${project.compileClasspathElements}", readonly = true, required = true)
65-
private List<String> compilePath;
65+
@Parameter(defaultValue = "${project.runtimeClasspathElements}", readonly = true, required = true)
66+
private List<String> runtimePath;
6667

6768
public void execute() throws MojoExecutionException {
68-
String classpath = String.join(File.pathSeparator, compilePath);
69+
String classpath = String.join(File.pathSeparator, runtimePath);
6970
List<String> args = new ArrayList<>();
7071
args.addAll(Arrays.asList("--classpath", classpath));
7172
if (functionTarget != null) {

0 commit comments

Comments
 (0)