copy task now functions a lot better
@@ -153,36 +153,21 @@ task setGameDir() {
}
task copyJar(type: DefaultTask, dependsOn: [setGameDir]) {
- doLast {
- final dir = "${project.ext.gameDir}/mods"
- final files = { directory, keyword ->
- project.fileTree(dir: directory).matching {
- include keyword
- }.files
+ final files = { directory, filter, closure ->
+ new File(directory).eachFileMatch(filter, closure)
}
+ doLast {
+ final mods = "${project.ext.gameDir}/mods"
+
+ project.copy {
// delete previous ForgeHax jars
- files(dir, "${project.archivesBaseName}*.jar").each { file ->
+ files(mods, ~/ForgeHax-.*\.jar/) { file ->
file.delete()
}
- // get the mod folder dir
-
- //noinspection UnnecessaryQualifiedReference
- final folder = java.nio.file.Paths.get(dir.toString())
- //noinspection UnnecessaryQualifiedReference
- if (java.nio.file.Files.exists(folder)) {
- // get all the build artifacts
-
- files('build/libs', "*.jar").each { file ->
- // copy the jar
- // why use this instead of a Copy task? because a Copy task will delete the
- // jar when gradle clean is ran
-
- final artifact = file.toPath()
- //noinspection UnnecessaryQualifiedReference
- java.nio.file.Files.copy(artifact, folder.resolve(file.getName()))
- }
+ from project.jar
+ into mods
}
}
}
