How do you customize the Ivy descriptor metadata — author, description, and license — on an IvyPublication?
answer
- descriptor { } = IvyModuleDescriptorSpec
- author { name; url }
- description { text; homepage }
- license { name; url }
- author/license additive; withXml escape hatch
basics
~20 sUse the descriptor { } block inside the publication and call author { name = ... }, description { text = ... }, and license { name = ... } to add metadata that is written into the generated ivy.xml.
solid answer
~40 sThe `IvyPublication` exposes a `descriptor` (an `IvyModuleDescriptorSpec`) for enriching the generated `ivy.xml`. Inside `descriptor { }` you can add one or more `author { name = ...; url = ... }` entries, a `description { text = ...; homepage = ... }`, and one or more `license { name = ...; url = ... }` entries. These nested DSL methods are additive — calling `author { }` twice adds two authors. The values land in the descriptor's extra-info / standard elements so consumers and repository browsers can read provenance and licensing. You can also set `descriptor.status` and add `descriptor.extraInfo(...)` for arbitrary namespaced metadata. This customization is purely metadata; it does not change which artifacts are published.
code
kotlin · 17 linescreate<IvyPublication>("ivyJava") {
from(components["java"])
descriptor {
author {
name = "Jane Doe"
url = "https://example.com/jane"
}
description {
text = "Billing core library"
homepage = "https://example.com/billing"
}
license {
name = "The Apache License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
}go deeper
Know that a descriptor { } block exists and carries author/description/license metadata.
Write the nested DSL correctly, know the additive semantics of author/license, and that it only affects metadata.
Know withXml/extraInfo/status escape hatches and how descriptor metadata feeds repository tooling and compliance scanning.
Mandate license/author metadata as part of a publishing standard and automate it via convention plugins for governance.
## The descriptor block Beyond coordinates, an `IvyPublication` lets you shape the generated `ivy.xml` through its `descriptor` property, an `IvyModuleDescriptorSpec`. You configure it with a `descriptor { ... }` block. The most common customizations are author, description, and license metadata. ## author `author { }` adds an `<author>` entry. It is **additive** — invoke it once per author: ```kotlin descriptor { author { name = "Jane Doe" url = "https://example.com/jane" } author { name = "Build Team" url = "https://example.com/team" } } ``` ## description `description { }` configures a single `<description>` element with a `text` body and an optional `homepage`: ```kotlin descriptor { description { text = "Billing core library" homepage = "https://example.com/billing" } } ``` ## license `license { }` is also additive — add one block per license: ```kotlin descriptor { license { name = "The Apache License, Version 2.0" url = "https://www.apache.org/licenses/LICENSE-2.0.txt" } } ``` ## Other descriptor knobs - `descriptor.status` — sets the Ivy `status` (e.g. `release`). - `descriptor.branch` — sets a branch attribute. - `descriptor.extraInfo(namespace, name, value)` — emit arbitrary namespaced elements. - `descriptor.withXml { ... }` — last-resort direct manipulation of the descriptor XML. ## What it does NOT do Descriptor customization only enriches metadata. It does not add or remove artifacts (use `artifact(...)`/`from(...)` for that) and does not change coordinates (set `organisation`/`module`/`revision` for that). ## Full example ```kotlin create<IvyPublication>("ivyJava") { from(components["java"]) descriptor { author { name = "Jane Doe"; url = "https://example.com" } description { text = "Billing core"; homepage = "https://example.com/billing" } license { name = "Apache-2.0"; url = "https://www.apache.org/licenses/LICENSE-2.0.txt" } } } ```
- How do you declare two authors or two licenses?Call the `author { }` (or `license { }`) block twice inside `descriptor`; both blocks are additive and each call appends another entry to the descriptor.
- What is the escape hatch if the descriptor DSL does not expose a field you need?`descriptor.withXml { ... }` lets you mutate the raw descriptor XML directly, and `descriptor.extraInfo(ns, name, value)` adds namespaced custom elements.
- Does adding a license block change which artifacts are published?No. The descriptor block only enriches metadata in ivy.xml; artifacts are controlled by `from(...)` and `artifact(...)`.
saying these in an interview costs you the question
- Thinking descriptor customization adds artifacts — it only edits metadata.
- Assuming `author`/`license` overwrite the previous one — each call is additive.
- Putting license/author at the publication level instead of inside `descriptor { }`.