This repository was archived by the owner on Feb 19, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
148 lines (123 loc) · 3.88 KB
/
Copy pathbuild.gradle
File metadata and controls
148 lines (123 loc) · 3.88 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'commons-io:commons-io:2.5'
}
}
plugins {
id 'org.ajoberstar.grgit' version '1.5.1'
id 'de.undercouch.download' version '3.1.1'
}
import java.nio.file.Paths;
import org.apache.commons.io.FileUtils;
task locateArma3 << {
def registryPaths = [
'REG QUERY "HKLM\\SOFTWARE\\Wow6432Node\\Bohemia Interactive Studio\\ArmA 3" /v "MAIN"',
'REG QUERY "HKLM\\SOFTWARE\\Bohemia Interactive Studio\\ArmA 3" /v "MAIN"',
'REG QUERY "HKLM\\SOFTWARE\\Wow6432Node\\Bohemia Interactive\\ArmA 3" /v "MAIN"',
'REG QUERY "HKLM\\SOFTWARE\\Bohemia Interactive\\ArmA 3" /v "MAIN"',
]
def found = false;
def registryDivider = " "
registryPaths.each { String query ->
Process process = Runtime.getRuntime().exec(query);
InputStream is = process.getInputStream();
StringBuilder sw = new StringBuilder();
try
{
int c;
while ((c = is.read()) != -1) {
sw.append((char)c);
}
}
catch (IOException e)
{
}
String output = sw.toString();
if(!output.contains(registryDivider)) {
return null;
}
// Parse out the value
String[] parsed = output.split(registryDivider);
project.ext.arma3dir = parsed[parsed.length-1].trim();
found = true
}
if (!found) {
throw new GradleException("Arma 3 directory could not be found")
}
}
subprojects {
project.ext.autotestFile = 'autotest.cfg'
task cloneIslandTestMission << {
def missionRepo = 'https://github.com/SwedishForcesPack/sfp_island_auto_test.VR.git'
delete file(missionDir).getAbsolutePath()
def grgit = org.ajoberstar.grgit.Grgit.clone(dir: file(missionDir).getAbsolutePath(), uri: missionRepo)
}
task cloneObjectDumperTestMission << {
def missionRepo = 'https://github.com/SwedishForcesPack/mrg_objectDumper.VR.git'
delete file(missionDir).getAbsolutePath()
def grgit = org.ajoberstar.grgit.Grgit.clone(dir: file(missionDir).getAbsolutePath(), uri: missionRepo)
}
task generateAutotestFile << {
String missionPath = file(missionDir).getAbsolutePath()
String fileContent = """
class TestMissions
{
class TestCase01
{
campaign = \"\";
mission = \"${missionPath}\";
};
};
""".stripIndent()
new File(autotestFile).write(fileContent)
}
task downloadMods() {
outputs.upToDateWhen { false }
doLast {
def args = ["SteamWorkshop.exe", "--priority", "107410"] + mods
def process = new ProcessBuilder(args).inheritIO().start()
process.waitFor()
if (process.exitValue() > 0) {
throw new GradleException("Steam Workshop download failed")
}
}
}
task runAutotest {
ext {
getModPath = { mod ->
return Paths.get(arma3dir, "..", "..", "workshop", "content", "107410", mod).normalize()
}
}
doLast {
String armaExecutable = "${arma3dir}/arma3.exe"
String autotestFilePath = new File(autotestFile).getAbsolutePath()
String autotest = "-autotest=${autotestFilePath}"
String mods = "-mod=${mods.collect(getModPath).join(';')}"
def pb = new ProcessBuilder([
armaExecutable,
autotest,
mods,
"-world=empty",
"-noPause",
"-noSplash",
"-window",
]).start().waitFor()
}
}
runAutotest.dependsOn(generateAutotestFile)
runAutotest.dependsOn(locateArma3)
runAutotest.mustRunAfter(downloadMods)
task moveLogFile << {
def logsDir = file('logs')
def localAppData = System.getenv('LOCALAPPDATA')
def logFiles = file("${localAppData}/Arma 3").listFiles().findAll { it.name.startsWith('arma3_') && it.name.endsWith('.rpt') }
File source = logFiles.sort().last()
File destination = file(Paths.get(logsDir.getAbsolutePath(), "${mod}.rpt").toString())
delete logsDir
mkdir logsDir
FileUtils.moveFile(source, destination)
}
}