Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure-maven-plugin cannot be used from subproject in multimodule project. #75

Closed
nicenemo opened this issue Jan 2, 2018 · 3 comments
Closed

Comments

@nicenemo
Copy link

nicenemo commented Jan 2, 2018

Plugin name and version

 <plugin>
          <groupId>com.microsoft.azure</groupId>
          <artifactId>azure-functions-maven-plugin</artifactId>
          <version>0.1.9</version>
        </plugin>

Plugin configuration in your `pom.xml

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <groupId>com.microsoft.azure</groupId>
          <artifactId>azure-functions-maven-plugin</artifactId>
          <version>0.1.9</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <!-- Use shade plugin to bundle dependencies -->
      <plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>3.1.0</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<transformers>
						<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
							<mainClass>no.identification.functions:EnrollmentFunctions</mainClass>
						</transformer>
					</transformers>
					<filters>
						<filter>
							<artifact>*:*</artifact>
							<excludes>
								<exclude>META-INF/*.SF</exclude>
								<exclude>META-INF/*.DSA</exclude>
								<exclude>META-INF/*.RSA</exclude>
							</excludes>
						</filter>
					</filters>
				</configuration>
			</plugin>
      <plugin>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>azure-functions-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>package-functions</id>
            <goals>
              <goal>package</goal>
            </goals>
          </execution>
        </executions>
        <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>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>package</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <overwrite>true</overwrite>
              <outputDirectory>${project.build.directory}/azure-functions/${functionAppName}</outputDirectory>
              <resources>
                <resource>
                  <directory>${project.basedir}</directory>
                  <includes>
                    <include>host.json</include>
                    <include>local.settings.json</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

Expected behavior

As a developer I want to be able to use the azure-functions plugin in a multi module project.
Either fix or provide guidance on how to do this correctly.

Actual behavior

Packaging is probably not correct.

Steps to reproduce the problem

Sample project

Build and run with:

mvn --projects azfunctions-multimodulefunction --also-make-dependents clean package azure-functions:package azure-functions:run

It will run but when triggering the function from a browser with http://localhost:7071/api/hello?name=hans it will fail with a reflection error.
Probably because packaging does not work correctly now.

Workaround:

  1. Remove the functions project from the multi module project
  2. Make the functions project a stand alone project that refers the artifacts from the multi module project.
  3. Do a mvn clean package install on the multi module project.
  4. Do a mvn clean package azure-functions:package azure-functions:run on the function project

This workaround requires extra steps on the build environment instead of a one liner in Maven.

@jdneo
Copy link
Member

jdneo commented Apr 26, 2018

Hi @nicenemo , the Sample project link does not exist any more. Would you mind to give it again so I can see what's happenning? 😄

@nicenemo
Copy link
Author

Sorry but we simplified our code "ages" ago so we do not need it for now.
That's why I deleted the old sample projects. Maybe I will try again after we moved to the latest version of the stack that does not require shading.

@jdneo
Copy link
Member

jdneo commented Jul 13, 2018

Hi @nicenemo, thank you for your feedback.

Just sorry to say that I'm going to close this issue for now since it is inactive for a while. But feel free to reopen it if you find this is still a problem.

Thank you for your contribution!

@jdneo jdneo closed this as completed Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants