Two copies of dependency jars included for gradle Kotlin build, as well as two copies of service classes and other useless files
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Description
I'm working on a very simple (public) example service, using lambda and sam (also gradle 5 and kotlin).
When I run `sam build` and later `sam package`, `sam` includes in the deployed `jar` two copies of my dependencies.
### Steps to reproduce
Checkout example service at , checkout `sam-issues` branch
or just download .
Run `sam build`.
### Observed result
Output of `sam build`:
```
2019-06-10 23:49:16 Using SAM Template at /home/knuckles/foo/derpservice-sam-issues/template.yaml
2019-06-10 23:49:16 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2019-06-10 23:49:16 Changing event name from before-call.apigateway to before-call.api-gateway
2019-06-10 23:49:16 Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2019-06-10 23:49:16 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2019-06-10 23:49:16 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-06-10 23:49:16 Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2019-06-10 23:49:16 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2019-06-10 23:49:16 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2019-06-10 23:49:16 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2019-06-10 23:49:16 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2019-06-10 23:49:16 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2019-06-10 23:49:16 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2019-06-10 23:49:16 Changing event name from before-call.apigateway to before-call.api-gateway
2019-06-10 23:49:16 Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2019-06-10 23:49:16 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2019-06-10 23:49:16 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-06-10 23:49:16 Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2019-06-10 23:49:16 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2019-06-10 23:49:16 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2019-06-10 23:49:16 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2019-06-10 23:49:16 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2019-06-10 23:49:16 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2019-06-10 23:49:16 'build' command is called
2019-06-10 23:49:16 No Parameters detected in the template
2019-06-10 23:49:16 2 resources found in the template
2019-06-10 23:49:16 Found Serverless function with name='DerpServiceLambda' and CodeUri='.'
2019-06-10 23:49:16 Building resource 'DerpServiceLambda'
2019-06-10 23:49:16 Looking for a supported build workflow in following directories: ['/home/knuckles/foo/derpservice-sam-issues', '/home/knuckles/foo/derpservice-sam-issues']
2019-06-10 23:49:16 Loading workflow module 'aws_lambda_builders.workflows'
2019-06-10 23:49:16 Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2019-06-10 23:49:16 Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
2019-06-10 23:49:16 Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
2019-06-10 23:49:16 Registering workflow 'GoDepBuilder' with capability 'Capability(language='go', dependency_manager='dep', application_framework=None)'
2019-06-10 23:49:16 Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
2019-06-10 23:49:16 Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2019-06-10 23:49:16 Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
2019-06-10 23:49:16 Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
2019-06-10 23:49:16 Found workflow 'JavaGradleWorkflow' to support capabilities 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2019-06-10 23:49:17 /home/knuckles/foo/derpservice-sam-issues/gradlew 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 'targetCompatibility' in Gradle.
2019-06-10 23:49:17 Running workflow 'JavaGradleWorkflow'
2019-06-10 23:49:17 Running JavaGradleWorkflow:GradleBuild
2019-06-10 23:49:19 JavaGradleWorkflow:GradleBuild succeeded
2019-06-10 23:49:19 Running JavaGradleWorkflow:CopyArtifacts
2019-06-10 23:49:19 JavaGradleWorkflow:CopyArtifacts 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
[*] Package: sam package --s3-bucket
```
Resulting build folder (notice the two copies of the dependencies):
```
$ tree .aws-sam/build/DerpServiceLambda
.aws-sam/build/DerpServiceLambda
├── derpservice
│ ├── AppKt.class
│ ├── bin
│ │ ├── derpservice
│ │ └── derpservice.bat
│ ├── DerpService$app$1.class
│ ├── DerpService$app$2.class
│ ├── DerpService$app$3.class
│ ├── DerpService$timingFilter$1$1.class
│ ├── DerpService$timingFilter$1.class
│ ├── DerpService.class
│ ├── DerpServiceLambda.class
│ └── lib
│ ├── annotations-13.0.jar
│ ├── derpservice.jar
│ ├── http4k-core-3.154.0.jar
│ ├── http4k-serverless-lambda-3.154.0.jar
│ ├── javax.servlet-api-4.0.1.jar
│ ├── kotlin-reflect-1.3.31.jar
│ ├── kotlin-stdlib-1.3.31.jar
│ ├── kotlin-stdlib-common-1.3.31.jar
│ ├── kotlin-stdlib-jdk7-1.3.31.jar
│ └── kotlin-stdlib-jdk8-1.3.31.jar
├── lib
│ ├── annotations-13.0.jar
│ ├── http4k-core-3.154.0.jar
│ ├── http4k-serverless-lambda-3.154.0.jar
│ ├── javax.servlet-api-4.0.1.jar
│ ├── kotlin-reflect-1.3.31.jar
│ ├── kotlin-stdlib-1.3.31.jar
│ ├── kotlin-stdlib-common-1.3.31.jar
│ ├── kotlin-stdlib-jdk7-1.3.31.jar
│ └── kotlin-stdlib-jdk8-1.3.31.jar
└── META-INF
├── derpservice.kotlin_module
└── MANIFEST.MF
5 directories, 31 files
```
Also, there seems to be an extra copy of the service as a jar (`derpservice.jar`) as well as the `bin/` launchers which are also useless for lambda.
### Expected result
Inside the build folder (and the zip file deployed), there should only be a single copy of every dependency, as well as a single copy of my service (either inside, or outside a jar, but not both).
### Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
1. OS: Ubuntu 18.10
2. `sam --version`: SAM CLI, version 0.17.0
Contributor guide
Assessment
This issue has not been assessed yet.