Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Defining an additional artifact

Friedger Müffke edited this page Jun 29, 2015 · 1 revision

Similar to defining a customer artifact you can define an additional artifact that will be published together with the standard artifacts.

import com.novoda.gradle.release.*

def fooJarPublish(String publicationName, Project project) {
    project.task(publicationName + 'FooJar', type: Jar) {
        classifier = 'foo'
        from sourceSets.main.output
    }
}

publish {
    ...
    dryRun = true

    publishing {
        publications {
            fooPublication(MavenPublication) {
                groupId project.publish.groupId
                artifactId project.publish.artifactId
                publishVersion project.publish.publishVersion

                Artifacts artifacts = new JavaArtifacts()
                (artifacts.all(it.name, project) + fooJarPublish(it.name, project)).each {
                    delegate.artifact it
                }
                from artifacts.from(project)
            }
        }
    }

    publications = ['fooPublication']
}