For AI agents: the documentation index is at https://docs.gradle.org/llms.txt. Request any page with the header Accept: text/markdown to get Markdown. User manual pages are also available as Markdown by replacing .html with .md in the URL.

setArtifacts

abstract fun setArtifacts(sources: Iterable<out Any>)(source)

Clears any previously added artifacts from getArtifacts and creates artifacts from the specified sources. Each supplied source is interpreted as per artifact. For example, to exclude the dependencies declared by a component and instead use a custom set of artifacts:

plugins {
    id 'java'
    id 'maven-publish'
}

task sourceJar(type: Jar) {
  archiveClassifier = "sources"
}

publishing {
  publications {
    maven(MavenPublication) {
      from components.java
      artifacts = ["my-custom-jar.jar", sourceJar]
    }
  }
}

Since

1.5

Parameters

sources

The set of artifacts for this publication.