plugins {
    id 'java'
}

// tag::archive-artifact[]
task myJar(type: Jar)

artifacts {
    archives myJar
}
// end::archive-artifact[]

// tag::file-artifact[]
def someFile = file("$buildDir/somefile.txt")

artifacts {
    archives someFile
}
// end::file-artifact[]

// tag::customized-file-artifact[]
task myTask(type:  MyTaskType) {
    destFile = file("$buildDir/somefile.txt")
}

artifacts {
    archives(myTask.destFile) {
        name 'my-artifact'
        type 'text'
        builtBy myTask
    }
}
// end::customized-file-artifact[]

// tag::map-file-artifact[]
task generate(type:  MyTaskType) {
    destFile = file("$buildDir/somefile.txt")
}

artifacts {
    archives file: generate.destFile, name: 'my-artifact', type: 'text', builtBy: generate
}
// end::map-file-artifact[]

class MyTaskType extends DefaultTask {
    File destFile
}

// tag::uploading[]
repositories {
    flatDir {
        name "fileRepo"
        dirs "repo"
    }
}

uploadArchives {
    repositories {
        add project.repositories.fileRepo
        ivy {
            credentials {
                username "username"
                password "pw"
            }
            url "http://repo.mycompany.com"
        }
    }
}
// end::uploading[]
