Skip to content

Commit 22c15fe

Browse files
author
vasile.baluta
committed
Add support for more start options.
Some might need to pass options like --enableAuth, this change enables passing this options and many other than the port and local debug supported today.
1 parent 50bbc7e commit 22c15fe

File tree

1 file changed

+19
-6
lines changed
  • azure-functions-maven-plugin/src/main/java/com/microsoft/azure/maven/function

1 file changed

+19
-6
lines changed

azure-functions-maven-plugin/src/main/java/com/microsoft/azure/maven/function/RunMojo.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
@Mojo(name = "run")
2626
public class RunMojo extends AbstractFunctionMojo {
2727
protected static final String FUNC_CMD = "func -v";
28-
protected static final String FUNC_HOST_START_CMD = "func host start -p %s";
28+
protected static final String FUNC_HOST_START_CMD = "func host start %s";
2929
protected static final String RUN_FUNCTIONS_FAILURE = "Failed to run Azure Functions. Please checkout console output.";
3030
protected static final String RUNTIME_NOT_FOUND = "Azure Functions Core Tools not found. " +
3131
"Please go to https://aka.ms/azfunc-install to install Azure Functions Core Tools first.";
3232
private static final String STAGE_DIR_FOUND = "Function App's staging directory found at: ";
3333
private static final String STAGE_DIR_NOT_FOUND =
3434
"Stage directory not found. Please run mvn package first.";
3535
private static final String RUNTIME_FOUND = "Azure Functions Core Tools found.";
36-
private static final String FUNC_HOST_START_WITH_DEBUG_CMD = "func host start -p %s --language-worker -- " +
36+
private static final String FUNC_HOST_START_WITH_DEBUG_CMD = "func host start %s --language-worker -- " +
3737
"\"-agentlib:jdwp=%s\"";
3838
private static final ComparableVersion JAVA_9 = new ComparableVersion("9");
3939
private static final ComparableVersion FUNC_3 = new ComparableVersion("3");
@@ -58,6 +58,14 @@ public class RunMojo extends AbstractFunctionMojo {
5858
*/
5959
@Parameter(property = "funcPort", defaultValue = "7071")
6060
protected Integer funcPort;
61+
62+
/**
63+
* Config String for other start options than port and local debug
64+
*
65+
* @since 1.29.0
66+
*/
67+
@Parameter(property = "startOptions")
68+
protected String startOptions;
6169
//region Getter
6270

6371
public String getLocalDebugConfig() {
@@ -126,8 +134,8 @@ private void checkRuntimeCompatibility(final CommandHandler handler) throws Azur
126134
return;
127135
}
128136
final ComparableVersion funcVersion = new ComparableVersion(handler.runCommandAndGetOutput(FUNC_VERSION_CMD, false, null));
129-
final ComparableVersion minimumVersion = funcVersion.compareTo(FUNC_3) >= 0 ? MINIMUM_JAVA_9_SUPPORTED_VERSION :
130-
MINIMUM_JAVA_9_SUPPORTED_VERSION_V2;
137+
final ComparableVersion minimumVersion = funcVersion.compareTo(FUNC_3) >= 0 ? MINIMUM_JAVA_9_SUPPORTED_VERSION
138+
: MINIMUM_JAVA_9_SUPPORTED_VERSION_V2;
131139
if (funcVersion.compareTo(minimumVersion) < 0) {
132140
throw new AzureExecutionException(FUNCTION_CORE_TOOLS_OUT_OF_DATE);
133141
}
@@ -146,12 +154,17 @@ protected String getStartFunctionHostCommand() {
146154
if (StringUtils.isNotEmpty(enableDebug) && enableDebug.equalsIgnoreCase("true")) {
147155
return getStartFunctionHostWithDebugCommand();
148156
} else {
149-
return String.format(FUNC_HOST_START_CMD, funcPort);
157+
return String.format(FUNC_HOST_START_CMD, allStartOptions());
150158
}
151159
}
152160

153161
protected String getStartFunctionHostWithDebugCommand() {
154-
return String.format(FUNC_HOST_START_WITH_DEBUG_CMD, funcPort, this.getLocalDebugConfig());
162+
return String.format(FUNC_HOST_START_WITH_DEBUG_CMD, allStartOptions(), this.getLocalDebugConfig());
163+
}
164+
165+
// Put together port and other start options
166+
protected String allStartOptions() {
167+
return " -p " + funcPort + " " + startOptions;
155168
}
156169

157170
//endregion

0 commit comments

Comments
 (0)