mirror of
https://github.com/gradle/actions.git
synced 2025-11-26 17:09:10 +08:00
Allow a task name to be specified for dependency-submission
Fixes: #125
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
import * as core from '@actions/core'
|
||||
import * as exec from '@actions/exec'
|
||||
import * as path from 'path'
|
||||
|
||||
import * as params from '../input-params'
|
||||
import * as provisioner from './provision'
|
||||
import * as gradlew from './gradlew'
|
||||
import {getWorkspaceDirectory} from '../input-params'
|
||||
|
||||
export async function provisionAndMaybeExecute(args: string[]): Promise<void> {
|
||||
export async function provisionAndMaybeExecute(
|
||||
gradleVersion: string,
|
||||
buildRootDirectory: string,
|
||||
args: string[]
|
||||
): Promise<void> {
|
||||
// Download and install Gradle if required
|
||||
const executable = await provisioner.provisionGradle()
|
||||
const executable = await provisioner.provisionGradle(gradleVersion)
|
||||
|
||||
// Only execute if arguments have been provided
|
||||
if (args.length > 0) {
|
||||
await executeGradleBuild(executable, buildRootDirectory(), args)
|
||||
await executeGradleBuild(executable, buildRootDirectory, args)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,13 +31,3 @@ async function executeGradleBuild(executable: string | undefined, root: string,
|
||||
core.setFailed(`Gradle build failed: see console output for details`)
|
||||
}
|
||||
}
|
||||
|
||||
function buildRootDirectory(): string {
|
||||
const baseDirectory = getWorkspaceDirectory()
|
||||
const buildRootDirectoryInput = params.getBuildRootDirectory()
|
||||
const resolvedBuildRootDirectory =
|
||||
buildRootDirectoryInput === ''
|
||||
? path.resolve(baseDirectory)
|
||||
: path.resolve(baseDirectory, buildRootDirectoryInput)
|
||||
return resolvedBuildRootDirectory
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import * as cache from '@actions/cache'
|
||||
import * as toolCache from '@actions/tool-cache'
|
||||
|
||||
import * as gradlew from './gradlew'
|
||||
import * as params from '../input-params'
|
||||
import {handleCacheFailure} from '../caching/cache-utils'
|
||||
import {CacheConfig} from '../input-params'
|
||||
|
||||
@@ -17,8 +16,7 @@ const gradleVersionsBaseUrl = 'https://services.gradle.org/versions'
|
||||
* Install any configured version of Gradle, adding the executable to the PATH.
|
||||
* @return Installed Gradle executable or undefined if no version configured.
|
||||
*/
|
||||
export async function provisionGradle(): Promise<string | undefined> {
|
||||
const gradleVersion = params.getGradleVersion()
|
||||
export async function provisionGradle(gradleVersion: string): Promise<string | undefined> {
|
||||
if (gradleVersion !== '' && gradleVersion !== 'wrapper') {
|
||||
return addToPath(await installGradle(gradleVersion))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user