Fix running gradle and gradle source tests when gradle is unavailable #606
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #605
The gradle source's
enabled?
check creates aGradle::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.Licensed::Sources::Gradle.enabled?
calledgradle_runner.enabled?
to check whether a gradle executable is availableLicensed::Sources::Gradle.gradle_runner
creates aLicensed::Sources::Gradle::Runner
objectLicensed::Sources::Gradle::Runner#initialize
callsLicensed::Sources::Gradle::Runner#create_init_script
which creates an initialization script that is used when calling into licensedLicensed::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 availableI 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.