diff --git a/docs/sources/gradle.md b/docs/sources/gradle.md index 70024283..3f68d2d6 100644 --- a/docs/sources/gradle.md +++ b/docs/sources/gradle.md @@ -21,4 +21,13 @@ To run `licensed` for specific projects in a [multi-build project](https://docs. ```yml apps: - source_path: ./path/to/subproject +``` + +### Gradlew + +The `gradle.gradlew` property is used to determine where the `gradlew` executable is. The default location the [configuration root](../configuration/configuration_root.md). + +```yml +gradle: + - gradlew: path/from/root/to/gradle/gradlew ``` \ No newline at end of file diff --git a/lib/licensed/sources/gradle.rb b/lib/licensed/sources/gradle.rb index fcb40a9f..63ee152a 100644 --- a/lib/licensed/sources/gradle.rb +++ b/lib/licensed/sources/gradle.rb @@ -66,7 +66,6 @@ def executable return @executable if defined?(@executable) @executable = begin - gradlew = File.join(config.pwd, "gradlew") return gradlew if File.executable?(gradlew) "gradle" if Licensed::Shell.tool_available?("gradle") @@ -89,6 +88,14 @@ def configurations end end + # Returns the path to the Gradle wrapper. + def gradlew + @gradlew ||= begin + gradlew = config.dig("gradle", "gradlew") + config.root.join(gradlew || "gradlew").to_s + end + end + # Returns a key to uniquely identify a name and version in the obtained CSV content def csv_key(name:, version:) "#{name}-#{version}"