You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sam build does not produce a valid build because it ignores the groupId in maven artefacts. This means that only one of the artefacts with the same artifactId but different groupIds will be part of the collected libs in the .aws-sam/build/function/lib folder
Steps to reproduce
Create a maven multi module project where two artifacts have the same name but differnt groupId. Place a unique class in each. Then make another project with an AWS handler and add the two above mentioend artifacts as dependencies. Now use a templace like:
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Lambda application that calls the Lambda API.
Resources:
function:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: example.Handler
Runtime: java8
Description: Java function
MemorySize: 512
Timeout: 60
# Function's execution role
Policies:
- AWSLambdaBasicExecutionRole
- AWSLambdaReadOnlyAccess
- AWSXrayWriteOnlyAccess
- AWSLambdaVPCAccessExecutionRole
Tracing: Active
build it with: sam build
inspect the folder .aws-sam/build/function/lib/ and observe that the two artefact dependencies are not present but only one of them e.g. x-1.0.0-SNAPSHOT.jar if unzil -l x-1.0.0-SNAPSHOT.jar it will show that it just contains the class for one of the dependencies.
Please provide command output with --debug flag set.
Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
'build' command is called
No Parameters detected in the template
1 resources found in the template
Found Serverless function with name='function' and CodeUri='handler'
No Parameters detected in the template
Building function 'function'
Looking for a supported build workflow in following directories: ['/Users/kgl/Downloads/sam-test/handler', '/Users/kgl/Downloads/sam-test']
Loading workflow module 'aws_lambda_builders.workflows'
Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
Registering workflow 'GoDepBuilder' with capability 'Capability(language='go', dependency_manager='dep', application_framework=None)'
Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'
Found workflow 'JavaMavenWorkflow' to support capabilities 'Capability(language='java', dependency_manager='maven', application_framework=None)'
/usr/local/bin/mvn is using a JVM with major version 11 which is newer than 8 that is supported by AWS Lambda. The compiled function code may not run in AWS Lambda unless the project has been configured to be compatible with Java 8 using 'maven.compiler.target' in Maven.
Running workflow 'JavaMavenWorkflow'
Running JavaMavenWorkflow:CopySource
JavaMavenWorkflow:CopySource succeeded
Running JavaMavenWorkflow:MavenBuild
Maven logs: [INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for a:handler:jar:1.0.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ a:root:1.0.0-SNAPSHOT, /Users/kgl/.m2/repository/a/root/1.0.0-SNAPSHOT/root-1.0.0-SNAPSHOT.pom, line 20, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -----------------------------< a:handler >------------------------------
[INFO] Building handler 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ handler ---
[INFO] Deleting /private/var/folders/x_/hxn9rtt12092gllyy1wyrl1sn_3pn7/T/tmp7m3ijio4/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ handler ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /private/var/folders/x_/hxn9rtt12092gllyy1wyrl1sn_3pn7/T/tmp7m3ijio4/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ handler ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /private/var/folders/x_/hxn9rtt12092gllyy1wyrl1sn_3pn7/T/tmp7m3ijio4/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ handler ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /private/var/folders/x_/hxn9rtt12092gllyy1wyrl1sn_3pn7/T/tmp7m3ijio4/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ handler ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ handler ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ handler ---
[INFO] Building jar: /private/var/folders/x_/hxn9rtt12092gllyy1wyrl1sn_3pn7/T/tmp7m3ijio4/target/handler-1.0.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ handler ---
[INFO] Installing /private/var/folders/x_/hxn9rtt12092gllyy1wyrl1sn_3pn7/T/tmp7m3ijio4/target/handler-1.0.0-SNAPSHOT.jar to /Users/kgl/.m2/repository/a/handler/1.0.0-SNAPSHOT/handler-1.0.0-SNAPSHOT.jar
[INFO] Installing /private/var/folders/x_/hxn9rtt12092gllyy1wyrl1sn_3pn7/T/tmp7m3ijio4/pom.xml to /Users/kgl/.m2/repository/a/handler/1.0.0-SNAPSHOT/handler-1.0.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.357 s
[INFO] Finished at: 2020-08-31T13:25:41+02:00
[INFO] ------------------------------------------------------------------------
JavaMavenWorkflow:MavenBuild succeeded
Running JavaMavenWorkflow:MavenCopyDependency
JavaMavenWorkflow:MavenCopyDependency succeeded
Running JavaMavenWorkflow:MavenCopyArtifacts
JavaMavenWorkflow:MavenCopyArtifacts succeeded
Build Succeeded
Built Artifacts : .aws-sam/build
Built Template : .aws-sam/build/template.yaml
Commands you can use next
=========================
[*] Invoke Function: sam local invoke
[*] Deploy: sam deploy --guided
Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'duration': 4355, 'exitReason': 'success', 'exitCode': 0, 'requestId': 'b2330c9c-844a-4062-920b-2eb075d2bf34', 'installationId': '965256fd-d56d-42d3-8f53-2086ce1c65f9', 'sessionId': 'f51b3907-d364-49d7-9e25-d1b5cca5d27f', 'executionEnvironment': 'CLI', 'pyversion': '3.7.8', 'samcliVersion': '1.1.0'}}]}
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Expected result
Maven artefacts are only unique if their full name is used (groupId, artifactId, version). So I would expect that all artefacts have their group included such that artefact jars are not overridden by each other.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
OS: 19.6.0 Darwin Kernel Version 19.6.0
sam --version: SAM CLI, version 1.1.0
Add --debug flag to command you are running
The text was updated successfully, but these errors were encountered:
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Description
Sam build does not produce a valid build because it ignores the groupId in maven artefacts. This means that only one of the artefacts with the same artifactId but different groupIds will be part of the collected libs in the
.aws-sam/build/function/lib
folderSteps to reproduce
Create a maven multi module project where two artifacts have the same name but differnt groupId. Place a unique class in each. Then make another project with an AWS handler and add the two above mentioend artifacts as dependencies. Now use a templace like:
build it with:
sam build
inspect the folder
.aws-sam/build/function/lib/
and observe that the two artefact dependencies are not present but only one of them e.g.x-1.0.0-SNAPSHOT.jar
if unzil -lx-1.0.0-SNAPSHOT.jar
it will show that it just contains the class for one of the dependencies.A full example is available here: https://github.com/lausdahl/sam_cli_dependency_build_bug
Observed result
Please provide command output with
--debug
flag set.Expected result
Maven artefacts are only unique if their full name is used (groupId, artifactId, version). So I would expect that all artefacts have their group included such that artefact jars are not overridden by each other.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: SAM CLI, version 1.1.0Add --debug flag to command you are running
The text was updated successfully, but these errors were encountered: