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

Fix running gradle and gradle source tests when gradle is unavailable #606

Merged
merged 2 commits into from
Jan 6, 2023

Conversation

jonabc
Copy link
Contributor

@jonabc jonabc commented Jan 6, 2023

closes #605

The gradle source's enabled? check creates a Gradle::Runner object to determine if a gradle executable is available. This can cause an order of operations where the source tries to use the executable before its existence has been check.

  1. Licensed::Sources::Gradle.enabled? called gradle_runner.enabled? to check whether a gradle executable is available
  2. Licensed::Sources::Gradle.gradle_runner creates a Licensed::Sources::Gradle::Runner object
  3. Licensed::Sources::Gradle::Runner#initialize calls Licensed::Sources::Gradle::Runner#create_init_script which creates an initialization script that is used when calling into licensed
  4. creating the initialization script calls Licensed::Sources::Gradle::Runner.gradle_version, which tries to use a gradle executable. this is where the error is thrown, because the gradle executable isn't available

I fixed this by moving the runner's enabled and executable location logic into the source enumerator class so that it could be used without needing to create the init script. There are other ways to fix this but this was quick and I think it makes sense for the source to be responsible for determining whether a gradle executable exists and providing its path, if it exists, to the runner.

I also wrapped the tests in a check that enforces that gradle is available when running the tests because a gradle executable is no longer shipped in licensed's test fixtures.

jonabc added 2 commits January 6, 2023 08:52
creating the gradle runner tries to check the gradle version,
which may not exist
@jonabc jonabc merged commit ef60311 into master Jan 6, 2023
@jonabc jonabc deleted the fix-gradle-source-when-gradle-unavailable branch January 6, 2023 16:38
jonabc added a commit that referenced this pull request Jan 6, 2023
## 4.0.1

### Fixed

- Running gradle tests will no longer fail when gradle is not available (#606)
@jonabc jonabc mentioned this pull request Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

licensed v4.0.0 test failure in Homebrew
1 participant