javamaven

how maven dependency, transitive dependency work?


in artifact docx4j-JAXB-ReferenceImpl https://repo1.maven.org/maven2/org/docx4j/docx4j-JAXB-ReferenceImpl/11.5.3/docx4j-JAXB-ReferenceImpl-11.5.3.pom
it declare docx4j-core as its dependency

<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-core</artifactId>
<version>11.5.3</version>
<scope>compile</scope>
</dependency>

but is this the whole docx4j-core, mean is this equals exactly to

<!-- https://mvnrepository.com/artifact/org.docx4j/docx4j-core -->
<dependency>
    <groupId>org.docx4j</groupId>
    <artifactId>docx4j-core</artifactId>
    <version>11.5.3</version>
</dependency>

or just a partial of docx4j-core, which docx4j-JAXB-ReferenceImpl will call?

  1. in https://mvnrepository.com/artifact/org.docx4j/docx4j-core/11.5.3, it declare
    <dependency>
        <groupId>org.docx4j</groupId>
        <artifactId>docx4j-openxml-objects</artifactId>
        <version>11.5.3</version>
        <scope>compile</scope>
    </dependency>

as its dependency, that if in my pom.xml, I just add

<!-- https://mvnrepository.com/artifact/org.docx4j/docx4j-JAXB-ReferenceImpl -->
<dependency>
    <groupId>org.docx4j</groupId>
    <artifactId>docx4j-JAXB-ReferenceImpl</artifactId>
    <version>11.5.3</version>
</dependency>

will my project also download docx4j-openxml-objects through downloading docx4j-core?

  1. if not, but docx4j-core need docx4j-openxml-objects to compile, then how docx4j-JAXB-ReferenceImpl work?

Solution

  • Ad 1.: This is the very same artifact since artifacts are identified by groupId, artifactId, version (GAV, for short). See POM ReferenceMaven Coordinates.

    <scope>compile declares to which classpath this artifact is added during a build. See POM ReferenceDependenciesscope:. BTW, compile is the default , so it wouldn't be necessary at all.

    Ad 2.: Yes, it (usually) will. Transitivity is a multi-level concept/process down to the leaves of the dependency tree. Check the Dependency Plugin in one of your Maven projects:

    mvn dependency:tree
    

    Ad 3.: No not. ;)