forked from wpilibsuite/EclipsePlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maven_commands.gradle
113 lines (92 loc) · 3.39 KB
/
maven_commands.gradle
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import org.gradle.internal.os.OperatingSystem
// This file builds and maintains the list of maven commands
List<String> mavenArgsVersionRun = []
List<String> mavenArgsBuildRun = []
task executeMaven() {
group = 'Build'
description = 'Executes all maven commands that have been added to this session.'
def execList = []
def mvn = getMvn()
doFirst {
if (!mavenArgsVersionRun.empty) {
execList << generateBuildProperties(mavenArgsVersionRun)
} else {
println "No version goals. Skipping version run."
}
if (!mavenArgsBuildRun.empty) {
execList << generateBuildProperties(mavenArgsBuildRun)
} else {
println "No build goals. Skipping build run."
}
}
doLast {
execList.each { argList ->
exec {
executable = mvn
args = argList
}
}
}
}
// Build tasks
task addCleanCommand() {
group = 'Maven Command'
description = 'Adds the clean command to the Maven command list.'
doLast {
mavenArgsBuildRun << 'clean'
}
}
task addPackageCommand() {
group = 'Maven Command'
description = 'Adds the package command to the Maven command list.'
doLast {
mavenArgsBuildRun << 'package'
}
}
// Version tasks
task updateWPILibVersionCommand() {
group = 'Maven Command'
description = 'Adds the version update command to the Maven command list.'
doLast {
// In order to get a correct eclipse version, there can't be too few or too many "."s. There needs to
// be exactly 4. So for official builds, we replace the last "-" with a ".". For local builds, this will
// cause the tycho-version plugin to error, so we don't set it. This is because local builds are prefixed
// with "424242."
def version = WPILibVersion.version
if (project.hasProperty('jenkinsBuild'))
version = version.replaceFirst('-', '.')
mavenArgsVersionRun << 'tycho-versions:set-version' << "-DnewVersion=$version"
}
}
task updateDependencyVersionsCommand() {
group = 'Maven Command'
description = 'Add the dependency version update command to the Maven command list.'
doLast {
mavenArgsVersionRun << 'versions:use-latest-versions'
}
}
// General build properties
def generateBuildProperties(args) {
args << "-Drepo.local=file://${WPILibVersion.mavenLocalUrl}" <<
"-Drepo.remote=${WPILibVersion.mavenRemoteUrl}" <<
'-U'
}
def buildTasks = [addCleanCommand, addPackageCommand, generateNiImageProperties]
def versionTasks = [updateWPILibVersionCommand, updateDependencyVersionsCommand]
// Both executeMaven must run after all the add command tasks have run
buildTasks.each { executeMaven.mustRunAfter it }
versionTasks.each { executeMaven.mustRunAfter it }
// The clean command must come first in the args list, and therefore everything else must run after it
addPackageCommand.mustRunAfter addCleanCommand
updateWPILibVersionCommand.mustRunAfter addCleanCommand
updateDependencyVersionsCommand.mustRunAfter addCleanCommand
// addPackageCommand is the last command to be run
addPackageCommand.mustRunAfter updateWPILibVersionCommand
addPackageCommand.mustRunAfter updateDependencyVersionsCommand
def getMvn() {
if (OperatingSystem.current().isWindows()) {
return 'mvn.cmd'
} else {
return 'mvn'
}
}