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

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