skip to content

A team applies ivy-publish but the published ivy.xml has no dependencies or the publish task does nothing useful. What are the likely causes?

level: seniorimportance: should knowfreq 12%

answer

  1. empty publication = no from(components.java)
  2. java component needs java/java-library plugin
  3. no ivy {} repo = no remote publish task
  4. inspect build/publications/ivy/ivy.xml
  5. artifact() != dependency metadata

basics

~10 s

Most often the publication has no component attached — from(components["java"]) was omitted — so no artifacts or dependency metadata are included. Also check that a java/java-library plugin exists to provide the component.

solid answer

~40 s

An `IvyPublication` is empty until you give it content. If `from(components["java"])` is missing, the `ivy.xml` has no published artifact and no dependency entries, and the publish task uploads little of value. The `java` software component only exists if a Java plugin (`java`, `java-library`, etc.) is applied, so a missing or misordered plugin is a common root cause. Other culprits: declaring the publication but no `repositories {}` destination (so only the `mavenLocal`/file tasks run), publishing with `artifact(...)` instead of `from(...)` so dependencies are not described, or expecting POM-style metadata. Verify by running `generateDescriptorFileForIvyPublication` and inspecting the generated `ivy.xml` under `build/publications`. Confirm the component, the plugins, and the repository are all present.

code

bash · 2 lines
bash
./gradlew generateDescriptorFileForIvyPublication
cat build/publications/ivy/ivy.xml   # check <dependencies> and <publications>

go deeper

for a junior

Recall that you must add from(components.java) or the publication is empty.

for a middle

Connect the empty descriptor to missing component/plugin and inspect build/publications/ivy.xml.

for a senior

Systematically diagnose component → plugin → repository wiring and explain artifact() vs from() metadata differences.

for a principal

Bake publication-correctness checks (descriptor non-empty, license present) into shared convention plugins and CI verification.

## Symptom The build applies `ivy-publish`, a publication is declared, yet the generated `ivy.xml` lists no dependencies (or no artifacts), or `publish` seems to do nothing. This is almost always a content/wiring problem, not a plugin bug. ## Cause 1 — no component attached A publication is empty by default. Dependency metadata and the main artifact come from a **software component**: ```kotlin create<IvyPublication>("ivyJava") { from(components["java"]) // <-- without this, ivy.xml has no deps/artifact } ``` If you only call `artifact(someJar)` you attach a file but Gradle does not derive dependency declarations from it, so the `<dependencies>` section stays empty. ## Cause 2 — no Java plugin The `components["java"]` component is contributed by the `java`/`java-library` plugin. If no such plugin is applied (or it is applied after you reference the component eagerly), the lookup fails or the component is absent. Apply `java-library` (or `java`) alongside `ivy-publish`. ## Cause 3 — no destination repository If `publishing { repositories { ivy { ... } } }` is missing, only tasks like `publishIvyPublicationToMavenLocal` (or descriptor generation) exist; there is no remote `publish...ToRepository` task, so a plain `publish` may appear to do little. ## Cause 4 — wrong expectations Ivy publishes `ivy.xml`, not `pom.xml`. Inspecting for a POM and finding none is not a bug. ## How to diagnose ```bash ./gradlew generateDescriptorFileForIvyPublication cat build/publications/ivy/ivy.xml ``` Inspect the generated descriptor: a correct one has `<info organisation module revision>`, a `<publications>` section with the artifact, and a `<dependencies>` section reflecting your `api`/`implementation` dependencies. If those are empty, walk back through component → plugins → repository. ## Checklist 1. Is `from(components["java"])` present? 2. Is `java`/`java-library` applied? 3. Is an `ivy { }` repository declared under `publishing`? 4. Are you inspecting `ivy.xml` (not `pom.xml`)?

  • Why does attaching artifacts with artifact(...) not populate the dependencies section?
    `artifact(...)` only attaches a file; dependency metadata is derived from a software component, so you need `from(components["java"])` for Gradle to describe your api/implementation dependencies.
  • Which plugin must be present for components["java"] to exist?
    A Java plugin — `java` or `java-library` — contributes the `java` software component used by the publication.

saying these in an interview costs you the question

  • Blaming the ivy-publish plugin instead of checking that a component was attached.
  • Looking for a pom.xml from an Ivy publication.
  • Assuming `artifact(jar)` alone produces full dependency metadata.

context