Search code examples
javamaven

What is the meaning of "auto" label next to a file name after running maven dependency : list?


Here is the example of the response I get when I run the command: mvn dependency:list

[INFO] The following files have been resolved:     
                                                                  
[INFO]    org.springframework.boot:spring-boot-starter-web:jar:3.1.6:compile -- module spring.boot.starter.web [auto]

[INFO]    org.springframework.boot:spring-boot-starter:jar:3.1.6:compile -- module spring.boot.starter [auto]  
      
[INFO]    org.springframework.boot:spring-boot:jar:3.1.6:compile -- module spring.boot [auto]                        

[INFO]    ch.qos.logback:logback-classic:jar:1.4.11:compile -- module ch.qos.logback.classic

Here is part of my pom file:

 <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.1.6</version>
        <relativePath/>
    </parent>

    <properties>
        <java.version>17</java.version>
        <camunda.version>7.20.0</camunda.version>
        <immutables.version>2.7.3</immutables.version>
        <db2.db2jcc4.driver.version>4.0.0</db2.db2jcc4.driver.version>
        <db2.db2jcc4.license.version>1.0.6</db2.db2jcc4.license.version>
        <snakeyaml.version>2.1</snakeyaml.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>2022.0.4</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

Dependency "spring-boot-starter-web" is explicitly provided by me in the pom file. Nevertheless, the maven labelled it as auto. The question is what that "auto" here denotes.


Solution

  • The output of the maven-dependency-plugin:list will show you information about being a Java Module or not ([auto], (auto) and nothing.).

    Let us check some particular examples to understand the output and what it exactly means:

    ch.qos.logback:logback-core:jar:1.4.11:compile -- module ch.qos.logback.core
    

    This output means the groupId:artifactId:type:version:scope describes a package or more accurate a module which has the module name: ch.qos.logback.core. That means in other words this is a real Java Module (containing a module-info.class in the root of the the jar file).

    org.springframework:spring-core:jar:6.0.14:compile -- module spring.core [auto]
    

    This means that the artifact spring-core (with version etc.) has defined an Automatic-Module-Name: spring.core (within the MANIFEST.MF file) but based on the output it means it does not not contain a module-info.class file inside the jar file.

    org.atteo:evo-inflector:jar:1.3:compile -- module evo.inflector (auto)
    

    This means that the artifact evo-inflector has not defined an Automatic-Module-Name: .. in the MANIFEST.MF file nor does it contain a module-info.class within the jar file. This module name is automatically generated. from the artifact name which could result in illegal module names (see the rules https://dev.java/learn/modules/automatic-module/).

    If you like to know the dependency tree use the tree goal instead of the maven-dependency-plugin.