Skip to content

Commit

Permalink
Ensure the user-provided mvnw wrapper script is executable (#133)
Browse files Browse the repository at this point in the history
If a developer has accidentally changed the permissions on their `mvnw` executable they should be able to deploy.

GUS-W-9689448

Previously if the `mvnw` file was not executable this would error:


```
       [Installing Java]
       JDK 1.8 installed
       JRE 1.8 installed

       [Installing Maven]
       [INFO] Maven wrapper detected, skipping installation.

       [Executing Maven]
       [INFO] $ ./mvnw -DskipTests clean install


       ERROR: failed to build: exit status 1

       stderr: /cnb/buildpacks/heroku_maven/0.2.5/bin/build: line 188: ./mvnw: Permission denied
       [ERROR: Failed to build app with Maven]
       We're sorry this build is failing! If you can't find the issue in application code,
       please submit a ticket so we can help: https://help.heroku.com/
       ERROR: failed to build: executing lifecycle: failed with status code: 145
```

Co-authored-by: Ed Morley <[email protected]>
  • Loading branch information
schneems and edmorley authored Aug 10, 2021
1 parent 05293c3 commit fc8aab5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion buildpacks/maven/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
* Ensures `mvnw` is executable

## [0.2.4] 2021/07/16
### Added
* Loosen stack requiremets allowing any linux distro use this buildpacak
* Loosen stack requiremets allowing any linux distro use this buildpack

## [0.2.3] 2021/05/05
### Added
Expand Down
1 change: 1 addition & 0 deletions buildpacks/maven/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ fi
maven_executable="mvn"
if maven::should_use_wrapper_for_app "${app_dir}"; then
maven_executable="./mvnw"
chmod +x "${maven_executable}"
fi

maven_options=()
Expand Down
11 changes: 11 additions & 0 deletions test/specs/maven/misc_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
require_relative "spec_helper"

describe "Heroku's Maven Cloud Native Buildpack" do
it "will ensure mvn is executable regardless of file permissions" do
Cutlass::App.new("simple-http-service").transaction do |app|
FileUtils.chmod(0444, app.tmpdir.join("mvnw")) # Set executable to read only on purpose

app.pack_build do |pack_result|
expect(pack_result.stdout).to include("Successfully built image")
expect(pack_result.success?).to be_truthy
end
end
end

it "will write ${APP_DIR}/target/mvn-dependency-list.log with the app's dependencies" do
Cutlass::App.new("simple-http-service", config: {MAVEN_CUSTOM_GOALS: "clean"}).transaction do |app|
app.pack_build do |pack_result|
Expand Down

0 comments on commit fc8aab5

Please sign in to comment.