Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

JavaGradleWorkflow includes extraneous files if other archive artifacts are defined

オープン
#138 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 10 日以内に返信

@xujiantop-crypto がすでに取り組んでいます。

2026年9月17日 から。

  • #927 @xujiantop-crypto による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
java
領域
build-system

調査の方向性

aws_lambda_builders/workflows/java_gradle/resources/lambda-build-init.gradle から始め、特にアーカイブ成果物の選択と、JavaGradleWorkflow の GradleBuild および CopyArtifacts ステップを確認します。ドキュメントに記載された sam init、application-plugin edit、sam build、find コマンドで再現します。完了条件は、不要なアプリケーションの配布ディレクトリとそのファイルを含めずに、ビルドにアプリケーションのクラスと依存関係の JAR が含まれることです。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
381
フォーク
161
平均マージ
9日 8時間
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aws/aws-lambda-builders のほかの issue

aws/aws-lambda-builders の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。