Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

JavaGradleWorkflow includes extraneous files if other archive artifacts are defined

Đang mở
#138 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 10 ngày

@xujiantop-crypto đang làm issue này rồi.

Từ ngày 17/9/2026.

  • #927 của @xujiantop-crypto — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
38/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
java
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu với aws_lambda_builders/workflows/java_gradle/resources/lambda-build-init.gradle, đặc biệt là phần lựa chọn artifact của archive và các bước GradleBuild và CopyArtifacts của JavaGradleWorkflow. Tái hiện bằng các lệnh sam init, application-plugin edit, sam build và find đã được ghi trong tài liệu. Hoàn tất có nghĩa là build bao gồm các class của ứng dụng và các JAR dependency mà không có thư mục phân phối ứng dụng không cần thiết cùng các tệp của nó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area/workflow/java_gradle maintainer/need-response

Description:

In certain Gradle projects, running sam build may include files in the bundle that aren't needed.
This occurs because the logic for grabbing the project's jar is actually pulling the contents of all defined archive artifacts, some of which may be for other purposes entirely. In most cases, this doesn't "break" anything, but just increases the size of the deployment bundle silently.

One example of a situation that would cause this is a Java project with the built-in "application" plugin applied, which then produces additional zip and tar distribution artifacts.

https://github.com/awslabs/aws-lambda-builders/blob/develop/aws_lambda_builders/workflows/java_gradle/resources/lambda-build-init.gradle#L62

One potential fix would be to change https://github.com/awslabs/aws-lambda-builders/blob/develop/aws_lambda_builders/workflows/java_gradle/resources/lambda-build-init.gradle#L27 from def artifactJars = t.project.configurations.archives.artifacts.files.files to def artifactJars = configurations.archives.artifacts.findAll { it.extension == 'jar' }*.file.

Steps to reproduce the issue:

  1. Run sam init --runtime java8 --dependency-manager gradle --name gradlebuildtest
  2. Run cd gradlebuildtest/
  3. Run sam build && find .aws-sam/build/HelloWorldFunction -type f (Expected result)
  4. Remove the previous result: rm -rf .aws-sam/
  5. Edit HelloWorldFunction/build.gradle as follows
    • Add id 'application' to the plugins block
    • Add mainClassName = 'helloworld.App' (it's not actually executable yet, but that doesn't matter for demonstrating this behavior)
  6. Run sam build && find .aws-sam/build/HelloWorldFunction -type f (Observed result)
  7. Note that there is now an unnecessary HelloWorldFunction directory included.

Observed result:

mac-dcarr:gradlebuildtest dcarr$ sam build && find .aws-sam/build/HelloWorldFunction -type f
Building resource 'HelloWorldFunction'
Running JavaGradleWorkflow:GradleBuild
Running JavaGradleWorkflow:CopyArtifacts

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 <yourbucket>

.aws-sam/build/HelloWorldFunction/helloworld/GatewayResponse.class
.aws-sam/build/HelloWorldFunction/helloworld/App.class
.aws-sam/build/HelloWorldFunction/HelloWorldFunction/bin/HelloWorldFunction
.aws-sam/build/HelloWorldFunction/HelloWorldFunction/bin/HelloWorldFunction.bat
.aws-sam/build/HelloWorldFunction/HelloWorldFunction/lib/aws-lambda-java-core-1.2.0.jar
.aws-sam/build/HelloWorldFunction/HelloWorldFunction/lib/HelloWorldFunction.jar
.aws-sam/build/HelloWorldFunction/META-INF/MANIFEST.MF
.aws-sam/build/HelloWorldFunction/lib/aws-lambda-java-core-1.2.0.jar
mac-dcarr:gradlebuildtest dcarr$

Expected result:

mac-dcarr:gradlebuildtest dcarr$ sam build && find .aws-sam/build/HelloWorldFunction -type f
Building resource 'HelloWorldFunction'
Running JavaGradleWorkflow:GradleBuild
Running JavaGradleWorkflow:CopyArtifacts

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 <yourbucket>

.aws-sam/build/HelloWorldFunction/helloworld/GatewayResponse.class
.aws-sam/build/HelloWorldFunction/helloworld/App.class
.aws-sam/build/HelloWorldFunction/META-INF/MANIFEST.MF
.aws-sam/build/HelloWorldFunction/lib/aws-lambda-java-core-1.2.0.jar
mac-dcarr:gradlebuildtest dcarr$

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

Scripts were run on Mac OS X 10.14.6; SAM CLI, version 0.23.0.

Ngôn ngữ chính
Python
Star
381
Fork
161
Merge trung bình
9 ngày 8 giờ
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của aws/aws-lambda-builders

Tất cả issue của aws/aws-lambda-builders

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.