Maven Multi Module EAR — не добавлять дочерние модули

У меня есть многомодульный проект Maven (Jakarta EE 8), основанный на архетипе wildfly-jakartaee8-with-tools, развернутом на Wildly 26 и использующем плагин maven-ear-plugin (3.2.0)

Это структура проекта

-WebApp.ear
    -Web-entities.jar
    -Web-ejb.jar
    -Web-web.war
    -Web-mobile.war
    -Web-api.war

Вот Web-ear pom.xml

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>com.webapp</groupId>
    <artifactId>WebApp</artifactId>
    <version>1.0.0</version>
</parent>
<artifactId>Web-ear</artifactId>
<packaging>ear</packaging>
<name>Web - ear</name>
<description>This is the EAR POM file</description>

<dependencies>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>Web-entities</artifactId>
        <type>ejb</type>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>Web-ejb</artifactId>
        <type>ejb</type>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>Web-web</artifactId>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>Web-mobile</artifactId>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>Web-api</artifactId>
        <type>war</type>
    </dependency>
</dependencies>

<build>
    <finalName>${project.parent.artifactId}</finalName>
    <plugins>
        <!--EAR plugin: format of output file -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>${version.ear.plugin}</version>
            <configuration>
                <!-- Tell Maven we are using Jakarta EE -->
                <version>8</version>
                <displayName>Web-ear</displayName>
                <generateApplicationXml>true</generateApplicationXml>
                <initializeInOrder>true</initializeInOrder>
                <!-- Use Jakarta EE ear libraries as needed. Jakarta EE ear libraries
                    are in easy way to package any libraries needed in the ear, and automatically
                    have any modules (EJB-JARs and WARs) use them -->
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <unpackTypes>war</unpackTypes>
                <modules>
                
                    <ejbModule>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>Web-entities</artifactId>
                        <bundleFileName>Web-entities.jar</bundleFileName>
                    </ejbModule>
                        
                    <ejbModule>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>Web-ejb</artifactId>
                        <bundleFileName>Web-ejb.jar</bundleFileName>
                    </ejbModule>
                    
                    <webModule>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>Web-web</artifactId>
                        <contextRoot>/webapp</contextRoot>
                        <bundleFileName>Web-web.war</bundleFileName>
                    </webModule>
                    
                    <webModule>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>Web-mobile</artifactId>
                        <contextRoot>/mobile</contextRoot>
                        <bundleFileName>Web-mobile.war</bundleFileName>
                    </webModule>
                    
                    <webModule>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>Web-api</artifactId>
                        <contextRoot>/api</contextRoot>
                        <bundleFileName>Web-api.war</bundleFileName>
                    </webModule>
                    
                </modules>
            </configuration>
        </plugin>
        <!-- The WildFly plug-in deploys your ear to a local WildFly / JBoss EAP container.
            Due to Maven's lack of intelligence with EARs we need to configure
            the WildFly Maven plug-in to skip deployment for all modules. We then enable
            it specifically in the ear module. -->
        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <configuration>
                <skip>false</skip>
            </configuration>
        </plugin>
    </plugins>
</build>

Но когда я создаю сгенерированный файл application.xml, он не включает ни один из дочерних модулей.

Если я установлю generateApplicationXml значение false, то вручную создам application.xml с указанными модулями, он все равно не добавит дочерние модули в выходной EAR. но если я устанавливаю <scope>compile</scope> для зависимостей модулей в наушниках, они включаются - но мне это кажется неправильным, поскольку во всех примерах, которые я вижу, используется <scope>provided</scope>?

Я вижу, что Maven правильно создает каждый дочерний модуль, и они присутствуют в выходной папке /target подмодуля, но просто не добавляют их в вывод EAR, я просто получаю пустой EAR с метаинформацией.

Не удалось выполнить цель org.apache.maven.plugins
Не удалось выполнить цель org.apache.maven.plugins
Опишу, что когда я только начинал изучать Maven, у меня не получалось компилировать и упаковывать.
Blibli Automation Journey - Как захватить сетевой трафик с помощью утилиты HAR в Selenium 4
Blibli Automation Journey - Как захватить сетевой трафик с помощью утилиты HAR в Selenium 4
Если вы являетесь веб-разработчиком или тестировщиком, вы можете быть знакомы с Selenium, популярным инструментом для автоматизации работы...
0
0
18
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Я обнаружил, что причина этого была в родительском проекте pom.xml дочерние зависимости были помечены <scope>provided</scope>, что предотвратило упаковку дочерних модулей, удаление этого устранило проблему.

Другие вопросы по теме