diff --git a/.github/workflows/java-native-image.yml b/.github/workflows/java-public-static-main-native-image-maven.yml similarity index 52% rename from .github/workflows/java-native-image.yml rename to .github/workflows/java-public-static-main-native-image-maven.yml index a05186a3..617147d3 100644 --- a/.github/workflows/java-native-image.yml +++ b/.github/workflows/java-public-static-main-native-image-maven.yml @@ -1,14 +1,14 @@ -name: native-image +name: java-public-static-main-native-image-maven "on": merge_group: pull_request: paths: - - java/native-image/java-native-image-sample/** + - java/native-image/public-static-main-native-image-maven/** push: branches: - main paths: - - java/native-image/java-native-image-sample/** + - java/native-image/public-static-main-native-image-maven/** jobs: test: @@ -23,10 +23,5 @@ jobs: with: java-version: ${{ matrix.java }} distribution: 'zulu' - - uses: actions/cache@v3 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('java/native-image/java-native-image-sample/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - run: ./mvnw -B package -Djava.version=${{ matrix.java }} - working-directory: java/native-image/java-native-image-sample + working-directory: java/native-image/public-static-main-native-image-maven diff --git a/.github/workflows/java-quarkus-native-image-maven.yml b/.github/workflows/java-quarkus-native-image-maven.yml new file mode 100644 index 00000000..800ba68a --- /dev/null +++ b/.github/workflows/java-quarkus-native-image-maven.yml @@ -0,0 +1,27 @@ +name: java-quarkus-native-image-maven +"on": + merge_group: + pull_request: + paths: + - java/native-image/quarkus-native-image-maven/** + push: + branches: + - main + paths: + - java/native-image/quarkus-native-image-maven/** + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + java: [17] + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + distribution: 'zulu' + - run: ./mvnw -B package -Djava.version=${{ matrix.java }} + working-directory: java/native-image/quarkus-native-image-maven diff --git a/.github/workflows/java-spring-boot-native-image-gradle.yml b/.github/workflows/java-spring-boot-native-image-gradle.yml new file mode 100644 index 00000000..4a8769c2 --- /dev/null +++ b/.github/workflows/java-spring-boot-native-image-gradle.yml @@ -0,0 +1,27 @@ +name: java-spring-boot-native-image-gradle +"on": + merge_group: + pull_request: + paths: + - java/native-image/spring-boot-native-image-gradle/** + push: + branches: + - main + paths: + - java/native-image/spring-boot-native-image-gradle/** + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + java: [17] + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + distribution: 'zulu' + - run: ./gradlew build + working-directory: java/native-image/spring-boot-native-image-gradle diff --git a/.github/workflows/java-spring-boot-native-image-maven.yml b/.github/workflows/java-spring-boot-native-image-maven.yml new file mode 100644 index 00000000..f462b233 --- /dev/null +++ b/.github/workflows/java-spring-boot-native-image-maven.yml @@ -0,0 +1,27 @@ +name: java-spring-boot-native-image-maven +"on": + merge_group: + pull_request: + paths: + - java/native-image/spring-boot-native-image-maven/** + push: + branches: + - main + paths: + - java/native-image/spring-boot-native-image-maven/** + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + java: [17] + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + distribution: 'zulu' + - run: ./mvnw -B package -Djava.version=${{ matrix.java }} + working-directory: java/native-image/spring-boot-native-image-maven diff --git a/.github/workflows/test-all-samples.yml b/.github/workflows/test-all-samples.yml index 51cd65d8..61b69228 100644 --- a/.github/workflows/test-all-samples.yml +++ b/.github/workflows/test-all-samples.yml @@ -12,70 +12,46 @@ on: - 'scripts/.util/tools.json' jobs: + prepare: + name: Prepare + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.paths.outputs.matrix }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Discover changed paths + id: paths + run: | + set -eo pipefail + all_java_smoke_test_paths=$( find ./java -iname "smoke_test" | jq --raw-input | jq --slurp --compact-output ) + all_other_smoke_test_paths='["ca-certificates","dotnet-core","git","go","nodejs","php","procfile","python","ruby","web-servers"]' + all_paths=$( echo -e "$all_java_smoke_test_paths\n$all_other_smoke_test_paths" | jq -s 'add' -c ) + + echo "These are the Java projects we'll run smoke tests against: $all_java_smoke_test_paths" >> $GITHUB_STEP_SUMMARY + echo "These are the other folders we'll run smoke tests against: : $all_other_smoke_test_paths" >> $GITHUB_STEP_SUMMARY + echo "These are all the smoke test locations: $all_paths" >> $GITHUB_STEP_SUMMARY + echo "matrix={\"suite\":$all_paths}" >> $GITHUB_OUTPUT + echo "This is how the matrix will look like: $(cat $GITHUB_OUTPUT)" + smoke: + needs: prepare name: Smoke Tests runs-on: ubuntu-latest strategy: fail-fast: false max-parallel: 3 - matrix: - suite: - - 'ca-certificates' - - 'dotnet-core' - - 'git' - - 'go' - - 'java' - - 'nodejs' - - 'php' - - 'procfile' - - 'python' - - 'ruby' - - 'web-servers' + matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }} steps: - name: Setup Go uses: actions/setup-go@v4 with: - go-version: 1.18.x + go-version: 1.20.x - name: Checkout uses: actions/checkout@v4 - - name: Cache local Gradle repository - if: ${{ matrix.suite == 'java' }} - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('java/**/*.gradle*', 'java/**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Cache local Maven repository - if: ${{ matrix.suite == 'java' }} - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - ~/.m2/wrapper - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', 'java/**/maven-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Setup Directories - if: ${{ matrix.suite == 'java' }} - run: | - #!/usr/bin/env bash - set -euo pipefail - - mkdir -p ~/.m2/repository - mkdir -p ~/.m2/repository/wrapper/dists - mkdir -p ~/.gradle/caches - mkdir -p ~/.gradle/wrapper/dists - chmod -R 775 ~/.m2 - chmod -R 775 ~/.gradle - - name: Test ${{ matrix.suite }} run: | ./scripts/smoke.sh --builder paketobuildpacks/builder-jammy-full:latest --suite ${{ matrix.suite }} diff --git a/.github/workflows/test-pull-request-java-native-image.yml b/.github/workflows/test-pull-request-java-native-image.yml index 3356dfd2..e69de29b 100644 --- a/.github/workflows/test-pull-request-java-native-image.yml +++ b/.github/workflows/test-pull-request-java-native-image.yml @@ -1,61 +0,0 @@ -name: Test Pull Request (Java Native Image) - -on: - merge_group: - pull_request: - branches: - - main - paths: - - 'java/native-image/**' - -jobs: - smoke: - name: Smoke Tests - runs-on: ubuntu-latest - steps: - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: 1.18.x - - - name: Checkout - uses: actions/checkout@v4 - - - name: Cache local Gradle repository - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('java/**/*.gradle*', 'java/**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - ~/.m2/wrapper - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', 'java/**/maven-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Setup Directories - run: | - #!/usr/bin/env bash - set -euo pipefail - - mkdir -p ~/.m2/repository - mkdir -p ~/.m2/repository/wrapper/dists - mkdir -p ~/.gradle/caches - mkdir -p ~/.gradle/wrapper/dists - chmod -R 775 ~/.m2 - chmod -R 775 ~/.gradle - - - name: Test Java Native Image Samples - run: | - ./scripts/smoke.sh --suite java/native-image \ - --builder paketobuildpacks/builder-jammy-full:latest \ - --builder paketobuildpacks/builder-jammy-base:latest \ - --builder paketobuildpacks/builder-jammy-tiny:latest diff --git a/.github/workflows/test-pull-request-java-node.yml b/.github/workflows/test-pull-request-java-node.yml index 3e0b6f87..e69de29b 100644 --- a/.github/workflows/test-pull-request-java-node.yml +++ b/.github/workflows/test-pull-request-java-node.yml @@ -1,60 +0,0 @@ -name: Test Pull Request (Java-Node) - -on: - merge_group: - pull_request: - branches: - - main - paths: - - 'java/java-node/**' - -jobs: - smoke: - name: Smoke Tests Java-Node - runs-on: ubuntu-latest - steps: - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: 1.18.x - - - name: Checkout - uses: actions/checkout@v4 - - - name: Cache local Gradle repository - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('java/**/*.gradle*', 'java/**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - ~/.m2/wrapper - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', 'java/**/maven-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Setup Directories - run: | - #!/usr/bin/env bash - set -euo pipefail - - mkdir -p ~/.m2/repository - mkdir -p ~/.m2/repository/wrapper/dists - mkdir -p ~/.gradle/caches - mkdir -p ~/.gradle/wrapper/dists - chmod -R 775 ~/.m2 - chmod -R 775 ~/.gradle - - - name: Test Java-Node Samples - run: | - ./scripts/smoke.sh --suite java/java-node \ - --builder paketobuildpacks/builder-jammy-full:latest \ - --builder paketobuildpacks/builder-jammy-base:latest \ diff --git a/.github/workflows/test-pull-request-java.yml b/.github/workflows/test-pull-request-java.yml index 74dd0ab2..b2597e8a 100644 --- a/.github/workflows/test-pull-request-java.yml +++ b/.github/workflows/test-pull-request-java.yml @@ -1,63 +1,87 @@ -name: Test Pull Request (Java) +name: Smoke Test Pull Request (Java) on: merge_group: pull_request: branches: - - main + - main paths: - - 'java/**' - - '!java/native-image/**' - - '!java/java-node/**' + - 'java/**' jobs: + prepare: + name: Prepare + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.paths.outputs.matrix }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Discover changed paths + id: paths + run: | + set -eo pipefail + # 1st step: we get the list of files changed between the tip of this PR branch and main + # Since we're only interested in the folders containing those files, we get them, sort them alphabetically (`sort`), de duplicate them (`uniq`) and filter out dot folders (.github for example) + # we end up with, for example, changed_java_folders="java/akka/smoke_test\njava/kotlin/gradle/wrapper\njava/application-insights" + changed_java_folders=$( git diff --name-only --merge-base origin/$GITHUB_BASE_REF $GITHUB_SHA | xargs -n 1 dirname | sort -k 2 | uniq | grep -v "^\." ) + + # 2nd step: we only want to keep the folders that contain a `smoke_test` subfolder -> those contain the tests we can run + # To do that, we loop through all the changed_java_folders and test (`-s`) for a sub folder named `smoke_test`; if there's none, we go to the parent directory (`dirname`) + # eventually, we'll find a `smoke_test` folder and add it to `smoke_test_folders`; if not, we move on to the next changed_java_folders entry (until the `.` folder in which case we give up) + + smoke_test_folders="" + while read -r changed_folder + do + echo "working on $changed_folder" + smoke_test="" + current_folder=$changed_folder + while [ -z "$smoke_test" ] && [ "$current_folder" != "." ] + do + echo "--smoke_test is $smoke_test" + echo "--current_folder is $current_folder" + if [[ -s $current_folder/smoke_test ]]; then + smoke_test="$current_folder/smoke_test" + else + current_folder=$(dirname $current_folder) + fi + done + if [ "$current_folder" != "." ]; then + smoke_test_folders="$smoke_test_folders\"$smoke_test\"\n" + fi + done <<<"$changed_java_folders" + + # Once the smoke_test_folders are all found, we de duplicate them (`uniq`), remove extra empty lines (`\S`), and format them into a string + # we end up with, for example, smoke_test_folders='"java/akka/smoke_test","java/kotlin/smoke_test","java/application-insights/smoke_test"' + # see: https://stackoverflow.com/a/8721550/24069 for usage of paste + smoke_test_folders=$( echo -e $smoke_test_folders | uniq | grep "\S" | paste -s -d, -) + + echo "These are the Java folders where we found changes for this PR : $changed_java_folders" >> $GITHUB_STEP_SUMMARY + echo "These are the Java folders where we found changes AND the presence of smoke tests for this PR : $smoke_test_folders" >> $GITHUB_STEP_SUMMARY + echo "matrix={\"java_sample_folder\":[$smoke_test_folders]}" >> $GITHUB_OUTPUT + echo "This is how the matrix will look like: $(cat $GITHUB_OUTPUT)" + smoke: + needs: prepare name: Smoke Tests runs-on: ubuntu-latest + strategy: + matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }} + steps: - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: 1.18.x - - - name: Checkout - uses: actions/checkout@v4 - - - name: Cache local Gradle repository - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('java/**/*.gradle*', 'java/**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - ~/.m2/wrapper - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml', 'java/**/maven-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Setup Directories - run: | - #!/usr/bin/env bash - set -euo pipefail - - mkdir -p ~/.m2/repository - mkdir -p ~/.m2/repository/wrapper/dists - mkdir -p ~/.gradle/caches - mkdir -p ~/.gradle/wrapper/dists - chmod -R 775 ~/.m2 - chmod -R 775 ~/.gradle - - - name: Test Java Samples - run: | - ./scripts/smoke.sh --suite java \ - --builder paketobuildpacks/builder-jammy-full:latest \ - --builder paketobuildpacks/builder-jammy-base:latest \ - --builder paketobuildpacks/builder-jammy-tiny:latest + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: 1.20.x + + - name: Checkout + uses: actions/checkout@v4 + + - name: Smoke Test Java samples + run: | + echo "About to run the smoke test script against this suite folder: ${{ matrix.java_sample_folder }}/smoke_test" + ./scripts/smoke.sh --suite ${{ matrix.java_sample_folder }} \ + --builder paketobuildpacks/builder-jammy-base:latest \ + --builder paketobuildpacks/builder-jammy-tiny:latest diff --git a/java/akka/smoke_test/akka_test.go b/java/akka/smoke_test/akka_test.go new file mode 100644 index 00000000..27b4d21d --- /dev/null +++ b/java/akka/smoke_test/akka_test.go @@ -0,0 +1,124 @@ +package akka_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} + +func TestAkka(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - Akka", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Akka with %s builder", builder), testAkkaWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testAkkaWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses akka", func() { + it("builds successfully", func() { + if strings.Contains(builder, "tiny") { + return // this sample requires bash, does not run on tiny + } + + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for SBT"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for DistZip"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(BeAvailable()) + }) + }) + }) + } +} diff --git a/java/application-insights/pom.xml b/java/application-insights/pom.xml index 47f600b0..aee5668e 100644 --- a/java/application-insights/pom.xml +++ b/java/application-insights/pom.xml @@ -4,7 +4,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.14 + 2.7.15 io.paketo diff --git a/java/application-insights/smoke_test/application_insights_test.go b/java/application-insights/smoke_test/application_insights_test.go new file mode 100644 index 00000000..0b99de3f --- /dev/null +++ b/java/application-insights/smoke_test/application_insights_test.go @@ -0,0 +1,120 @@ +package application_insights_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} + +func TestApplicationInsights(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - Application Insights", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Application Insights with %s builder", builder), testApplicationInsightsWithBuilders(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testApplicationInsightsWithBuilders(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses application insights", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) + }) + }) + }) + } +} diff --git a/java/aspectj/pom.xml b/java/aspectj/pom.xml index 51a7808c..8c16392d 100644 --- a/java/aspectj/pom.xml +++ b/java/aspectj/pom.xml @@ -4,7 +4,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.14 + 2.7.15 io.paketo diff --git a/java/aspectj/smoke_test/aspectj_test.go b/java/aspectj/smoke_test/aspectj_test.go new file mode 100644 index 00000000..5f5a8813 --- /dev/null +++ b/java/aspectj/smoke_test/aspectj_test.go @@ -0,0 +1,119 @@ +package aspectj_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestAspectJ(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - AspectJ", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("AspectJ with %s builder", builder), testAspectJWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testAspectJWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses aspectj", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) + }) + }) + }) + } +} diff --git a/java/deps/smoke_test/deps_test.go b/java/deps/smoke_test/deps_test.go new file mode 100644 index 00000000..46748d1b --- /dev/null +++ b/java/deps/smoke_test/deps_test.go @@ -0,0 +1,125 @@ +package deps_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestDeps(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - Deps", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Deps with %s builder", builder), testDepsWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testDepsWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses clojure tools with deps", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithEnv(map[string]string{ + "JAVA_TOOL_OPTIONS": "-XX:MaxMetaspaceSize=100M", + }). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Clojure Tools"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + WithPublishAll(). + WithTTY(). + WithEnv(map[string]string{ + "JAVA_TOOL_OPTIONS": "-XX:MaxMetaspaceSize=100M"}). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("Hello World!")).OnPort(8080)) + }) + }) + }) + } +} diff --git a/java/dist-zip/build.gradle b/java/dist-zip/build.gradle index 22abc8db..e25e160f 100644 --- a/java/dist-zip/build.gradle +++ b/java/dist-zip/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' - id 'org.springframework.boot' version '3.1.1' - id 'io.spring.dependency-management' version '1.1.2' + id 'org.springframework.boot' version '3.1.3' + id 'io.spring.dependency-management' version '1.1.3' id 'application' } diff --git a/java/dist-zip/gradle/wrapper/gradle-wrapper.properties b/java/dist-zip/gradle/wrapper/gradle-wrapper.properties index f398c33c..4e86b927 100644 --- a/java/dist-zip/gradle/wrapper/gradle-wrapper.properties +++ b/java/dist-zip/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/java/dist-zip/smoke_test/dist_zip_test.go b/java/dist-zip/smoke_test/dist_zip_test.go new file mode 100644 index 00000000..8c1a46c3 --- /dev/null +++ b/java/dist-zip/smoke_test/dist_zip_test.go @@ -0,0 +1,127 @@ +package dist_zip_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestDistZip(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - Dist Zip", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Dist Zip with %s builder", builder), testDistZipWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testDistZipWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses dist zip", func() { + it("builds successfully", func() { + if strings.Contains(builder, "tiny") { + return // this sample requires bash, does not run on tiny + } + + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithEnv(map[string]string{ + "BP_JVM_VERSION": "17", + "BP_GRADLE_BUILD_ARGUMENTS": "--no-daemon -x test bootDistZip", + "BP_GRADLE_BUILT_ARTIFACT": "build/distributions/*.zip"}). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Gradle"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for DistZip"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) + }) + }) + }) + } +} diff --git a/java/gradle/build.gradle b/java/gradle/build.gradle index 299fadc7..88413502 100644 --- a/java/gradle/build.gradle +++ b/java/gradle/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' - id 'org.springframework.boot' version '3.1.2' - id 'io.spring.dependency-management' version '1.1.2' + id 'org.springframework.boot' version '3.1.3' + id 'io.spring.dependency-management' version '1.1.3' } group = 'io.paketo' diff --git a/java/gradle/gradle/wrapper/gradle-wrapper.properties b/java/gradle/gradle/wrapper/gradle-wrapper.properties index f398c33c..4e86b927 100644 --- a/java/gradle/gradle/wrapper/gradle-wrapper.properties +++ b/java/gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/java/gradle/smoke_test/gradle_test.go b/java/gradle/smoke_test/gradle_test.go new file mode 100644 index 00000000..34e21f3a --- /dev/null +++ b/java/gradle/smoke_test/gradle_test.go @@ -0,0 +1,122 @@ +package gradle_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestGradle(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - Gradle", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Gradle with %s builder", builder), testGradleWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testGradleWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses gradle", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithEnv(map[string]string{ + "BP_JVM_VERSION": "17", + "BP_GRADLE_BUILT_ARTIFACT": "build/libs/*-SNAPSHOT.jar", + }). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Gradle"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) + }) + }) + }) + } +} diff --git a/java/jar/smoke_test/jar_test.go b/java/jar/smoke_test/jar_test.go new file mode 100644 index 00000000..3a53ba89 --- /dev/null +++ b/java/jar/smoke_test/jar_test.go @@ -0,0 +1,118 @@ +package jar_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestJar(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - JAR", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("JAR with %s builder", builder), testJarWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testJarWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses jar", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithBuilder(builder). + WithEnv(map[string]string{"BP_JVM_VERSION": "17"}). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) + }) + }) + }) + } +} diff --git a/java/java-node/gradle-node/build.gradle b/java/java-node/gradle-node/build.gradle index 65471dfd..3e772179 100644 --- a/java/java-node/gradle-node/build.gradle +++ b/java/java-node/gradle-node/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java' - id 'org.springframework.boot' version '3.0.5' - id 'io.spring.dependency-management' version '1.1.0' + id 'org.springframework.boot' version '3.0.10' + id 'io.spring.dependency-management' version '1.1.3' } group = 'io.paketo' diff --git a/java/java-node/gradle-node/gradle/wrapper/gradle-wrapper.properties b/java/java-node/gradle-node/gradle/wrapper/gradle-wrapper.properties index f398c33c..4e86b927 100644 --- a/java/java-node/gradle-node/gradle/wrapper/gradle-wrapper.properties +++ b/java/java-node/gradle-node/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/java/java-node/gradle-node/smoke_test/gradle_node_test.go b/java/java-node/gradle-node/smoke_test/gradle_node_test.go new file mode 100644 index 00000000..b5822ccc --- /dev/null +++ b/java/java-node/gradle-node/smoke_test/gradle_node_test.go @@ -0,0 +1,136 @@ +package java_node_test + +import ( + "flag" + "fmt" + "os" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/paketo-buildpacks/samples/tests" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} + +func TestGradleNode(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - Gradle & Node", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Gradle Node with %s builder", builder), testGradleNodeWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testGradleNodeWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses gradle and node", func() { + it("builds successfully", func() { + if strings.Contains(builder, "tiny") { + return // this sample requires bash, does not run on tiny + } + + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithBuilder(builder). + WithGID("123"). + WithEnv(map[string]string{ + "BP_JVM_VERSION": "17", + "BP_JAVA_INSTALL_NODE": "true", + "BP_NODE_PROJECT_PATH": "frontend"}). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Node Engine"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Gradle"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) + Eventually(container). + Should( + Serve(MatchRegexp("")). + OnPort(8080). + WithEndpoint("/")) + + }) + }) + }) + } +} diff --git a/java/java-node/maven-yarn/pom.xml b/java/java-node/maven-yarn/pom.xml index bf59b3ef..9b5fde02 100644 --- a/java/java-node/maven-yarn/pom.xml +++ b/java/java-node/maven-yarn/pom.xml @@ -4,7 +4,7 @@ org.springframework.boot spring-boot-starter-parent - 3.0.5 + 3.0.10 io.paketo diff --git a/java/java-node/java_node_test.go b/java/java-node/maven-yarn/smoke_test/maven_node_test.go similarity index 59% rename from java/java-node/java_node_test.go rename to java/java-node/maven-yarn/smoke_test/maven_node_test.go index 72721413..b5bd78bd 100644 --- a/java/java-node/java_node_test.go +++ b/java/java-node/maven-yarn/smoke_test/maven_node_test.go @@ -1,15 +1,16 @@ -package java_test +package java_node_test import ( "flag" "fmt" + "github.com/paketo-buildpacks/samples/tests" "os" "path/filepath" + "strings" "testing" "time" "github.com/paketo-buildpacks/occam" - "github.com/paketo-buildpacks/samples/tests" "github.com/sclevine/spec" "github.com/sclevine/spec/report" @@ -22,22 +23,21 @@ var builders tests.BuilderFlags func init() { flag.Var(&builders, "name", "the name a builder to test with") } - -func TestJava(t *testing.T) { +func TestMavenNode(t *testing.T) { Expect := NewWithT(t).Expect Expect(len(builders)).NotTo(Equal(0)) SetDefaultEventuallyTimeout(60 * time.Second) - suite := spec.New("Java", spec.Parallel(), spec.Report(report.Terminal{})) + suite := spec.New("Java - Maven & Node", spec.Parallel(), spec.Report(report.Terminal{})) for _, builder := range builders { - suite(fmt.Sprintf("Java with %s builder", builder), testJavaWithBuilder(builder), spec.Sequential()) + suite(fmt.Sprintf("Maven Node with %s builder", builder), testMavenNodeWithBuilder(builder), spec.Sequential()) } suite.Run(t) } -func testJavaWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { +func testMavenNodeWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { return func(t *testing.T, context spec.G, it spec.S) { var ( Expect = NewWithT(t).Expect @@ -45,7 +45,6 @@ func testJavaWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { pack occam.Pack docker occam.Docker - home string = os.Getenv("HOME") ) it.Before(func() { @@ -80,7 +79,7 @@ func testJavaWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { err = docker.Image.Remove.Execute(image.ID) if err != nil { - Expect(err).To(MatchError("failed to remove docker image: exit status 1: Error: No such image:")) + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) } else { Expect(err).ToNot(HaveOccurred()) } @@ -90,15 +89,18 @@ func testJavaWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { context("app uses maven and yarn", func() { it("builds successfully", func() { + if strings.Contains(builder, "tiny") { + return // this sample requires bash, does not run on tiny + } + var err error - source, err = occam.Source(filepath.Join(".", "maven-yarn")) + source, err = occam.Source(filepath.Join("../")) Expect(err).NotTo(HaveOccurred()) var logs fmt.Stringer image, logs, err = pack.Build. WithPullPolicy("never"). WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.m2:/home/cnb/.m2:rw", home)). WithGID("123"). WithEnv(map[string]string{ "BP_JVM_VERSION": "17", @@ -129,47 +131,6 @@ func testJavaWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { }) }) - - context("app uses gradle and node", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join(".", "gradle-node")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.gradle:/home/cnb/.gradle:rw", home)). - WithGID("123"). - WithEnv(map[string]string{ - "BP_JVM_VERSION": "17", - "BP_JAVA_INSTALL_NODE": "true", - "BP_NODE_PROJECT_PATH": "frontend"}). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Node Engine"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Gradle"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) - Eventually(container). - Should( - Serve(MatchRegexp("")). - OnPort(8080). - WithEndpoint("/")) - - }) - }) }) } } diff --git a/java/java_test.go b/java/java_test.go deleted file mode 100644 index b89a467e..00000000 --- a/java/java_test.go +++ /dev/null @@ -1,524 +0,0 @@ -package java_test - -import ( - "flag" - "fmt" - "os" - "path/filepath" - "strings" - "testing" - "time" - - "github.com/paketo-buildpacks/occam" - "github.com/paketo-buildpacks/samples/tests" - "github.com/sclevine/spec" - "github.com/sclevine/spec/report" - - . "github.com/onsi/gomega" - . "github.com/paketo-buildpacks/occam/matchers" -) - -var builders tests.BuilderFlags - -func init() { - flag.Var(&builders, "name", "the name a builder to test with") -} - -func TestJava(t *testing.T) { - Expect := NewWithT(t).Expect - - Expect(len(builders)).NotTo(Equal(0)) - - SetDefaultEventuallyTimeout(60 * time.Second) - - suite := spec.New("Java", spec.Parallel(), spec.Report(report.Terminal{})) - for _, builder := range builders { - suite(fmt.Sprintf("Java with %s builder", builder), testJavaWithBuilder(builder), spec.Sequential()) - } - suite.Run(t) -} - -func testJavaWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { - return func(t *testing.T, context spec.G, it spec.S) { - var ( - Expect = NewWithT(t).Expect - Eventually = NewWithT(t).Eventually - - pack occam.Pack - docker occam.Docker - home string = os.Getenv("HOME") - ) - - it.Before(func() { - pack = occam.NewPack().WithVerbose().WithNoColor() - docker = occam.NewDocker() - }) - - context("detects a Java app", func() { - var ( - image occam.Image - container occam.Container - - name string - source string - ) - - it.Before(func() { - var err error - name, err = occam.RandomName() - Expect(err).NotTo(HaveOccurred()) - }) - - it.After(func() { - err := docker.Container.Remove.Execute(container.ID) - if err != nil { - Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) - } else { - Expect(err).ToNot(HaveOccurred()) - } - - Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) - - err = docker.Image.Remove.Execute(image.ID) - if err != nil { - Expect(err).To(MatchError("failed to remove docker image: exit status 1: Error: No such image:")) - } else { - Expect(err).ToNot(HaveOccurred()) - } - - Expect(os.RemoveAll(source)).To(Succeed()) - }) - - context("app uses akka", func() { - it("builds successfully", func() { - if strings.HasSuffix(builder, "tiny") { - return // this sample requires bash, does not run on tiny - } - - var err error - source, err = occam.Source(filepath.Join("../java", "akka")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.m2:/home/cnb/.m2:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for SBT"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for DistZip"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(BeAvailable()) - }) - }) - - context("app uses application insights", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join("../java", "application-insights")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.m2:/home/cnb/.m2:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) - }) - }) - - context("app uses aspectj", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join("../java", "aspectj")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.m2:/home/cnb/.m2:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) - }) - }) - - context("app uses dist zip", func() { - it("builds successfully", func() { - if strings.HasSuffix(builder, "tiny") { - return // this sample requires bash, does not run on tiny - } - - var err error - source, err = occam.Source(filepath.Join("../java", "dist-zip")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithEnv(map[string]string{ - "BP_JVM_VERSION": "17", - "BP_GRADLE_BUILD_ARGUMENTS": "--no-daemon -x test bootDistZip", - "BP_GRADLE_BUILT_ARTIFACT": "build/distributions/*.zip"}). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.gradle:/home/cnb/.gradle:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Gradle"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for DistZip"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) - }) - }) - - context("app uses gradle", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join("../java", "gradle")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithEnv(map[string]string{ - "BP_JVM_VERSION": "17", - "BP_GRADLE_BUILT_ARTIFACT": "build/libs/*-SNAPSHOT.jar", - }). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.gradle:/home/cnb/.gradle:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Gradle"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) - }) - }) - - context("app uses jar", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join("../java", "jar")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithBuilder(builder). - WithEnv(map[string]string{"BP_JVM_VERSION": "17"}). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) - }) - }) - - context("app uses kotlin", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join("../java", "kotlin")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithEnv(map[string]string{ - "BP_GRADLE_BUILT_ARTIFACT": "build/libs/*-SNAPSHOT.jar", - }). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.gradle:/home/cnb/.gradle:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Gradle"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) - }) - }) - - context("app uses leiningen", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join("../java", "leiningen")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithEnv(map[string]string{ - "JAVA_TOOL_OPTIONS": "-XX:MaxMetaspaceSize=100M", - }). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.m2:/home/cnb/.m2:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Leiningen"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - WithPublishAll(). - WithTTY(). - WithEnv(map[string]string{ - "JAVA_TOOL_OPTIONS": "-XX:MaxMetaspaceSize=100M"}). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("Hello World!")).OnPort(8080)) - }) - }) - - context("app uses maven", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join("../java", "maven")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.m2:/home/cnb/.m2:rw", home)). - WithGID("123"). - WithEnv(map[string]string{"BP_JVM_VERSION": "17"}). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) - }) - }) - - context("app uses opentelemetry", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join("../java", "opentelemetry")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("if-not-present"). - WithEnv(map[string]string{ - "BP_OPENTELEMETRY_ENABLED": "true", - }). - WithBuilder(builder). - WithBuildpacks( - "paketo-buildpacks/java", - "gcr.io/paketo-buildpacks/opentelemetry", - ). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Gradle"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for OpenTelemetry"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) - }) - }) - - context("app uses war", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join("../java", "war")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.m2:/home/cnb/.m2:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Apache Tomcat"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) - }) - }) - - context("app uses clojure tools with deps", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join("../java", "deps")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithEnv(map[string]string{ - "JAVA_TOOL_OPTIONS": "-XX:MaxMetaspaceSize=100M", - }). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.m2:/home/cnb/.m2:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Clojure Tools"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - WithPublishAll(). - WithTTY(). - WithEnv(map[string]string{ - "JAVA_TOOL_OPTIONS": "-XX:MaxMetaspaceSize=100M"}). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("Hello World!")).OnPort(8080)) - }) - }) - - context("app uses clojure tools with tools build", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join("../java", "tools-build")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithEnv(map[string]string{ - "BP_CLJ_TOOLS_BUILD_ENABLED": "true", - "JAVA_TOOL_OPTIONS": "-XX:MaxMetaspaceSize=100M", - }). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.m2:/home/cnb/.m2:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Clojure Tools"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - - container, err = docker.Container.Run. - WithPublish("8080"). - WithPublishAll(). - WithTTY(). - WithEnv(map[string]string{ - "JAVA_TOOL_OPTIONS": "-XX:MaxMetaspaceSize=100M", - }). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(Serve(ContainSubstring("Hello World!")).OnPort(8080)) - }) - }) - }) - } -} diff --git a/java/kotlin/build.gradle.kts b/java/kotlin/build.gradle.kts index 765784f7..7608d244 100644 --- a/java/kotlin/build.gradle.kts +++ b/java/kotlin/build.gradle.kts @@ -1,8 +1,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { - id("org.springframework.boot") version "2.7.7" - id("io.spring.dependency-management") version "1.1.0" + id("org.springframework.boot") version "2.7.15" + id("io.spring.dependency-management") version "1.1.3" kotlin("jvm") version "1.6.21" kotlin("plugin.spring") version "1.6.21" } diff --git a/java/kotlin/gradle/wrapper/gradle-wrapper.jar b/java/kotlin/gradle/wrapper/gradle-wrapper.jar index 62d4c053..7454180f 100644 Binary files a/java/kotlin/gradle/wrapper/gradle-wrapper.jar and b/java/kotlin/gradle/wrapper/gradle-wrapper.jar differ diff --git a/java/kotlin/gradle/wrapper/gradle-wrapper.properties b/java/kotlin/gradle/wrapper/gradle-wrapper.properties index 69a97150..98debb84 100644 --- a/java/kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/java/kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/java/kotlin/gradlew b/java/kotlin/gradlew index fbd7c515..744e882e 100755 --- a/java/kotlin/gradlew +++ b/java/kotlin/gradlew @@ -72,7 +72,7 @@ case "`uname`" in Darwin* ) darwin=true ;; - MINGW* ) + MSYS* | MINGW* ) msys=true ;; NONSTOP* ) @@ -130,7 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath diff --git a/java/kotlin/gradlew.bat b/java/kotlin/gradlew.bat index 5093609d..107acd32 100644 --- a/java/kotlin/gradlew.bat +++ b/java/kotlin/gradlew.bat @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -54,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -64,21 +64,6 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line @@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/java/kotlin/smoke_test/kotlin_test.go b/java/kotlin/smoke_test/kotlin_test.go new file mode 100644 index 00000000..3167cfc8 --- /dev/null +++ b/java/kotlin/smoke_test/kotlin_test.go @@ -0,0 +1,122 @@ +package kotlin_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestKotlin(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - Kotlin", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Kotlin with %s builder", builder), testKotlinWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testKotlinWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses kotlin", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithEnv(map[string]string{ + "BP_GRADLE_BUILT_ARTIFACT": "build/libs/*-SNAPSHOT.jar", + }). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Gradle"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) + }) + }) + }) + } +} diff --git a/java/leiningen/smoke_test/leiningen_test.go b/java/leiningen/smoke_test/leiningen_test.go new file mode 100644 index 00000000..1481e846 --- /dev/null +++ b/java/leiningen/smoke_test/leiningen_test.go @@ -0,0 +1,125 @@ +package leiningen_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestLeiningen(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - Leiningen", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Leiningen with %s builder", builder), testLeiningenWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testLeiningenWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses leiningen", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithEnv(map[string]string{ + "JAVA_TOOL_OPTIONS": "-XX:MaxMetaspaceSize=100M", + }). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Leiningen"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + WithPublishAll(). + WithTTY(). + WithEnv(map[string]string{ + "JAVA_TOOL_OPTIONS": "-XX:MaxMetaspaceSize=100M"}). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("Hello World!")).OnPort(8080)) + }) + }) + }) + } +} diff --git a/java/maven/pom.xml b/java/maven/pom.xml index 3d1d617e..05ace2ad 100644 --- a/java/maven/pom.xml +++ b/java/maven/pom.xml @@ -4,7 +4,7 @@ org.springframework.boot spring-boot-starter-parent - 3.1.2 + 3.1.3 io.paketo diff --git a/java/maven/smoke_test/maven_test.go b/java/maven/smoke_test/maven_test.go new file mode 100644 index 00000000..fc9e236c --- /dev/null +++ b/java/maven/smoke_test/maven_test.go @@ -0,0 +1,120 @@ +package maven_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestMaven(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - Maven", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Maven with %s builder", builder), testMavenWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testMavenWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses maven", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithBuilder(builder). + WithGID("123"). + WithEnv(map[string]string{"BP_JVM_VERSION": "17"}). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) + }) + }) + }) + } +} diff --git a/java/native-image/java_native_image_test.go b/java/native-image/java_native_image_test.go deleted file mode 100644 index 708e5c5c..00000000 --- a/java/native-image/java_native_image_test.go +++ /dev/null @@ -1,220 +0,0 @@ -package java_test - -import ( - "flag" - "fmt" - "os" - "path/filepath" - "testing" - "time" - - "github.com/paketo-buildpacks/occam" - "github.com/paketo-buildpacks/samples/tests" - "github.com/sclevine/spec" - "github.com/sclevine/spec/report" - - . "github.com/onsi/gomega" - . "github.com/paketo-buildpacks/occam/matchers" -) - -var builders tests.BuilderFlags - -func init() { - flag.Var(&builders, "name", "the name a builder to test with") -} - -func TestJNI(t *testing.T) { - Expect := NewWithT(t).Expect - - Expect(len(builders)).NotTo(Equal(0)) - - SetDefaultEventuallyTimeout(60 * time.Second) - - suite := spec.New("JavaNativeImage", spec.Parallel(), spec.Report(report.Terminal{})) - for _, builder := range builders { - suite(fmt.Sprintf("Java Native Image with %s builder", builder), testJNIWithBuilder(builder), spec.Sequential()) - } - suite.Run(t) -} - -func testJNIWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { - return func(t *testing.T, context spec.G, it spec.S) { - var ( - Expect = NewWithT(t).Expect - Eventually = NewWithT(t).Eventually - - pack occam.Pack - docker occam.Docker - home string = os.Getenv("HOME") - ) - - it.Before(func() { - pack = occam.NewPack().WithVerbose().WithNoColor() - docker = occam.NewDocker() - }) - - context("detects a Java Native Image app", func() { - var ( - image occam.Image - container occam.Container - - name string - source string - ) - - it.Before(func() { - var err error - name, err = occam.RandomName() - Expect(err).NotTo(HaveOccurred()) - }) - - it.After(func() { - Expect(docker.Container.Remove.Execute(container.ID)).To(Succeed()) - Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) - Expect(docker.Image.Remove.Execute(image.ID)).To(Succeed()) - Expect(os.RemoveAll(source)).To(Succeed()) - }) - - context("uses Spring Boot app", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join(".", "java-native-image-sample")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithEnv(map[string]string{ - "BP_NATIVE_IMAGE": "true", - "BP_MAVEN_BUILD_ARGUMENTS": "-Dmaven.test.skip=true --no-transfer-progress -Pnative package", - "BP_JVM_VERSION": "17"}). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.m2:/home/cnb/.m2:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - container, err = docker.Container.Run. - WithEnv(map[string]string{"PORT": "8080"}). - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(BeAvailable()) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Native Image"))) - - Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) - }) - }) - - context("uses Gradle based Spring Boot app", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join(".", "java-native-image-sample-gradle")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithEnv(map[string]string{ - "BP_NATIVE_IMAGE": "true"}). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.gradle:/home/cnb/.gradle:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - container, err = docker.Container.Run. - WithEnv(map[string]string{"PORT": "8080"}). - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(BeAvailable()) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Gradle"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Native Image"))) - - Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) - }) - }) - - context("app uses simple JAR", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join(".", "public-static-main")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithEnv(map[string]string{"BP_NATIVE_IMAGE": "true"}). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.m2:/home/cnb/.m2:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Native Image"))) - - container, err = docker.Container.Run.Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(func() (fmt.Stringer, error) { - return docker.Container.Logs.Execute(container.ID) - }).Should(ContainLines(ContainSubstring("Hello World!"))) - }) - }) - - context("uses simple Quarkus app", func() { - it("builds successfully", func() { - var err error - source, err = occam.Source(filepath.Join(".", "quarkus-native")) - Expect(err).NotTo(HaveOccurred()) - - var logs fmt.Stringer - image, logs, err = pack.Build. - WithPullPolicy("never"). - WithEnv(map[string]string{ - "BP_NATIVE_IMAGE": "true", - "BP_MAVEN_BUILD_ARGUMENTS": "-Dquarkus.package.type=native-sources -Dmaven.test.skip=true package", - "BP_MAVEN_BUILT_ARTIFACT": "target/native-sources", - "BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE": "native-sources/native-image.args", - "BP_NATIVE_IMAGE_BUILT_ARTIFACT": "native-sources/getting-started-*-runner.jar", - }). - WithBuilder(builder). - WithVolumes(fmt.Sprintf("%s/.m2:/home/cnb/.m2:rw", home)). - WithGID("123"). - Execute(name, source) - Expect(err).ToNot(HaveOccurred(), logs.String) - - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) - Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Native Image"))) - - container, err = docker.Container.Run. - WithEnv(map[string]string{"PORT": "8080"}). - WithPublish("8080"). - Execute(image.ID) - Expect(err).NotTo(HaveOccurred()) - - Eventually(container).Should(BeAvailable()) - - Eventually(container).Should(Serve(ContainSubstring("hello")).OnPort(8080).WithEndpoint("/hello")) - }) - }) - }) - } -} diff --git a/java/native-image/public-static-main/.gitignore b/java/native-image/public-static-main-native-image-maven/.gitignore similarity index 100% rename from java/native-image/public-static-main/.gitignore rename to java/native-image/public-static-main-native-image-maven/.gitignore diff --git a/java/native-image/public-static-main/.mvn/wrapper/MavenWrapperDownloader.java b/java/native-image/public-static-main-native-image-maven/.mvn/wrapper/MavenWrapperDownloader.java similarity index 100% rename from java/native-image/public-static-main/.mvn/wrapper/MavenWrapperDownloader.java rename to java/native-image/public-static-main-native-image-maven/.mvn/wrapper/MavenWrapperDownloader.java diff --git a/java/native-image/java-native-image-sample/.mvn/wrapper/maven-wrapper.jar b/java/native-image/public-static-main-native-image-maven/.mvn/wrapper/maven-wrapper.jar similarity index 100% rename from java/native-image/java-native-image-sample/.mvn/wrapper/maven-wrapper.jar rename to java/native-image/public-static-main-native-image-maven/.mvn/wrapper/maven-wrapper.jar diff --git a/java/native-image/java-native-image-sample/.mvn/wrapper/maven-wrapper.properties b/java/native-image/public-static-main-native-image-maven/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from java/native-image/java-native-image-sample/.mvn/wrapper/maven-wrapper.properties rename to java/native-image/public-static-main-native-image-maven/.mvn/wrapper/maven-wrapper.properties diff --git a/java/native-image/public-static-main/mvnw b/java/native-image/public-static-main-native-image-maven/mvnw similarity index 100% rename from java/native-image/public-static-main/mvnw rename to java/native-image/public-static-main-native-image-maven/mvnw diff --git a/java/native-image/public-static-main/pom.xml b/java/native-image/public-static-main-native-image-maven/pom.xml similarity index 100% rename from java/native-image/public-static-main/pom.xml rename to java/native-image/public-static-main-native-image-maven/pom.xml diff --git a/java/native-image/public-static-main-native-image-maven/smoke_test/java_native_image_public_static_main_test.go b/java/native-image/public-static-main-native-image-maven/smoke_test/java_native_image_public_static_main_test.go new file mode 100644 index 00000000..95af6633 --- /dev/null +++ b/java/native-image/public-static-main-native-image-maven/smoke_test/java_native_image_public_static_main_test.go @@ -0,0 +1,106 @@ +package native_image_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestJNIPublicStaticMain(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("JavaNativeImage - Public Static Main", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Public Static Main with %s builder", builder), testPublicStaticMainWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testPublicStaticMainWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java Native Image app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + Expect(docker.Container.Remove.Execute(container.ID)).To(Succeed()) + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + Expect(docker.Image.Remove.Execute(image.ID)).To(Succeed()) + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses simple JAR", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithEnv(map[string]string{"BP_NATIVE_IMAGE": "true"}). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Native Image"))) + + container, err = docker.Container.Run.Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(func() (fmt.Stringer, error) { + return docker.Container.Logs.Execute(container.ID) + }).Should(ContainLines(ContainSubstring("Hello World!"))) + }) + }) + }) + } +} diff --git a/java/native-image/public-static-main/src/main/java/io/paketo/App.java b/java/native-image/public-static-main-native-image-maven/src/main/java/io/paketo/App.java similarity index 100% rename from java/native-image/public-static-main/src/main/java/io/paketo/App.java rename to java/native-image/public-static-main-native-image-maven/src/main/java/io/paketo/App.java diff --git a/java/native-image/quarkus-native/.gitignore b/java/native-image/quarkus-native-image-maven/.gitignore similarity index 100% rename from java/native-image/quarkus-native/.gitignore rename to java/native-image/quarkus-native-image-maven/.gitignore diff --git a/java/native-image/quarkus-native/.mvn/wrapper/MavenWrapperDownloader.java b/java/native-image/quarkus-native-image-maven/.mvn/wrapper/MavenWrapperDownloader.java similarity index 100% rename from java/native-image/quarkus-native/.mvn/wrapper/MavenWrapperDownloader.java rename to java/native-image/quarkus-native-image-maven/.mvn/wrapper/MavenWrapperDownloader.java diff --git a/java/native-image/quarkus-native/.mvn/wrapper/maven-wrapper.jar b/java/native-image/quarkus-native-image-maven/.mvn/wrapper/maven-wrapper.jar similarity index 100% rename from java/native-image/quarkus-native/.mvn/wrapper/maven-wrapper.jar rename to java/native-image/quarkus-native-image-maven/.mvn/wrapper/maven-wrapper.jar diff --git a/java/native-image/quarkus-native/.mvn/wrapper/maven-wrapper.properties b/java/native-image/quarkus-native-image-maven/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from java/native-image/quarkus-native/.mvn/wrapper/maven-wrapper.properties rename to java/native-image/quarkus-native-image-maven/.mvn/wrapper/maven-wrapper.properties diff --git a/java/native-image/quarkus-native/.s2i/environment b/java/native-image/quarkus-native-image-maven/.s2i/environment similarity index 100% rename from java/native-image/quarkus-native/.s2i/environment rename to java/native-image/quarkus-native-image-maven/.s2i/environment diff --git a/java/native-image/quarkus-native/README.md b/java/native-image/quarkus-native-image-maven/README.md similarity index 100% rename from java/native-image/quarkus-native/README.md rename to java/native-image/quarkus-native-image-maven/README.md diff --git a/java/native-image/quarkus-native/mvnw b/java/native-image/quarkus-native-image-maven/mvnw similarity index 100% rename from java/native-image/quarkus-native/mvnw rename to java/native-image/quarkus-native-image-maven/mvnw diff --git a/java/native-image/quarkus-native/mvnw.cmd b/java/native-image/quarkus-native-image-maven/mvnw.cmd similarity index 100% rename from java/native-image/quarkus-native/mvnw.cmd rename to java/native-image/quarkus-native-image-maven/mvnw.cmd diff --git a/java/native-image/quarkus-native/pom.xml b/java/native-image/quarkus-native-image-maven/pom.xml similarity index 100% rename from java/native-image/quarkus-native/pom.xml rename to java/native-image/quarkus-native-image-maven/pom.xml diff --git a/java/native-image/quarkus-native-image-maven/smoke_test/java_native_image_quarkus_native_test.go b/java/native-image/quarkus-native-image-maven/smoke_test/java_native_image_quarkus_native_test.go new file mode 100644 index 00000000..0e39c893 --- /dev/null +++ b/java/native-image/quarkus-native-image-maven/smoke_test/java_native_image_quarkus_native_test.go @@ -0,0 +1,115 @@ +package native_image_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestJNIQuarkus(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("JavaNativeImage - Quarkus", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Quarkus with %s builder", builder), testQuarkusWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testQuarkusWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java Native Image app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + Expect(docker.Container.Remove.Execute(container.ID)).To(Succeed()) + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + Expect(docker.Image.Remove.Execute(image.ID)).To(Succeed()) + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("uses simple Quarkus app", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithEnv(map[string]string{ + "BP_NATIVE_IMAGE": "true", + "BP_MAVEN_BUILD_ARGUMENTS": "-Dquarkus.package.type=native-sources -Dmaven.test.skip=true package", + "BP_MAVEN_BUILT_ARTIFACT": "target/native-sources", + "BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE": "native-sources/native-image.args", + "BP_NATIVE_IMAGE_BUILT_ARTIFACT": "native-sources/getting-started-*-runner.jar", + }). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Native Image"))) + + container, err = docker.Container.Run. + WithEnv(map[string]string{"PORT": "8080"}). + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(BeAvailable()) + + Eventually(container).Should(Serve(ContainSubstring("hello")).OnPort(8080).WithEndpoint("/hello")) + }) + }) + }) + } +} diff --git a/java/native-image/quarkus-native/src/main/java/org/acme/getting/started/GreetingResource.java b/java/native-image/quarkus-native-image-maven/src/main/java/org/acme/getting/started/GreetingResource.java similarity index 100% rename from java/native-image/quarkus-native/src/main/java/org/acme/getting/started/GreetingResource.java rename to java/native-image/quarkus-native-image-maven/src/main/java/org/acme/getting/started/GreetingResource.java diff --git a/java/native-image/quarkus-native/src/main/java/org/acme/getting/started/GreetingService.java b/java/native-image/quarkus-native-image-maven/src/main/java/org/acme/getting/started/GreetingService.java similarity index 100% rename from java/native-image/quarkus-native/src/main/java/org/acme/getting/started/GreetingService.java rename to java/native-image/quarkus-native-image-maven/src/main/java/org/acme/getting/started/GreetingService.java diff --git a/java/native-image/quarkus-native/src/main/resources/META-INF/resources/index.html b/java/native-image/quarkus-native-image-maven/src/main/resources/META-INF/resources/index.html similarity index 100% rename from java/native-image/quarkus-native/src/main/resources/META-INF/resources/index.html rename to java/native-image/quarkus-native-image-maven/src/main/resources/META-INF/resources/index.html diff --git a/java/native-image/quarkus-native/src/main/resources/application.properties b/java/native-image/quarkus-native-image-maven/src/main/resources/application.properties similarity index 100% rename from java/native-image/quarkus-native/src/main/resources/application.properties rename to java/native-image/quarkus-native-image-maven/src/main/resources/application.properties diff --git a/java/native-image/quarkus-native/src/test/java/org/acme/getting/started/GreetingResourceTest.java b/java/native-image/quarkus-native-image-maven/src/test/java/org/acme/getting/started/GreetingResourceTest.java similarity index 100% rename from java/native-image/quarkus-native/src/test/java/org/acme/getting/started/GreetingResourceTest.java rename to java/native-image/quarkus-native-image-maven/src/test/java/org/acme/getting/started/GreetingResourceTest.java diff --git a/java/native-image/quarkus-native/src/test/java/org/acme/getting/started/NativeGreetingResourceIT.java b/java/native-image/quarkus-native-image-maven/src/test/java/org/acme/getting/started/NativeGreetingResourceIT.java similarity index 100% rename from java/native-image/quarkus-native/src/test/java/org/acme/getting/started/NativeGreetingResourceIT.java rename to java/native-image/quarkus-native-image-maven/src/test/java/org/acme/getting/started/NativeGreetingResourceIT.java diff --git a/java/native-image/java-native-image-sample-gradle/.gitignore b/java/native-image/spring-boot-native-image-gradle/.gitignore similarity index 100% rename from java/native-image/java-native-image-sample-gradle/.gitignore rename to java/native-image/spring-boot-native-image-gradle/.gitignore diff --git a/java/native-image/java-native-image-sample-gradle/README.md b/java/native-image/spring-boot-native-image-gradle/README.md similarity index 100% rename from java/native-image/java-native-image-sample-gradle/README.md rename to java/native-image/spring-boot-native-image-gradle/README.md diff --git a/java/native-image/java-native-image-sample-gradle/build.gradle b/java/native-image/spring-boot-native-image-gradle/build.gradle similarity index 87% rename from java/native-image/java-native-image-sample-gradle/build.gradle rename to java/native-image/spring-boot-native-image-gradle/build.gradle index 2de2ff9b..87c257e1 100644 --- a/java/native-image/java-native-image-sample-gradle/build.gradle +++ b/java/native-image/spring-boot-native-image-gradle/build.gradle @@ -1,8 +1,8 @@ plugins { id 'java' - id 'org.springframework.boot' version '3.0.6' + id 'org.springframework.boot' version '3.0.10' id 'org.graalvm.buildtools.native' version '0.9.21' - id 'io.spring.dependency-management' version '1.1.0' + id 'io.spring.dependency-management' version '1.1.3' } group = 'io.paketo' diff --git a/java/native-image/java-native-image-sample-gradle/gradle/wrapper/gradle-wrapper.jar b/java/native-image/spring-boot-native-image-gradle/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from java/native-image/java-native-image-sample-gradle/gradle/wrapper/gradle-wrapper.jar rename to java/native-image/spring-boot-native-image-gradle/gradle/wrapper/gradle-wrapper.jar diff --git a/java/native-image/java-native-image-sample-gradle/gradle/wrapper/gradle-wrapper.properties b/java/native-image/spring-boot-native-image-gradle/gradle/wrapper/gradle-wrapper.properties similarity index 92% rename from java/native-image/java-native-image-sample-gradle/gradle/wrapper/gradle-wrapper.properties rename to java/native-image/spring-boot-native-image-gradle/gradle/wrapper/gradle-wrapper.properties index f398c33c..4e86b927 100644 --- a/java/native-image/java-native-image-sample-gradle/gradle/wrapper/gradle-wrapper.properties +++ b/java/native-image/spring-boot-native-image-gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/java/native-image/java-native-image-sample-gradle/gradlew b/java/native-image/spring-boot-native-image-gradle/gradlew similarity index 100% rename from java/native-image/java-native-image-sample-gradle/gradlew rename to java/native-image/spring-boot-native-image-gradle/gradlew diff --git a/java/native-image/java-native-image-sample-gradle/gradlew.bat b/java/native-image/spring-boot-native-image-gradle/gradlew.bat similarity index 100% rename from java/native-image/java-native-image-sample-gradle/gradlew.bat rename to java/native-image/spring-boot-native-image-gradle/gradlew.bat diff --git a/java/native-image/java-native-image-sample-gradle/settings.gradle b/java/native-image/spring-boot-native-image-gradle/settings.gradle similarity index 100% rename from java/native-image/java-native-image-sample-gradle/settings.gradle rename to java/native-image/spring-boot-native-image-gradle/settings.gradle diff --git a/java/native-image/spring-boot-native-image-gradle/smoke_test/java_native_image_gradle_test.go b/java/native-image/spring-boot-native-image-gradle/smoke_test/java_native_image_gradle_test.go new file mode 100644 index 00000000..a8989abc --- /dev/null +++ b/java/native-image/spring-boot-native-image-gradle/smoke_test/java_native_image_gradle_test.go @@ -0,0 +1,112 @@ +package native_image_test + +import ( + "flag" + "fmt" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/paketo-buildpacks/samples/tests" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} + +func TestJNIGradle(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("JavaNativeImage - Gradle", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Gradle with %s builder", builder), testGradleWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testGradleWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java Native Image app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + Expect(docker.Container.Remove.Execute(container.ID)).To(Succeed()) + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + Expect(docker.Image.Remove.Execute(image.ID)).To(Succeed()) + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("uses Gradle based Spring Boot app", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithEnv(map[string]string{ + "BP_NATIVE_IMAGE": "true"}). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + container, err = docker.Container.Run. + WithEnv(map[string]string{"PORT": "8080"}). + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(BeAvailable()) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Gradle"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Native Image"))) + + Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) + }) + }) + }) + } +} diff --git a/java/native-image/java-native-image-sample-gradle/src/main/java/io/paketo/demo/DemoApplication.java b/java/native-image/spring-boot-native-image-gradle/src/main/java/io/paketo/demo/DemoApplication.java similarity index 100% rename from java/native-image/java-native-image-sample-gradle/src/main/java/io/paketo/demo/DemoApplication.java rename to java/native-image/spring-boot-native-image-gradle/src/main/java/io/paketo/demo/DemoApplication.java diff --git a/java/native-image/java-native-image-sample-gradle/src/main/resources/application.properties b/java/native-image/spring-boot-native-image-gradle/src/main/resources/application.properties similarity index 100% rename from java/native-image/java-native-image-sample-gradle/src/main/resources/application.properties rename to java/native-image/spring-boot-native-image-gradle/src/main/resources/application.properties diff --git a/java/native-image/java-native-image-sample-gradle/src/test/java/io/paketo/demo/DemoApplicationTests.java b/java/native-image/spring-boot-native-image-gradle/src/test/java/io/paketo/demo/DemoApplicationTests.java similarity index 100% rename from java/native-image/java-native-image-sample-gradle/src/test/java/io/paketo/demo/DemoApplicationTests.java rename to java/native-image/spring-boot-native-image-gradle/src/test/java/io/paketo/demo/DemoApplicationTests.java diff --git a/java/native-image/java-native-image-sample/.gitignore b/java/native-image/spring-boot-native-image-maven/.gitignore similarity index 100% rename from java/native-image/java-native-image-sample/.gitignore rename to java/native-image/spring-boot-native-image-maven/.gitignore diff --git a/java/native-image/java-native-image-sample/.mvn/wrapper/MavenWrapperDownloader.java b/java/native-image/spring-boot-native-image-maven/.mvn/wrapper/MavenWrapperDownloader.java similarity index 100% rename from java/native-image/java-native-image-sample/.mvn/wrapper/MavenWrapperDownloader.java rename to java/native-image/spring-boot-native-image-maven/.mvn/wrapper/MavenWrapperDownloader.java diff --git a/java/native-image/public-static-main/.mvn/wrapper/maven-wrapper.jar b/java/native-image/spring-boot-native-image-maven/.mvn/wrapper/maven-wrapper.jar similarity index 100% rename from java/native-image/public-static-main/.mvn/wrapper/maven-wrapper.jar rename to java/native-image/spring-boot-native-image-maven/.mvn/wrapper/maven-wrapper.jar diff --git a/java/native-image/public-static-main/.mvn/wrapper/maven-wrapper.properties b/java/native-image/spring-boot-native-image-maven/.mvn/wrapper/maven-wrapper.properties similarity index 100% rename from java/native-image/public-static-main/.mvn/wrapper/maven-wrapper.properties rename to java/native-image/spring-boot-native-image-maven/.mvn/wrapper/maven-wrapper.properties diff --git a/java/native-image/java-native-image-sample/README.md b/java/native-image/spring-boot-native-image-maven/README.md similarity index 100% rename from java/native-image/java-native-image-sample/README.md rename to java/native-image/spring-boot-native-image-maven/README.md diff --git a/java/native-image/java-native-image-sample/mvnw b/java/native-image/spring-boot-native-image-maven/mvnw similarity index 100% rename from java/native-image/java-native-image-sample/mvnw rename to java/native-image/spring-boot-native-image-maven/mvnw diff --git a/java/native-image/java-native-image-sample/mvnw.cmd b/java/native-image/spring-boot-native-image-maven/mvnw.cmd similarity index 100% rename from java/native-image/java-native-image-sample/mvnw.cmd rename to java/native-image/spring-boot-native-image-maven/mvnw.cmd diff --git a/java/native-image/java-native-image-sample/pom.xml b/java/native-image/spring-boot-native-image-maven/pom.xml similarity index 100% rename from java/native-image/java-native-image-sample/pom.xml rename to java/native-image/spring-boot-native-image-maven/pom.xml diff --git a/java/native-image/spring-boot-native-image-maven/smoke_test/java_native_image_maven_test.go b/java/native-image/spring-boot-native-image-maven/smoke_test/java_native_image_maven_test.go new file mode 100644 index 00000000..0a8dc732 --- /dev/null +++ b/java/native-image/spring-boot-native-image-maven/smoke_test/java_native_image_maven_test.go @@ -0,0 +1,113 @@ +package native_image_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestJNIMaven(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("JavaNativeImage - Maven", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Maven with %s builder", builder), testMavenWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testMavenWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java Native Image app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + Expect(docker.Container.Remove.Execute(container.ID)).To(Succeed()) + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + Expect(docker.Image.Remove.Execute(image.ID)).To(Succeed()) + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("uses Spring Boot app Maven", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithEnv(map[string]string{ + "BP_NATIVE_IMAGE": "true", + "BP_MAVEN_BUILD_ARGUMENTS": "-Dmaven.test.skip=true --no-transfer-progress -Pnative package", + "BP_JVM_VERSION": "17"}). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + container, err = docker.Container.Run. + WithEnv(map[string]string{"PORT": "8080"}). + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(BeAvailable()) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Native Image"))) + + Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) + }) + }) + }) + } +} diff --git a/java/native-image/java-native-image-sample/src/main/java/io/paketo/demo/DemoApplication.java b/java/native-image/spring-boot-native-image-maven/src/main/java/io/paketo/demo/DemoApplication.java similarity index 100% rename from java/native-image/java-native-image-sample/src/main/java/io/paketo/demo/DemoApplication.java rename to java/native-image/spring-boot-native-image-maven/src/main/java/io/paketo/demo/DemoApplication.java diff --git a/java/native-image/java-native-image-sample/src/main/resources/application.properties b/java/native-image/spring-boot-native-image-maven/src/main/resources/application.properties similarity index 100% rename from java/native-image/java-native-image-sample/src/main/resources/application.properties rename to java/native-image/spring-boot-native-image-maven/src/main/resources/application.properties diff --git a/java/native-image/java-native-image-sample/src/test/java/io/paketo/demo/DemoApplicationTests.java b/java/native-image/spring-boot-native-image-maven/src/test/java/io/paketo/demo/DemoApplicationTests.java similarity index 100% rename from java/native-image/java-native-image-sample/src/test/java/io/paketo/demo/DemoApplicationTests.java rename to java/native-image/spring-boot-native-image-maven/src/test/java/io/paketo/demo/DemoApplicationTests.java diff --git a/java/opentelemetry/build.gradle b/java/opentelemetry/build.gradle index 7fe91914..fea42233 100644 --- a/java/opentelemetry/build.gradle +++ b/java/opentelemetry/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'org.springframework.boot' version '2.7.7' + id 'org.springframework.boot' version '2.7.15' id 'io.spring.dependency-management' version '1.0.15.RELEASE' id 'java' } diff --git a/java/opentelemetry/gradle/wrapper/gradle-wrapper.properties b/java/opentelemetry/gradle/wrapper/gradle-wrapper.properties index f398c33c..4e86b927 100644 --- a/java/opentelemetry/gradle/wrapper/gradle-wrapper.properties +++ b/java/opentelemetry/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/java/opentelemetry/smoke_test/opentelemetry_test.go b/java/opentelemetry/smoke_test/opentelemetry_test.go new file mode 100644 index 00000000..fd01be68 --- /dev/null +++ b/java/opentelemetry/smoke_test/opentelemetry_test.go @@ -0,0 +1,127 @@ +package opentelemetry_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestOpentelemetry(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - Opentelemetry", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("Opentelemetry with %s builder", builder), testOpentelemetryWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testOpentelemetryWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses opentelemetry", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("if-not-present"). + WithEnv(map[string]string{ + "BP_OPENTELEMETRY_ENABLED": "true", + }). + WithBuilder(builder). + WithBuildpacks( + "paketo-buildpacks/java", + "gcr.io/paketo-buildpacks/opentelemetry", + ). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Gradle"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Spring Boot"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for OpenTelemetry"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) + }) + }) + }) + } +} diff --git a/java/tools-build/smoke_test/tools_build_test.go b/java/tools-build/smoke_test/tools_build_test.go new file mode 100644 index 00000000..e79f8086 --- /dev/null +++ b/java/tools-build/smoke_test/tools_build_test.go @@ -0,0 +1,127 @@ +package tools_build_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestToolsBuild(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - ToolsBuild", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("ToolsBuild with %s builder", builder), testToolsBuildWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testToolsBuildWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses clojure tools with tools build", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithEnv(map[string]string{ + "BP_CLJ_TOOLS_BUILD_ENABLED": "true", + "JAVA_TOOL_OPTIONS": "-XX:MaxMetaspaceSize=100M", + }). + WithBuilder(builder). + WithGID("123"). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Clojure Tools"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Executable JAR"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + WithPublishAll(). + WithTTY(). + WithEnv(map[string]string{ + "JAVA_TOOL_OPTIONS": "-XX:MaxMetaspaceSize=100M", + }). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("Hello World!")).OnPort(8080)) + }) + }) + }) + } +} diff --git a/java/war/pom.xml b/java/war/pom.xml index 165ac4c2..3022f1b4 100644 --- a/java/war/pom.xml +++ b/java/war/pom.xml @@ -4,7 +4,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.14 + 2.7.15 io.paketo diff --git a/java/war/smoke_test/war_test.go b/java/war/smoke_test/war_test.go new file mode 100644 index 00000000..509c75e4 --- /dev/null +++ b/java/war/smoke_test/war_test.go @@ -0,0 +1,117 @@ +package war_test + +import ( + "flag" + "fmt" + "github.com/paketo-buildpacks/samples/tests" + "os" + "path/filepath" + "testing" + "time" + + "github.com/paketo-buildpacks/occam" + "github.com/sclevine/spec" + "github.com/sclevine/spec/report" + + . "github.com/onsi/gomega" + . "github.com/paketo-buildpacks/occam/matchers" +) + +var builders tests.BuilderFlags + +func init() { + flag.Var(&builders, "name", "the name a builder to test with") +} +func TestWAR(t *testing.T) { + Expect := NewWithT(t).Expect + + Expect(len(builders)).NotTo(Equal(0)) + + SetDefaultEventuallyTimeout(60 * time.Second) + + suite := spec.New("Java - WAR", spec.Parallel(), spec.Report(report.Terminal{})) + for _, builder := range builders { + suite(fmt.Sprintf("WAR with %s builder", builder), testWARWithBuilder(builder), spec.Sequential()) + } + suite.Run(t) +} + +func testWARWithBuilder(builder string) func(*testing.T, spec.G, spec.S) { + return func(t *testing.T, context spec.G, it spec.S) { + var ( + Expect = NewWithT(t).Expect + Eventually = NewWithT(t).Eventually + + pack occam.Pack + docker occam.Docker + ) + + it.Before(func() { + pack = occam.NewPack().WithVerbose().WithNoColor() + docker = occam.NewDocker() + }) + + context("detects a Java app", func() { + var ( + image occam.Image + container occam.Container + + name string + source string + ) + + it.Before(func() { + var err error + name, err = occam.RandomName() + Expect(err).NotTo(HaveOccurred()) + }) + + it.After(func() { + err := docker.Container.Remove.Execute(container.ID) + if err != nil { + Expect(err).To(MatchError("failed to remove docker container: exit status 1: Container name cannot be empty")) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(docker.Volume.Remove.Execute(occam.CacheVolumeNames(name))).To(Succeed()) + + err = docker.Image.Remove.Execute(image.ID) + if err != nil { + Expect(err).To(MatchError(ContainSubstring("failed to remove docker image: exit status 1: Error"))) + } else { + Expect(err).ToNot(HaveOccurred()) + } + + Expect(os.RemoveAll(source)).To(Succeed()) + }) + + context("app uses war", func() { + it("builds successfully", func() { + var err error + source, err = occam.Source(filepath.Join("../")) + Expect(err).NotTo(HaveOccurred()) + + var logs fmt.Stringer + image, logs, err = pack.Build. + WithPullPolicy("never"). + WithBuilder(builder). + Execute(name, source) + Expect(err).ToNot(HaveOccurred(), logs.String) + + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for CA Certificates"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for BellSoft Liberica"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Maven"))) + Expect(logs).To(ContainLines(ContainSubstring("Paketo Buildpack for Apache Tomcat"))) + + container, err = docker.Container.Run. + WithPublish("8080"). + Execute(image.ID) + Expect(err).NotTo(HaveOccurred()) + + Eventually(container).Should(Serve(ContainSubstring("UP")).OnPort(8080).WithEndpoint("/actuator/health")) + }) + }) + }) + } +}