3
votes

Is there a way to translate this human language in an xml codeblock that Maven will happily understand?

Hey Maven, look you are a great dependency management system. I am working on a JavaEE project which is intended to be deployed on Wildfly 10.1.0. Please put all Libraries that are specified in Wildflys parent BOM http://repo1.maven.org/maven2/org/wildfly/wildfly-parent/10.1.0.Final/wildfly-parent-10.1.0.Final.pom on the compiletime classpath and consider them as provided by Wildfly at runtime. And please dont bother me to list every single referenced artifact in the dependencies section of the projects pom file. Thank you Maven, you are so cool.

To clarify: As far as I understand, importing the bom file in the dependencyManagement section of my pom file will only spare me to specify the Version Number of every single artifact, but I will still have to declare every artifactID and groupID.

This is indeed discussed here How to use BOM file with Maven But in this answer is also stated:

Then you do not have to specify the version attribute of a dependency.

I would prefer to declare only that I am using wildfly and then be able to use all client libraries without declaring any other dependencies.

But I must admit, I have the feeling to miss something obvious. There should be an easy way to do this.

1
Possible duplicate of How to use BOM file with Maven?K.Nicholas
Thank you for your suggestions, but I think it is not a duplicate. The answer above only explains how to spare the declaration of version numbers, not the artifactID itself.Thomas
Depends on what you're trying to do. Typically, I only import such artifacts as I need. If you want everything, I would suggest the javaee 7 pom adam-bien.com/roller/abien/entry/essential_maven_pom_for_javaee or the wildfly spec api pom repo1.maven.org/maven2/org/wildfly/wildfly-spec-api/…K.Nicholas

1 Answers

3
votes

If you want everything in a another pom to be set as a dependency and as provided you can specify that in your pom. A minimal pom for wildfly 10.1.0.Final that includes everything seems to be as follows:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>wft</groupId>
    <artifactId>wft</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>wft</name>
    <description>wft</description>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-spec-api</artifactId>
            <version>10.1.0.Final</version>
            <type>pom</type>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>

But I would still recommend doing it the way that wildfly does it themselves, which is to put the BOM in the depencency management section and declare artifacts as you need them. Why? I don't know other than it's cleaner to read and maybe easier for maven/java to compile and build.