How to copy a file which resides directly under the project directory and not one it's folders?

I’m sure this is simple. I need to copy the README.md file from my project’s directory.

Exaample:
/Users/MyName/myProjectFolderName
README.md build src target bin build.gradle
src:
main test
bin:
com drivers features sample

My Task currently is set as

task copyReadMe(type: Copy, description: “Copies the readMe file to prepare for archival”){
println "project directory: " + project.projectDir;
from 'project.projectDir.'
into 'build/libs’
include ‘README.md’
}

I tried various things but I’m having no luck trying to copy the README.md when it’s under the project directory. It works if I have it under a folder like src but that’s not where it currently lives.

Thank you for help!

Your from 'project.projectDir.' line isn’t correct. It’s looking for a folder called project.projectDir., not the actual project directory in projectDir.

For this current version to work, it should directly reference the property: from project.projectDir
or double quoted with reference than will be interpolated: from "${project.projectDir}"

However, you don’t even need to specify the directory and an include pattern. You can specify exactly what you want to do, which is just copy from the README.md file to the libs directory:

task copyReadMe(type: Copy, description: 'Copies the readMe file to prepare for archival') {
    from 'README.md'
    into "${buildDir}/libs"
}
1 Like

That’s what I needed. I knew it had to be simple. Thank You very much!