Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java maven耳朵插件<;包装包括>;不包括项目文件_Java_Maven_Ear_Maven Ear Plugin - Fatal编程技术网

Java maven耳朵插件<;包装包括>;不包括项目文件

Java maven耳朵插件<;包装包括>;不包括项目文件,java,maven,ear,maven-ear-plugin,Java,Maven,Ear,Maven Ear Plugin,My ear项目具有以下结构: 我的pom.xml如下所示: <plugin> <artifactId>maven-ear-plugin</artifactId> <version>2.10</version> <configuration> <earSourceIncludes>META-INF/*</earSourceIncludes> <

My ear项目具有以下结构:

我的pom.xml如下所示:

  <plugin>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.10</version>
    <configuration>
      <earSourceIncludes>META-INF/*</earSourceIncludes>
      <packagingIncludes>META-INF/*,**/*.war</packagingIncludes>
      <version>7</version>
                <modules>
                    <webModule>
                        <groupId>com.ex</groupId>
                        <artifactId>one</artifactId>
                    </webModule>
                </modules>
      <generateApplicationXml>false</generateApplicationXml>  
    </configuration>
  </plugin>

maven耳朵插件
2.10
META-INF/*
META-INF/*,***/*战争
7.
com.ex
一
假的
我想要的是在我的ear文件中包含META-INF文件夹的内容,在ear文件根目录中类似的META-INF文件夹中

我尝试了earSourceIncludes和PackageIncludes的多种组合,但都没有成功:我的ear文件有链接的application.war,这很好,还有一个META-INF文件夹,它没有我需要的东西,而是一个预生成的MANIFEST.MF文件和一个带有pom的maven文件夹


我想知道我是否真的需要这个耳机。老实说,我不知道为什么它不能只使用packagingcludes参数

您可以使用
maven资源插件
将META-INF文件夹的内容包含到根META-INF文件夹中。见下文

项目基本目录-
${Project.basedir}

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.5</version>
    <executions>
        <execution>
            <id>copy-resources</id>
            <!-- here the phase you need -->
            <phase>validate</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>                         
                <outputDirectory>${project.basedir}/META-INF</outputDirectory>
                <resources>
                    <resource>                      
                        <directory>${project.rootdir}/META-INF</directory>
                        <filtering>true</filtering>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>
EAR根目录-
${project.rootdir}

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.5</version>
    <executions>
        <execution>
            <id>copy-resources</id>
            <!-- here the phase you need -->
            <phase>validate</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>                         
                <outputDirectory>${project.basedir}/META-INF</outputDirectory>
                <resources>
                    <resource>                      
                        <directory>${project.rootdir}/META-INF</directory>
                        <filtering>true</filtering>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

maven资源插件
2.5
复制资源
验证
复制资源
${project.basedir}/META-INF
${project.rootdir}/META-INF
真的

也许我不明白,但是META-INF文件夹在src文件夹之外,我不认为插件会找到它。我认为如果你把META-INF放在src/main/resources文件夹中,它应该可以在没有PackageIncludes的情况下工作。谢谢,我会尝试给出反馈更新:将ear插件与resources插件结合的想法很到位,所以我会将答案标记为正确,但是output directory project.basedir不会在ear中包含我的文件,因为ear插件显然是从构建目录(/target)中获取这些文件的。因此,我不得不使用${project.build.directory}/${project.build.finalName}/META-INF,而且工作正常。对于更多的读者,这可能取决于您如何配置ear插件。@Jorge.V感谢您让我知道这一点。我对ear插件只有一点经验。