I want to copy the src and gradle folders, including their contents, from the project’s home directory.
Example:
ProjectFolder/
src/ gradle/
src/
main/ test/
gradle/
wrapper/
I came up with one solution but I have to list everything I don’t want which I don’t think is a great solution.
Include doesn’t work
task copySource(type: Copy, description: "Copies files to prepare for archival"){
from ("${projectDir}/"){
exclude 'build', 'bin'
}
into "${buildDir}/libs/"
}
This option works well too but only with one directory
task copySource(type: Copy, description: "Copies files to prepare for archival"){
from ('src')
from ("${buildDir}/libs") {
include 'main/*', 'test/*'
}
into "${buildDir}/libs/src"
}
I ended up creating separate tasks to accomplish what I need but is there a way to do this all in one task?
task copySource(dependsOn:'fatJar',type: Copy, description: "Copies files to prepare for archival"){
from ('src')
into "${buildDir}/libs/src"
}
task copyReadme(dependsOn:'copySource', type: Copy, description: "Copies files to prepare for archival"){
from ('README.md)
into "${buildDir}/libs/
}
task copyGradle(dependsOn:'copyReadme', type: Copy, description: "Copies files to prepare for archival"){
from ('gradle')
into "${buildDir}/libs/gradle"
}