-
Notifications
You must be signed in to change notification settings - Fork 205
Expand file tree
/
Copy pathYarnSetupTask.groovy
More file actions
52 lines (43 loc) · 1.24 KB
/
Copy pathYarnSetupTask.groovy
File metadata and controls
52 lines (43 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.moowork.gradle.node.yarn
import com.moowork.gradle.node.npm.NpmSetupTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputDirectory
/**
* Setup a specific version of Yarn to be used by the build.
**/
class YarnSetupTask
extends NpmSetupTask
{
public final static String NAME = 'yarnSetup'
YarnSetupTask()
{
this.group = 'Node'
this.description = 'Setup a specific version of Yarn to be used by the build.'
this.enabled = false;
}
@Input
Set<String> getInput()
{
def set = new HashSet<>()
set.add( this.getConfig().download )
set.add( this.getConfig().yarnVersion )
set.add( this.getConfig().npmRegistry )
return set
}
@OutputDirectory
File getYarnDir()
{
return this.getVariant().yarnDir
}
void configureVersion( String yarnVersion )
{
def pkg = "yarn"
if ( !yarnVersion.isEmpty() )
{
logger.debug( "Setting yarnVersion to ${yarnVersion}" )
pkg += "@${yarnVersion}"
}
this.setArgs( ['install', '--global', '--no-save', '--registry', getVariant().npmRegistry, '--prefix', this.getVariant().yarnDir, pkg] )
enabled = true
}
}