What is "components.java"

I see “components.java” in the maven-publish plugin documentation. That documentation mentions that components.java is added by the Java plugin. However, the Java plugin documentation doesn’t mention anything about components. Actually I can find very little documentation about components. So what exactly is included in components.java? What is it? Why doesn’t the java plugin doc mention anything about it?

This contains the only documentation for components I can find: https://docs.gradle.org/current/userguide/software_model_extend.html#sec:components

Here is an example of its usage from the maven-publication plugin doc:

  publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }

    repositories {
        mavenLocal()
    }
}

set a breakpoint on components.java, we can see that it’s

roughly, it’s something like,

components => project.components => DefaultSoftwareComponentContainer
components.java => components.getByName(“java”) => JavaLibraryDecorated …

1 Like

Came across this definition in docs: https://docs.gradle.org/current/userguide/publishing_overview.html#glossary:component

Any single version of a module.

Components are defined by plugins and provide a simple way to define a publication for publishing. They comprise one or more artifacts as well as the appropriate metadata. For example, the java component consists of the production JAR — produced by the jar task — and its dependency information.