Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.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
如何在maven远程资源插件中使用/_Maven_Filtering_Maven Resources Plugin - Fatal编程技术网

如何在maven远程资源插件中使用/

如何在maven远程资源插件中使用/,maven,filtering,maven-resources-plugin,Maven,Filtering,Maven Resources Plugin,我正在尝试使用maven remote resources插件(如示例所示)在多个maven模块之间选择性地共享公共资源,我很难有选择性地导入资源 我正在尝试使用和元素如下。我还没有看到doco中提到的这些插件,但是eclipse在命令完成中提供了它们作为有效选项,并且在运行pom时没有收到任何错误。到目前为止,我还不能得到或有任何影响,在所有的进口资源 <build> <plugins> <plugin> <artifactI

我正在尝试使用maven remote resources插件(如示例所示)在多个maven模块之间选择性地共享公共资源,我很难有选择性地导入资源

我正在尝试使用和元素如下。我还没有看到doco中提到的这些插件,但是eclipse在命令完成中提供了它们作为有效选项,并且在运行pom时没有收到任何错误。到目前为止,我还不能得到或有任何影响,在所有的进口资源

<build>
  <plugins>
    <plugin>
       <artifactId>maven-remote-resources-plugin</artifactId>
       <executions>
         <execution>
           <goals>
             <goal>bundle</goal>
           </goals>
         </execution>
       </executions>
       <configuration>
         <includes>
           <include>**/*</include>
         </includes>
       </configuration>
     </plugin>
  </plugins>
</build>

<dependencies>
  <dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-remote-resources-plugin</artifactId>
    <version>1.3</version>
  </dependency>
</dependencies>
我的pom的相关部分包括:

共享资源

<build>
  <plugins>
    <plugin>
       <artifactId>maven-remote-resources-plugin</artifactId>
       <executions>
         <execution>
           <goals>
             <goal>bundle</goal>
           </goals>
         </execution>
       </executions>
       <configuration>
         <includes>
           <include>**/*</include>
         </includes>
       </configuration>
     </plugin>
  </plugins>
</build>

<dependencies>
  <dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-remote-resources-plugin</artifactId>
    <version>1.3</version>
  </dependency>
</dependencies>
资源消费者

<build>
 ...
  <plugins>
    <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-remote-resources-plugin</artifactId>
       <version>1.3</version>
       <configuration>
         <resourceBunldes>
           <resourceBundle>myApp:myApp_sharedresources:${project.version}</resourceBundle>
         </resourceBundles>
         <outputDirectory>${project.build.outputDirectory}</outputDirectory>
         <includes>
           <include>theOnlyResourceIWant.properties</include>
         </includes>
       </configuration>
       <executions>
         <execution>
           <goals>
             <goal>process</goal>
           </goals>
           <phase>generate-resources</phase>
         </execution>
       </executions>
     </plugin>
  </plugins>
</build>

<dependencies>
  <dependency>
    <groupId>myApp</groupId>
    <artifactId>myApp_sharedresources</artifactId>
    <version>1.0</version>
  </dependency>
</dependencies>
我尝试了许多和的组合,但到目前为止都没有效果

那么,你呢

<includes></includes>

maven远程资源插件配置的有效元素,以及如何使用它们? 我可以合理地将资源分离为单独的maven模块,但这可能会创建大量单文件maven模块,并添加大量额外的xml,因此如果可能的话,我希望避免使用它


我真的不想开始浏览插件源代码,但这是下一步。

要为格式为“{expr}”的Ruby样式启用筛选器分隔符,请在插件配置中添加以下内容:

<plugin>
    <artifactId>maven-remote-resources-plugin</artifactId>
    <version>1.3</version>
    <executions>
      <execution>
        <id>process-remote-resources</id>
        <goals>
          <goal>process</goal>
        </goals>
        <configuration>
          <filterDelimiters>
            <filterDelimiter>#{*}</filterDelimiter>
          </filterDelimiters>
          [...]
        </configuration>
      </execution>
    </executions>
  </plugin>

检查引用

我为正在导入的共享资源使用临时目录,并对其进行筛选

远程资源插件配置如下。这会将所有共享资源复制到项目中的临时目录中。设置attached to false意味着它们不包含在最终项目工件中,这使您有机会使用Maven的正常资源处理来选择要包含的项目工件

<plugin>
<artifactId>maven-remote-resources-plugin</artifactId>
<configuration>
  <resourceBundles>
    <resourceBundle>myApp:myApp_sharedresources:${project.version}</resourceBundle>
  </resourceBundles>
  <attached>false</attached>
  <outputDirectory>${project.build.directory}/shared-resources</outputDirectory>
</configuration>
<executions>
   <execution>
     <goals>
       <goal>process</goal>
     </goals>
     <phase>generate-resources</phase>
   </execution>
 </executions>
</plugin>

我建议将共享目录设置为${project.build.directory}的子目录,这样干净的生命周期就可以不做任何更改了。

谢谢你的回答,但我阅读了这篇关于如何更改筛选器分隔符的文档,但无法解决如何将其应用于我的情况。请编辑您的答案,包括一个示例/链接,说明如何将过滤器应用于从捆绑包中选择的每个文件。我对Maven很陌生,所以这可能是一件标准的事情。对不起,如果我不知道
<resources>
  <resource>
     <directory>${project.build.directory}/shared-resources</directory>
     <includes>
       <include>theOnlyResourceIWant.properties</include>
     </includes>
  </resource>
  <resource>
     <directory>${basedir}/src/main/resources</directory>
  </resource>
</resources>