forked from wpilibsuite/GradleRIO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversionupdates.gradle
69 lines (58 loc) · 2.48 KB
/
versionupdates.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
def versionMap = [
wpilibVersion: 'edu.wpi.first.wpilibj:wpilibj-java:+',
smartDashboardVersion: 'edu.wpi.first.tools:SmartDashboard:+:win64',
outlineViewerVersion: 'edu.wpi.first.tools:OutlineViewer:+:windowsx86-64@zip',
robotBuilderVersion: 'edu.wpi.first.tools:RobotBuilder:+',
robotBuilderOldVersion: 'edu.wpi.first.tools:RobotBuilder-Old:+',
shuffleboardVersion: 'edu.wpi.first.shuffleboard:shuffleboard:+:win64',
pathWeaverVersion: 'edu.wpi.first.tools:PathWeaver:+:win64',
glassVersion: 'edu.wpi.first.tools:Glass:+:windowsx86-64@zip',
sysIdVersion: 'edu.wpi.first.tools:SysId:+:windowsx86-64@zip',
opencvVersion: 'edu.wpi.first.thirdparty.frc2022.opencv:opencv-java:+',
googleTestVersion: 'edu.wpi.first.thirdparty.frc2022:googletest:+:headers',
niLibrariesVersion: 'edu.wpi.first.ni-libraries:chipobject:+:headers',
imguiVersion: 'edu.wpi.first.thirdparty.frc2022:imgui:+:headers',
wpimathVersion: 'edu.wpi.first.wpimath:wpimath-java:+'
]
configurations {
gradleRioVersions
}
def useDevelopmentProperty = 'useDevelopment'
project.repositories.maven { repo ->
repo.name = "WPI"
if (project.hasProperty(useDevelopmentProperty)) {
repo.url = "https://frcmaven.wpi.edu/artifactory/development"
} else {
repo.url = "https://frcmaven.wpi.edu/artifactory/release"
}
}
dependencies {
versionMap.each { key, value ->
gradleRioVersions value
}
}
String regex = "String\\s+?placeholder\\s+?=\\s+?[\\\"|\\'].+?[\\\"|\\']"
String mavenDevRegex = "this\\.useDevelopment\\s*=\\s*(true|false)"
tasks.register('UpdateVersions') {
doLast {
def mavenExtFile = file('src/main/java/edu/wpi/first/gradlerio/wpi/WPIMavenExtension.java')
def mavenExtText = mavenExtFile.text
def toSet = "this.useDevelopment = false"
if (project.hasProperty(useDevelopmentProperty)) {
toSet = "this.useDevelopment = true"
}
mavenExtFile.text = mavenExtText.replaceAll(mavenDevRegex, toSet)
def extFile = file('src/main/java/edu/wpi/first/gradlerio/wpi/WPIVersionsExtension.java')
def extText = extFile.text
configurations.gradleRioVersions.resolvedConfiguration.resolvedArtifacts.each {
versionMap.each { key, value ->
def id = it.moduleVersion.id
if (value.startsWith("${id.group}:${it.name}:+".toString())) {
def localRegex = regex.replace('placeholder', key)
extText = extText.replaceAll(localRegex, "String ${key} = \"${id.version}\"".toString())
}
}
}
extFile.text = extText
}
}