azure-maven-plugins: Packaging fails with multi module project
Plugin name and version
<pluginManagement>
<plugins>
...
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-maven-plugin</artifactId>
<version>0.1.6</version>
</plugin>
</plugins>
</pluginManagement>
Plugin configuration in your pom.xml
...
<build>
...
<plugins>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-maven-plugin</artifactId>
<configuration>
<resourceGroup>java-functions-group</resourceGroup>
<appName>${functionAppName}</appName>
<region>${functionAppRegion}</region>
<appSettings>
<property>
<name>FUNCTIONS_EXTENSION_VERSION</name>
<value>beta</value>
</property>
</appSettings>
</configuration>
<executions>
<execution>
<id>package-functions</id>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
...
Expected behavior
As a developer in a project using Azure Functions I want to use the Java Azure SDK with components from private repositories.
-
mvn package
works. -
mvn azure-functions:run
works. -
I want to use a self created library from my Azure Function
-
I want to use proprietary libraries within that function or another function. These libraries cannot be deployed to Maven Central or another public repository for legal reasons.
Actual behavior
Both fail with a complaint of missing a class from a jar in a private repo.
Steps to reproduce the problem
In an Azure Functions project mvn package
fails if you refer components in private repositories.
Normal package works
If you remove azure-functions-maven-plugin
plugin from the pom.xml
a normal package works. So it is for sure something in the azure-functions-maven-plugin
Reproduce
- Create an Azure Function with the Azure Functions Archetype: https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-java-maven
- create another java project that just produces a jar with an
Hello World
function. - install the jar in your local .m2 cache
- Refer to it from the Function project pom file.
- Use the
Hello World
from within the function mvn compile
andmvn test
should already work- observe that
mvn package
does not work.
Private repo
After Googleing I noticed that for package a repository should be available and that packaging does not work with only the local cache in ~/.m2
I “Fixed” this by publishing to a local repository from the library project and refering to that from the Azure Function project.
8. Publish to “remote” repository by adding the following to the pom.xml
of the library project:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<configuration>
<altDeploymentRepository>internal.repo::default::file:${project.basedir}/../mvn-repo</altDeploymentRepository>
</configuration>
</plugin>
- Do
mvn clean package install deploy
in the library project folder. - Verify that the library is deployed to the new local file repo.
- clear my .m2/repository
- Go to the functions project project
- Add the following to the
pom.xml
file
<repositories>
<!--other repositories if any-->
<repository>
<id>project.local</id>
<name>project</name>
<url>file:${project.basedir}/../mvn-repo</url>
</repository>
</repositories>
- do
mvn clean compile test
- Observe that the tests are run (If you do not add the repository. The code will fail to compile/test if your .m2 cache is empty too.)
- Do
mvn package
--> fails with library classes that cannot be found - Try
mvn azure-functions:run
It tries to package first and fails.
Error:
INFO] Reflections took 78 ms to scan 1 urls, producing 1 keys and 1 values
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 38.051 s
[INFO] Finished at: 2017-11-09T15:41:27+01:00
[INFO] Final Memory: 43M/286M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.microsoft.azure:azure-functions-maven-plugin:0.1.6:package (package-functions) on project helloworldFunction: Execution package-functions of goal com.microsoft.azure:azure-functions-mave
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>com.microsoft.azure:azure-functions-maven-plugin:0.1.6
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/hkruse/.m2/repository/com/microsoft/azure/azure-functions-maven-plugin/0.1.6/azure-functions-maven-plugin-0.1.6.jar
[... <<<cut>>> ...]
[ERROR] urls[82] = file:/C:/Users/hkruse/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
Side note: using Github as repo
We looked into using hosted Nexus as a repo but did not do that for cost reasons.
We finally want to use either Github site plugin or Wagon-git I think wagon-git is finally the way to go because the site plugin is more for publishing sites. I did not want to complicate matters more yet by using git based repo plugins now. So I used the local file system to try it out.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 17 (5 by maintainers)
Ok good news. I have it working again. But I am sorry to tell that the
azure-maven-functions-plugin
does not support multi module projects.Workaround:
mvn clean package install
No need for nexus or alike yet. This installs it in the local package cache…