blob: 9b4f8db3cdcde76e56eabac4193801b9a6015802 (
plain)
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
|
import java.nio.file.FileVisitResult
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.SimpleFileVisitor
import java.nio.file.StandardCopyOption
import java.nio.file.attribute.BasicFileAttributes
apply plugin: 'java'
apply plugin: 'idea'
jar {
if (project.hasProperty('installerJarName')) {
archiveName = installerJarName
}
manifest {
attributes("Main-Class": "com.github.dcevm.installer.Main")
}
}
project.ext {
processedData = Paths.get("$buildDir/data")
// Should be populated by build server from the DCEVM upstream job
dataSource = Paths.get("$buildDir/rawdata")
}
sourceSets {
main {
output.dir(processedData.toFile(), builtBy: 'copyData')
}
}
task copyData {
onlyIf { Files.exists(dataSource) }
doLast {
Files.createDirectories(processedData)
Files.walkFileTree(dataSource, new CopyDataVisitor(project));
}
}
class CopyDataVisitor extends SimpleFileVisitor<Path> {
def project
CopyDataVisitor(prj) {
project = prj
}
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
Path rel = project.dataSource.relativize(dir)
if (rel.nameCount > 4) {
rel = rel.subpath(4, rel.nameCount);
if (rel.fileName.toString() == 'fastdebug') {
// Do not copy fastdebug versions
return FileVisitResult.SKIP_SUBTREE;
}
def targetPath = project.processedData.resolve(rel);
if(!Files.exists(targetPath)){
Files.createDirectory(targetPath);
}
}
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Path rel = project.dataSource.relativize(file)
if (rel.nameCount > 4) {
rel = rel.subpath(4, rel.nameCount);
def targetPath = project.processedData.resolve(rel);
Files.copy(file, targetPath, StandardCopyOption.REPLACE_EXISTING);
}
return FileVisitResult.CONTINUE;
}
}
|