microsoft / azure-maven-plugins

Maven plugins for Azure
MIT License
274 stars 146 forks source link

Abstract classes from referred project cannot be used #74

Closed nicenemo closed 6 years ago

nicenemo commented 6 years ago

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

The azure functions plugin should be able to package code that uses abstract classes and methods.

Actual behavior

mvn clean package azure-functions-package fails with an error about not being able to find the abstract class.

Note that doing a mvn clean compile test just works. If you remove the abstract class it just works.

Steps to reproduce the problem

I created a sample project to illustrate this. It is based on the standard HelloWorld archetype for Azure functions. It consists of two projects:

  1. library, this must be build and installed in the local maven cache first!
  2. function, Azure function project that uses the library.

The shade plugin is used to combine all dependencies.

Do the following after cloning:

cd library
mvn clean package install
cd ..
cd function
mvn clean package

Resulting error:

C:\Users\angor\git\nicenemo\azfunctions-abstractmethodissue\function>mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Azure Java Functions 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ azfunctions-abstractmethodissue ---
[INFO] Deleting C:\Users\angor\git\nicenemo\azfunctions-abstractmethodissue\function\target
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ azfunctions-abstractmethodissue ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\angor\git\nicenemo\azfunctions-abstractmethodissue\function\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ azfunctions-abstractmethodissue ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\angor\git\nicenemo\azfunctions-abstractmethodissue\function\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ azfunctions-abstractmethodissue ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\angor\git\nicenemo\azfunctions-abstractmethodissue\function\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ azfunctions-abstractmethodissue ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\angor\git\nicenemo\azfunctions-abstractmethodissue\function\target\test-classes
[WARNING] /C:/Users/angor/git/nicenemo/azfunctions-abstractmethodissue/function/src/test/java/eu/hanskruse/FunctionTest.java: C:\Users\angor\git\nicenemo\azfunctions-abstractmethodissue\function\src\test\java\eu\hanskruse\FunctionTest.java uses unchecked or unsafe operations.
[WARNING] /C:/Users/angor/git/nicenemo/azfunctions-abstractmethodissue/function/src/test/java/eu/hanskruse/FunctionTest.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ azfunctions-abstractmethodissue ---
[INFO] Surefire report directory: C:\Users\angor\git\nicenemo\azfunctions-abstractmethodissue\function\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running eu.hanskruse.FunctionTest
Jan 02, 2018 1:39:13 PM eu.hanskruse.Function hello
SEVERE: Signature length: 4
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.797 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ azfunctions-abstractmethodissue ---
[INFO] Building jar: C:\Users\angor\git\nicenemo\azfunctions-abstractmethodissue\function\target\azfunctions-abstractmethodissue-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-shade-plugin:3.1.0:shade (default) @ azfunctions-abstractmethodissue ---
[INFO] Including com.microsoft.azure:azure-functions-java-core:jar:1.0.0-beta-2 in the shaded jar.
[INFO] Including eu.hanskruse:abstractmethod-library:jar:1.0.0-SNAPSHOT in the shaded jar.
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing C:\Users\angor\git\nicenemo\azfunctions-abstractmethodissue\function\target\azfunctions-abstractmethodissue-1.0-SNAPSHOT.jar with C:\Users\angor\git\nicenemo\azfunctions-abstractmethodissue\function\target\azfunctions-abstractmethodissue-1.0-SNAPSHOT-shaded.jar
[INFO] Dependency-reduced POM written at: C:\Users\angor\git\nicenemo\azfunctions-abstractmethodissue\function\dependency-reduced-pom.xml
[INFO]
[INFO] --- azure-functions-maven-plugin:0.1.9:package (package-functions) @ azfunctions-abstractmethodissue ---
AI: INFO 02-01-2018 13:39, 1: Configuration file has been successfully found as resource
AI: INFO 02-01-2018 13:39, 1: Configuration file has been successfully found as resource
[INFO]
[INFO] Step 1 of 6: Searching for Azure Function entry points
[INFO] Reflections took 78 ms to scan 1 urls, producing 1 keys and 1 values
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.566 s
[INFO] Finished at: 2018-01-02T13:39:18+01:00
[INFO] Final Memory: 71M/426M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.microsoft.azure:azure-functions-maven-plugin:0.1.9:package (package-functions) on project azfunctions-abstractmethodissue: Execution package-functions of goal com.microsoft.azure:azure-functions-maven-plugin:0.1.9:package failed: A required class was missing while executing com.microsoft.azure:azure-functions-maven-plugin:0.1.9:package: eu/hanskruse/signing/AbstractSigner
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>com.microsoft.azure:azure-functions-maven-plugin:0.1.9
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-functions-maven-plugin/0.1.9/azure-functions-maven-plugin-0.1.9.jar
[ERROR] urls[1] = file:/C:/Users/angor/.m2/repository/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar
[ERROR] urls[2] = file:/C:/Users/angor/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.0/org.eclipse.sisu.inject-0.3.0.jar
[ERROR] urls[3] = file:/C:/Users/angor/.m2/repository/org/apache/maven/maven-builder-support/3.3.3/maven-builder-support-3.3.3.jar
[ERROR] urls[4] = file:/C:/Users/angor/.m2/repository/org/eclipse/aether/aether-util/1.0.2.v20150114/aether-util-1.0.2.v20150114.jar
[ERROR] urls[5] = file:/C:/Users/angor/.m2/repository/org/sonatype/sisu/sisu-guice/3.2.5/sisu-guice-3.2.5-no_aop.jar
[ERROR] urls[6] = file:/C:/Users/angor/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
[ERROR] urls[7] = file:/C:/Users/angor/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.21/plexus-interpolation-1.21.jar
[ERROR] urls[8] = file:/C:/Users/angor/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[9] = file:/C:/Users/angor/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[10] = file:/C:/Users/angor/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[11] = file:/C:/Users/angor/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.20/plexus-utils-3.0.20.jar
[ERROR] urls[12] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-maven-plugin-lib/0.1.6/azure-maven-plugin-lib-0.1.6.jar
[ERROR] urls[13] = file:/C:/Users/angor/.m2/repository/org/apache/maven/shared/maven-filtering/3.0.0/maven-filtering-3.0.0.jar
[ERROR] urls[14] = file:/C:/Users/angor/.m2/repository/org/apache/maven/shared/maven-shared-utils/3.0.0/maven-shared-utils-3.0.0.jar
[ERROR] urls[15] = file:/C:/Users/angor/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
[ERROR] urls[16] = file:/C:/Users/angor/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar
[ERROR] urls[17] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure/1.2.1/azure-1.2.1.jar
[ERROR] urls[18] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-resources/1.2.1/azure-mgmt-resources-1.2.1.jar
[ERROR] urls[19] = file:/C:/Users/angor/.m2/repository/org/slf4j/slf4j-simple/1.7.5/slf4j-simple-1.7.5.jar
[ERROR] urls[20] = file:/C:/Users/angor/.m2/repository/io/reactivex/rxjava/1.2.4/rxjava-1.2.4.jar
[ERROR] urls[21] = file:/C:/Users/angor/.m2/repository/org/apache/httpcomponents/httpcore/4.4.5/httpcore-4.4.5.jar
[ERROR] urls[22] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-storage/1.2.1/azure-mgmt-storage-1.2.1.jar
[ERROR] urls[23] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-network/1.2.1/azure-mgmt-network-1.2.1.jar
[ERROR] urls[24] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-compute/1.2.1/azure-mgmt-compute-1.2.1.jar
[ERROR] urls[25] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-graph-rbac/1.2.1/azure-mgmt-graph-rbac-1.2.1.jar
[ERROR] urls[26] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-keyvault/1.2.1/azure-mgmt-keyvault-1.2.1.jar
[ERROR] urls[27] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-batch/1.2.1/azure-mgmt-batch-1.2.1.jar
[ERROR] urls[28] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-trafficmanager/1.2.1/azure-mgmt-trafficmanager-1.2.1.jar
[ERROR] urls[29] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-dns/1.2.1/azure-mgmt-dns-1.2.1.jar
[ERROR] urls[30] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-redis/1.2.1/azure-mgmt-redis-1.2.1.jar
[ERROR] urls[31] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-appservice/1.2.1/azure-mgmt-appservice-1.2.1.jar
[ERROR] urls[32] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-cdn/1.2.1/azure-mgmt-cdn-1.2.1.jar
[ERROR] urls[33] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-sql/1.2.1/azure-mgmt-sql-1.2.1.jar
[ERROR] urls[34] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-containerregistry/1.2.1/azure-mgmt-containerregistry-1.2.1.jar
[ERROR] urls[35] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-cosmosdb/1.2.1/azure-mgmt-cosmosdb-1.2.1.jar
[ERROR] urls[36] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-search/1.2.1/azure-mgmt-search-1.2.1.jar
[ERROR] urls[37] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-mgmt-servicebus/1.2.1/azure-mgmt-servicebus-1.2.1.jar
[ERROR] urls[38] = file:/C:/Users/angor/.m2/repository/joda-time/joda-time/2.1/joda-time-2.1.jar
[ERROR] urls[39] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-client-runtime/1.1.0/azure-client-runtime-1.1.0.jar
[ERROR] urls[40] = file:/C:/Users/angor/.m2/repository/com/microsoft/rest/client-runtime/1.1.0/client-runtime-1.1.0.jar
[ERROR] urls[41] = file:/C:/Users/angor/.m2/repository/com/squareup/retrofit2/retrofit/2.1.0/retrofit-2.1.0.jar
[ERROR] urls[42] = file:/C:/Users/angor/.m2/repository/com/squareup/okhttp3/okhttp/3.3.1/okhttp-3.3.1.jar
[ERROR] urls[43] = file:/C:/Users/angor/.m2/repository/com/squareup/okio/okio/1.8.0/okio-1.8.0.jar
[ERROR] urls[44] = file:/C:/Users/angor/.m2/repository/com/squareup/okhttp3/logging-interceptor/3.3.1/logging-interceptor-3.3.1.jar
[ERROR] urls[45] = file:/C:/Users/angor/.m2/repository/com/squareup/okhttp3/okhttp-urlconnection/3.3.1/okhttp-urlconnection-3.3.1.jar
[ERROR] urls[46] = file:/C:/Users/angor/.m2/repository/com/squareup/retrofit2/converter-jackson/2.1.0/converter-jackson-2.1.0.jar
[ERROR] urls[47] = file:/C:/Users/angor/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.7.2/jackson-databind-2.7.2.jar
[ERROR] urls[48] = file:/C:/Users/angor/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-joda/2.7.2/jackson-datatype-joda-2.7.2.jar
[ERROR] urls[49] = file:/C:/Users/angor/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0.jar
[ERROR] urls[50] = file:/C:/Users/angor/.m2/repository/com/squareup/retrofit2/adapter-rxjava/2.1.0/adapter-rxjava-2.1.0.jar
[ERROR] urls[51] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-client-authentication/1.1.0/azure-client-authentication-1.1.0.jar
[ERROR] urls[52] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/adal4j/1.1.2/adal4j-1.1.2.jar
[ERROR] urls[53] = file:/C:/Users/angor/.m2/repository/com/nimbusds/oauth2-oidc-sdk/4.5/oauth2-oidc-sdk-4.5.jar
[ERROR] urls[54] = file:/C:/Users/angor/.m2/repository/javax/mail/mail/1.4.7/mail-1.4.7.jar
[ERROR] urls[55] = file:/C:/Users/angor/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar
[ERROR] urls[56] = file:/C:/Users/angor/.m2/repository/net/jcip/jcip-annotations/1.0/jcip-annotations-1.0.jar
[ERROR] urls[57] = file:/C:/Users/angor/.m2/repository/net/minidev/json-smart/1.1.1/json-smart-1.1.1.jar
[ERROR] urls[58] = file:/C:/Users/angor/.m2/repository/com/nimbusds/lang-tag/1.4/lang-tag-1.4.jar
[ERROR] urls[59] = file:/C:/Users/angor/.m2/repository/com/nimbusds/nimbus-jose-jwt/3.1.2/nimbus-jose-jwt-3.1.2.jar
[ERROR] urls[60] = file:/C:/Users/angor/.m2/repository/org/bouncycastle/bcprov-jdk15on/1.51/bcprov-jdk15on-1.51.jar
[ERROR] urls[61] = file:/C:/Users/angor/.m2/repository/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar
[ERROR] urls[62] = file:/C:/Users/angor/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar
[ERROR] urls[63] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-annotations/1.2.0/azure-annotations-1.2.0.jar
[ERROR] urls[64] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/applicationinsights-core/1.0.9/applicationinsights-core-1.0.9.jar
[ERROR] urls[65] = file:/C:/Users/angor/.m2/repository/eu/infomas/annotation-detector/3.0.4/annotation-detector-3.0.4.jar
[ERROR] urls[66] = file:/C:/Users/angor/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
[ERROR] urls[67] = file:/C:/Users/angor/.m2/repository/org/apache/httpcomponents/httpclient/4.5.3/httpclient-4.5.3.jar
[ERROR] urls[68] = file:/C:/Users/angor/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar
[ERROR] urls[69] = file:/C:/Users/angor/.m2/repository/commons-net/commons-net/3.6/commons-net-3.6.jar
[ERROR] urls[70] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-functions-java-core/1.0.0-beta-2/azure-functions-java-core-1.0.0-beta-2.jar
[ERROR] urls[71] = file:/C:/Users/angor/.m2/repository/org/reflections/reflections/0.9.11/reflections-0.9.11.jar
[ERROR] urls[72] = file:/C:/Users/angor/.m2/repository/com/google/guava/guava/20.0/guava-20.0.jar
[ERROR] urls[73] = file:/C:/Users/angor/.m2/repository/org/javassist/javassist/3.21.0-GA/javassist-3.21.0-GA.jar
[ERROR] urls[74] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-storage/5.4.0/azure-storage-5.4.0.jar
[ERROR] urls[75] = file:/C:/Users/angor/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.6.0/jackson-core-2.6.0.jar
[ERROR] urls[76] = file:/C:/Users/angor/.m2/repository/org/apache/commons/commons-lang3/3.4/commons-lang3-3.4.jar
[ERROR] urls[77] = file:/C:/Users/angor/.m2/repository/com/microsoft/azure/azure-keyvault-core/0.8.0/azure-keyvault-core-0.8.0.jar
[ERROR] urls[78] = file:/C:/Users/angor/.m2/repository/org/zeroturnaround/zt-zip/1.12/zt-zip-1.12.jar
[ERROR] urls[79] = file:/C:/Users/angor/.m2/repository/junit/junit/4.12/junit-4.12.jar
[ERROR] urls[80] = file:/C:/Users/angor/.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]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : eu.hanskruse.signing.AbstractSigner
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
jdneo commented 6 years ago

Hi @nicenemo .

We have fixed this issue. You can have a try if you want. The following command might help:

git clone https://github.com/Microsoft/azure-maven-plugins.git

cd azure-maven-plugins

mvn clean install -DskipTests

Then change your function plugin version to 0.1.10-SNAPSHOT.

Thanks.

nicenemo commented 6 years ago

Marked on my todo list. Sorry busy with other issues now.