You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build.gradle 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import java.nio.file.FileVisitResult
  2. import java.nio.file.Files
  3. import java.nio.file.Path
  4. import java.nio.file.Paths
  5. import java.nio.file.SimpleFileVisitor
  6. import java.nio.file.StandardCopyOption
  7. import java.nio.file.attribute.BasicFileAttributes
  8. apply plugin: 'java'
  9. apply plugin: 'idea'
  10. jar {
  11. manifest {
  12. attributes("Main-Class": "com.github.dcevm.installer.Main")
  13. }
  14. }
  15. project.ext {
  16. processedData = Paths.get("$buildDir/data")
  17. // Should be populated by build server from the DCEVM upstream job
  18. dataSource = Paths.get("$buildDir/rawdata")
  19. }
  20. sourceSets {
  21. main {
  22. output.dir(processedData.toFile(), builtBy: 'copyData')
  23. }
  24. }
  25. task copyData {
  26. onlyIf { Files.exists(dataSource) }
  27. doLast {
  28. Files.createDirectories(processedData)
  29. Files.walkFileTree(dataSource, new CopyDataVisitor(project));
  30. }
  31. }
  32. class CopyDataVisitor extends SimpleFileVisitor<Path> {
  33. def project
  34. CopyDataVisitor(prj) {
  35. project = prj
  36. }
  37. @Override
  38. public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
  39. Path rel = project.dataSource.relativize(dir)
  40. if (rel.nameCount > 4) {
  41. rel = rel.subpath(4, rel.nameCount);
  42. if (rel.fileName.toString() == 'fastdebug') {
  43. // Do not copy fastdebug versions
  44. return FileVisitResult.SKIP_SUBTREE;
  45. }
  46. def targetPath = project.processedData.resolve(rel);
  47. if(!Files.exists(targetPath)){
  48. Files.createDirectory(targetPath);
  49. }
  50. }
  51. return FileVisitResult.CONTINUE;
  52. }
  53. @Override
  54. public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
  55. Path rel = project.dataSource.relativize(file)
  56. if (rel.nameCount > 4) {
  57. rel = rel.subpath(4, rel.nameCount);
  58. def targetPath = project.processedData.resolve(rel);
  59. Files.copy(file, targetPath, StandardCopyOption.REPLACE_EXISTING);
  60. }
  61. return FileVisitResult.CONTINUE;
  62. }
  63. }