Creating files in META-INF folder inside of jar without creating them outside of the jar

I might be trying to do something that isn’t supported…

I’m trying to generate a file that only gets created inside of the jar during the jar task. It would be easy to create the file first somewhere in the build folder, then copy it into the jar. However, I’m really trying to avoid creating it outside of the jar just for the sake of later adding it into the jar contents.

Trying to do something like this (This is a simplified version of the actual build file snippet, just for the sake of conveying the goal. I can’t post the actual build file here.) -->

allprojects {
    apply plugin: 'java'
    jar {
        metaInf {
            into("META-INF/$$") {
                file("myFile.stuff").text = """artifactId=$"""

Is my goal something that gradle supports? If so, can someone point me in the right direction?

Thanks in advance!