Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Log stderr of gradle task on configuration issues #80

Merged
merged 1 commit into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ The following example showcases a gradle module in the root, without a module na
| `use-gradlew` | Defines if `./gradlew` or `gradle` cli will be used to retrieve the dependencies. Defaults to 'true' e.g. `./gradlew`.|
| `gradle-project-path` | Defines the path to the gradle project. Defaults to ''. |
| `gradle-build-module` | Defines the module to retrieve the dependencies for. This is often `:app`. Defaults to ''. |
| `gradle-build-configuration` | The configuration for which dependencies are resolved. Defaults to `debugCompileClasspath`. |
| `gradle-build-configuration` | The configuration for which dependencies are resolved. Defaults to `debugCompileClasspath`. Plain java projects usually use `compileClasspath`. |
| `gradle-dependency-path` | Defines the path to the gradle dependency file, relative to the `gradle-project-path`. If not provided, automatically resolved via gradle and the `module` config. |

## Sample 🖥️
Expand Down
13 changes: 13 additions & 0 deletions __tests__/process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ describe('processDependencyList', () => {
expect(dependencies).toEqual(EXPECTED_GRADLE_DEPENDENCY_OUTPUT)
})

test('run in gradle-example with invalid configuration', async () => {
try {
await processDependencyList(
true,
'gradle-example',
':app',
'non-existing'
)
} catch (error: any) {
expect(error.message).toEqual("Failed to execute './gradlew :app:dependencies'")
}
})

test('run in root', async () => {
const dependencies = await processDependencyList(
false,
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inputs:
default: ''
gradle-build-configuration:
required: true
description: 'The configuration used to retrieve all dependencies from.'
description: 'The configuration used to retrieve all dependencies from. Defaults to `debugCompileClasspath` (Android). Java projects usually use `compileClasspath`'
default: 'debugCompileClasspath'
gradle-dependency-path:
required: false
Expand Down
9 changes: 6 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/gradle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ async function fetchGradleVersion(useGradlew: boolean, gradleProjectPath: string
const command = retrieveGradleCLI(useGradlew)
const versionOutput = await exec.getExecOutput(command, ['--version'], {
cwd: gradleProjectPath,
silent: !core.isDebug()
silent: !core.isDebug(),
ignoreReturnCode: true
})
if (versionOutput.exitCode !== 0) {
core.error(versionOutput.stderr)
Expand Down Expand Up @@ -55,7 +56,8 @@ export async function retrieveGradleDependencies(
[`${module}:dependencies`, '--configuration', gradleBuildConfiguration],
{
cwd: gradleProjectPath,
silent: !core.isDebug()
silent: !core.isDebug(),
ignoreReturnCode: true
}
)
if (dependencyList.exitCode !== 0) {
Expand Down Expand Up @@ -113,7 +115,8 @@ async function retrieveGradleProperty(

const propertyOutput = await exec.getExecOutput(command, [`${module}:properties`, '-q', '--property', property], {
cwd: gradleProjectPath,
silent: !core.isDebug()
silent: !core.isDebug(),
ignoreReturnCode: true
})
if (propertyOutput.exitCode !== 0) {
core.error(propertyOutput.stderr)
Expand Down