Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Gradle tasks with the wrapper in Gradle scaffolding #3983

Open
mcanalesmayo opened this issue Jun 17, 2021 · 0 comments
Open

Run Gradle tasks with the wrapper in Gradle scaffolding #3983

mcanalesmayo opened this issue Jun 17, 2021 · 0 comments

Comments

@mcanalesmayo
Copy link

Currently, the Gradle scaffolding is invoking gradle directly here: https://github.com/habitat-sh/core-plans/blob/master/scaffolding-gradle/lib/scaffolding.sh#L121-L133

scaffolding_build() {
  case "$_app_type" in
    springboot)
      gradle build --project-cache-dir "$GRADLE_USER_HOME" -x test
      ;;
    ratpack)
      gradle installDist --project-cache-dir "$GRADLE_USER_HOME" -x test
      ;;
    gradle)
      gradle stage --project-cache-dir "$GRADLE_USER_HOME"
      ;;
  esac
}

That makes the end user use Gradle taken from the Habitat core/gradle package, which is version v5.6.4 (while the latest stable Gradle version now is 7.1). Therefore and according to the Habitat documentation, if I want to use a different Gradle version I would need to create another package with my preferred version, upload it to the Habitat and override scaffolding_gradle_pkg to reference my package.

However, Gradle documentation recommends using the wrapper to run any task, as it already takes care of invoking the proper Gradle version (taken from the cache or downloaded if it's the first run). Therefore, it would be nice to let Gradle take care of this, so Habitat would not need to maintain and install the Gradle package as build dependency.

Instead of using gradle we could use ./gradlew (it would be a requirement for projects who want to use the Gradle scaffolding to have the Gradle wrapper, which is the most common option nowadays).

Another solution is to always preferably run tasks through the Gradle wrapper (run ./gradlew if gradlew file is present in the project), or otherwise invoke gradle taken from Habitat's core/gradle dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant