task syncDependencies(type: Sync) {
description 'Copies the assets directory from external netbeans project to the target directory.'
from '../PathToSDKProject/assets'
exclude ('**/*.j3odata','**/*.mesh','**/*.skeleton','**/*.mesh.xml','**/*.skeleton.xml','**/*.scene','**/*.material','**/*.obj','**/*.mtl','**/*.3ds','**/*.dae','**/*.blend','**/*.blend*[0-9]','**/*.bin','**/*.gltf')
into 'assets'
}
Well discovered some more quirkiness using gradle. Being new to me probably not to others but when syncing folders i found out that you can always create a sub directory, and add files to it in the βfromβ directory and it will propagate the βintoβ directory.
However, at least for me, if i were to delete those files and or the sub directory, or move that directory, the βfromβ directory now has an empty folder where once there was none. The sync, at least for me, would not update the βintoβ directory now because it found an empty folder in the βfromβ directory and ignores it. This means my βintoβ directory was now out of sync with the βfromβ directory.
I created a chain of task calls to fix it using Pauls default gradle templates createDirs task so now I always have a matching synced folder when I want one.
The first task is still the syncDependencies task but now set to dependOn Pauls default template createDirs task which is set to dependOn a delete task.
task syncDependencies(type: Sync) {
dependsOn.createDirs
description 'Copies the assets directory from external netbeans project to the target directory.'
from '../PolyAssets/assets'
exclude ('**/*.j3odata','**/*.mesh','**/*.skeleton','**/*.mesh.xml','**/*.skeleton.xml','**/*.scene','**/*.material','**/*.obj','**/*.mtl','**/*.3ds','**/*.dae','**/*.blend','**/*.blend*[0-9]','**/*.bin','**/*.gltf')
into 'assets'
}
I left the createDirs task intact but it could be cleaned up to remove unneeded things like creating stubs.
task (createDirs).doLast {
dependsOn makePretty
def pkg = 'mygame'
def dirs = [
// file("./src/main/java/$pkg"),
// file("./src/main/resources"),
file("./assets/Interface"),
file("./assets/MatDefs"),
file("./assets/Materials"),
file("./assets/Models"),
file("./assets/Scenes"),
file("./assets/Shaders"),
file("./assets/Sounds"),
file("./assets/Textures"),
]
dirs.each {
if( !it.exists() ) {
println "Creating " + it
it.mkdirs()
}
if( it.listFiles().length == 0 ) {
def stub = new File(it, 'removeme.txt')
println "Creating stub file to allow git checkin, file:$stub"
stub.text = "Remove me when there are files here."
}
}
}
The makePretty task.
task makePretty(type: Delete) {
description 'Deletes all files in the target directory without deleting the target directory.'
delete file('assets').listFiles()
}
This works real well and I can move things around in the βfromβ folder, add to or remove them, leave empty directories anywhere I want and its real fast.
If there are better ways to do this please advise.
Edit: Never mind. Failed again for some reason once all the folders were empty.
That loud smacking sound you hear is me punching the shit out of gradle.