diff --git a/azure-functions-maven-plugin/src/main/java/com/microsoft/azure/maven/function/RunMojo.java b/azure-functions-maven-plugin/src/main/java/com/microsoft/azure/maven/function/RunMojo.java index c79331803..b2adee544 100644 --- a/azure-functions-maven-plugin/src/main/java/com/microsoft/azure/maven/function/RunMojo.java +++ b/azure-functions-maven-plugin/src/main/java/com/microsoft/azure/maven/function/RunMojo.java @@ -25,7 +25,7 @@ @Mojo(name = "run") public class RunMojo extends AbstractFunctionMojo { protected static final String FUNC_CMD = "func -v"; - protected static final String FUNC_HOST_START_CMD = "func host start -p %s"; + protected static final String FUNC_HOST_START_CMD = "func host start %s"; protected static final String RUN_FUNCTIONS_FAILURE = "Failed to run Azure Functions. Please checkout console output."; protected static final String RUNTIME_NOT_FOUND = "Azure Functions Core Tools not found. " + "Please go to https://aka.ms/azfunc-install to install Azure Functions Core Tools first."; @@ -33,7 +33,7 @@ public class RunMojo extends AbstractFunctionMojo { private static final String STAGE_DIR_NOT_FOUND = "Stage directory not found. Please run mvn package first."; private static final String RUNTIME_FOUND = "Azure Functions Core Tools found."; - private static final String FUNC_HOST_START_WITH_DEBUG_CMD = "func host start -p %s --language-worker -- " + + private static final String FUNC_HOST_START_WITH_DEBUG_CMD = "func host start %s --language-worker -- " + "\"-agentlib:jdwp=%s\""; private static final ComparableVersion JAVA_9 = new ComparableVersion("9"); private static final ComparableVersion FUNC_3 = new ComparableVersion("3"); @@ -58,6 +58,14 @@ public class RunMojo extends AbstractFunctionMojo { */ @Parameter(property = "funcPort", defaultValue = "7071") protected Integer funcPort; + + /** + * Config String for other start options than port and local debug + * + * @since 1.29.0 + */ + @Parameter(property = "startOptions", defaultValue = "") + protected String startOptions; //region Getter public String getLocalDebugConfig() { @@ -146,12 +154,22 @@ protected String getStartFunctionHostCommand() { if (StringUtils.isNotEmpty(enableDebug) && enableDebug.equalsIgnoreCase("true")) { return getStartFunctionHostWithDebugCommand(); } else { - return String.format(FUNC_HOST_START_CMD, funcPort); + return String.format(FUNC_HOST_START_CMD, allStartOptions()); } } protected String getStartFunctionHostWithDebugCommand() { - return String.format(FUNC_HOST_START_WITH_DEBUG_CMD, funcPort, this.getLocalDebugConfig()); + return String.format(FUNC_HOST_START_WITH_DEBUG_CMD, allStartOptions(), this.getLocalDebugConfig()); + } + + // Put together port and other start options + protected String allStartOptions() { + final String startOptionsCli = System.getProperty("startOptions"); + if (StringUtils.isNotEmpty(startOptionsCli)) { + // override startOptions from maven plugin configuration + startOptions = startOptionsCli; + } + return " -p " + funcPort + " " + startOptions; } //endregion diff --git a/azure-functions-maven-plugin/src/test/java/com/microsoft/azure/maven/function/RunMojoTest.java b/azure-functions-maven-plugin/src/test/java/com/microsoft/azure/maven/function/RunMojoTest.java index 8bb944155..3af215833 100644 --- a/azure-functions-maven-plugin/src/test/java/com/microsoft/azure/maven/function/RunMojoTest.java +++ b/azure-functions-maven-plugin/src/test/java/com/microsoft/azure/maven/function/RunMojoTest.java @@ -114,7 +114,10 @@ public void getCheckRuntimeCommand() throws Exception { public void getStartFunctionHostCommand() throws Exception { final RunMojo mojo = getMojoFromPom(); final RunMojo mojoSpy = spy(mojo); - assertEquals(String.format(FUNC_HOST_START_CMD, mojoSpy.funcPort), mojoSpy.getStartFunctionHostCommand()); + final String startOptions = mojoSpy.allStartOptions(); + assertEquals(String.format(FUNC_HOST_START_CMD, startOptions), mojoSpy.getStartFunctionHostCommand()); + System.setProperty("startOptions", "--enableAuth"); + assertTrue(mojoSpy.getStartFunctionHostCommand().contains("--enableAuth")); System.setProperty("enableDebug", "true"); assertTrue(mojoSpy.getStartFunctionHostCommand().contains("-agentlib:jdwp")); }