Closed BenD10 closed 1 year ago
@BenD10 Thanks a lot for your efforts and help and sorry for the late response. Azure plugin will read dependencies from Gradle runtime class path (refers), and we will filter out the non-existing files, which may throw exception if you refer another module while did not compile it.
We could leverage the Gradle compile class path to get the module dependencies in this case, however, they are just java class files which is not supported by function java worker (refers), so we must package the dependencies to run or deploy to Azure. I've submitted a commit to show warning in this case, here is the link https://github.com/microsoft/azure-gradle-plugins/pull/157/commits/1104ad9e04bb83d7052d7a62f98527c9ff239609
Description Trying to use the
com.microsoft.azure.azurefunctions
plugin in a Gradle project with multiple sub projects from a clean state will fail.Full stacktrace is available at the bottom, but it hints at a classpath error with
Caused by: java.lang.ClassNotFoundException: com.microsoft.azure.functions.annotation.FunctionName
. Running thejar
task first will allow the package to succeed.I stepped through the plugin with a debugger, and it looks like if the project we depend on has had its' jar task ran, it will be added to the internal project representation, otherwise it won't - https://github.com/microsoft/azure-gradle-plugins/blob/71e34e06afe43d81aa8424c023c33b4fe059a03e/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/handler/PackageHandler.java#L172
This causes the annotated method finder to fail, which eventually causes the confusing stacktrace - https://github.com/microsoft/azure-gradle-plugins/blob/71e34e06afe43d81aa8424c023c33b4fe059a03e/azure-functions-gradle-plugin/src/main/java/com/microsoft/azure/plugin/functions/gradle/handler/PackageHandler.java#L153
The workaround is to always run the jar task before trying to run any Azure function tasks, but that's not ideal.
Reproducer Clone https://github.com/BenD10/azure-fnapp and run
./gradlew clean :app:azureFunctionsPackage
and it will fail. Running./gradlew jar :app:azureFunctionsPackage
will work until the next clean.Stacktrace