Maven耳塞&带分类器的ejbModule

时间:2015-12-07 11:07:40

标签: maven-2 maven-ear-plugin

在我的maven2多模块项目中,我有2个模块

  • 一个带有ejb3
  • 一个人的耳朵

ejb包含我想要包含在jar中的依赖项。

因此ejb我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>

<parent>
    <groupId>be.tuto</groupId>
    <artifactId>cendo2015</artifactId>
    <version>1.0</version>
</parent>

<artifactId>cendo2015-ejb</artifactId>

<packaging>ejb</packaging>

<name>${project.artifactId}</name>

<dependencies>

    <dependency>
        <groupId>be.tuto</groupId>
        <artifactId>test2015</artifactId>
        <type>jar</type>
        <version>1.0</version>
        <optional>true</optional>
    </dependency>

</dependencies>

<build>

    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <ejbVersion>3.0</ejbVersion>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>create-my-bundle</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </execution>
            </executions>
        </plugin>

    </plugins>

</build>

两个罐子生成良好

[INFO] [install:install {execution: default-install}]
[INFO] Installing ...\cendo2015\modules\ejb\target\cendo2015-ejb-1.0.jar to ...\.m2\repository\be\tuto\cendo2015-ejb\1.0\cendo2015-ejb-1.0.jar
[INFO] Installing ...\cendo2015\modules\ejb\target\cendo2015-ejb-1.0-jar-with-dependencies.jar to ...\.m2\repository\be\tuto\cendo2015-ejb\1.0\cendo2015-ejb-1.0-jar-with-dependencies.jar

我现在想把jar-with-dependencies包含在耳中。

所以我的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>be.tuto</groupId>
    <artifactId>cendo2015</artifactId>
    <version>1.0</version>
</parent>

<artifactId>cendo2015-app</artifactId>

<name>${project.artifactId}</name>

<packaging>ear</packaging>

<dependencies>

    <dependency>
        <groupId>be.tuto</groupId>
        <artifactId>cendo2015-ejb</artifactId>
        <type>ejb</type>
        <version>1.0</version>
        <classifier>jar-with-dependencies</classifier>
    </dependency>

</dependencies>

<build>

    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>2.10.1</version>
                <configuration>
                    <modules>
                        <ejbModule>
                            <groupId>be.tuto</groupId>
                            <artifactId>cendo2015-ejb</artifactId>
                            <classifier>jar-with-dependencies</classifier>
                        </ejbModule>
                    </modules>
                </configuration>
          </plugin>

    </plugins>

</build>

最后,我的parent 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/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>be.tuto</groupId>
<artifactId>cendo2015</artifactId>
<version>1.0</version>

<packaging>pom</packaging>

<name>cendo2015</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>

</dependencies>

<build>

    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>

    </plugins>

</build>

<dependencyManagement>

    <dependencies>
    </dependencies>

</dependencyManagement>

<modules>
    <module>modules/ejb</module>
    <module>modules/app</module>
</modules>

正在运行mvn clean package给我

[INFO] [ear:generate-application-xml {execution: default-generate-application-xml}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Artifact[ejb:be.tuto:cendo2015-ejb:jar-with-dependencies] is not a dependency of the project.

现在,如果我只针对耳模块执行mvn clean package,那么它正在工作。

[INFO] [ear:ear {execution: default-ear}]
[INFO] Copying artifact [ejb:be.tuto:cendo2015-ejb:jar-with-dependencies:1.0] to [cendo2015-ejb-1.0-jar-with-dependencies.jar]

所以我不明白发生了什么!

0 个答案:

没有答案