如何在maven-jar-plugin中包含外部源文件

时间:2012-04-04 16:31:40

标签: maven

我们正在从外部(到项目)类构建一个jar文件。 这工作正常,但我们无法弄清楚如何包含外部源文件。我尝试过使用“< includes>”标签但最终只在最终jar中使用清单文件。我已经看过使用maven-resources-plugin但是我使用它错了或者在我的情况下不起作用。这是我们代码的副本:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <executions>
                <execution>
                    <!-- <phase>generate-resources</phase> -->
                    <phase>clean</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <classesDirectory>${itendant.path}/web/rocket/WEB-INF/classes</classesDirectory>
                        <finalName>${itendant.jar.name}</finalName>
                        <outputDirectory>${itendant.jar.path}</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>

1 个答案:

答案 0 :(得分:0)

来源?你的意思是外部依赖吗?这些也应该使用maven进行管理,使用http://maven.apache.org/plugins/maven-deploy-plugin/usage.html中所述的mvn deploy:deploy-file进行管理,并导入到您的pom.xml中。

如果你真的是指外部资源,那么适当的资源声明将是:

<project>
 ...
 <build>
   ...
   <resources>
     <resource>
       <directory> [your folder here] </directory>
     </resource>
   </resources>
   ...
 </build>
 ...
</project>

如果您有多个资源目录,当然可以有多个标记。另请注意,在clean期间构建任何内容都值得怀疑,因为clean未在每次构建时运行 - package将是更好的选择。