Skip to content
This repository has been archived by the owner on May 8, 2020. It is now read-only.

Commit

Permalink
Support build.gradle.kts
Browse files Browse the repository at this point in the history
Previously, determination of a Gradle repository was dependent on the
existence of a build.gradle file.  With the adoption of Kotlin in the Gradle
community, it now needs to inlcude build.gradle.kts.  This change updates the
buildpack to look for that file as well.

[resolves #3]

Signed-off-by: Ben Hale <bhale@pivotal.io>
  • Loading branch information
nebhale committed Dec 12, 2018
1 parent 3241abf commit 32f4c8b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This buildpack is designed to work in collaboration with other buildpacks.
## Detection
The detection phase passes if

* `<APPLICATION_ROOT>/build.gradle` exists
* `<APPLICATION_ROOT>/build.gradle` or `<APPLICATION_ROOT>/build.gradle.kts` exists
* Contributes `gradle` to the build plan
* Contributes `jvm-application` to the build plan
* Contributes `openjdk-jdk` to the build plan
Expand Down
9 changes: 7 additions & 2 deletions buildsystem/gradle.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,17 @@ func GradleBuildPlanContribution() buildplan.BuildPlan {

// IsGradle returns whether this application is built using Gradle.
func IsGradle(application application.Application) bool {
exists, err := helper.FileExists(filepath.Join(application.Root, "build.gradle"))
e1, err := helper.FileExists(filepath.Join(application.Root, "build.gradle"))
if err != nil {
return false
}

return exists
e2, err := helper.FileExists(filepath.Join(application.Root, "build.gradle.kts"))
if err != nil {
return false
}

return e1 || e2
}

// NewGradleBuildSystem creates a new Gradle BuildSystem instance. OK is true if build plan contains "gradle"
Expand Down
6 changes: 6 additions & 0 deletions buildsystem/gradle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ func TestGradle(t *testing.T) {

g.Expect(buildsystem.IsGradle(f.Build.Application)).To(BeTrue())
})

it("returns true if build.gradle.kts does exist", func() {
test.TouchFile(t, f.Build.Application.Root, "build.gradle.kts")

g.Expect(buildsystem.IsGradle(f.Build.Application)).To(BeTrue())
})
})

when("NewGradleBuildSystem", func() {
Expand Down
6 changes: 6 additions & 0 deletions detect/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func TestDetect(t *testing.T) {
g.Expect(d(f.Detect)).To(Equal(detect.PassStatusCode))
})

it("passes with build.gradle.kts", func() {
test.TouchFile(t, f.Detect.Application.Root, "build.gradle.kts")

g.Expect(d(f.Detect)).To(Equal(detect.PassStatusCode))
})

it("passes with pom.xml", func() {
test.TouchFile(t, f.Detect.Application.Root, "pom.xml")

Expand Down

0 comments on commit 32f4c8b

Please sign in to comment.