我刚接触maven,一开始遇到了一个看起来很简单的问题,但我已经忙了一整天,没有办法让它工作。
首先,作为运行eclipse:eclipse插件的一部分,我创建了一个链接文件夹,如下所示:
<linkedResources>
<linkedResource>
<name>properties</name>
<type>2</type>
<location>${PARENT-2-PROJECT_LOC}/some_other_project/properties</location>
</linkedResource>
<linkedResource>
<name>properties/messages.properties</name>
<type>1</type>
<location>${PARENT-2-PROJECT_LOC}/some_other_project/properties/messages.properties</location>
</linkedResource>然后添加该文件夹作为源文件夹,如下所示:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>properties</source>
<source>some_real_folder</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>然而,当我查看eclipse中生成的属性时,“some_real_folder”存在,但“.classpath”不存在。默认情况下,build-helper-maven-plugin将检查文件夹是否在那里,如果不在,则不会添加它。
我在eclipse外使用maven 3.0.4来运行构建,我可以在maven日志中看到类似以下内容:
[INFO] Source directory: <some path>\properties added.这是我的项目结构:
project1
\-- properties (this is the real folder)
project2
\-- some_real_folder
\-- properties (this is the link resource pointing to the project1/properties folder)我所需要的就是将"some_real_folder“和链接的资源”.classpath“添加到project2的属性中
发布于 2012-11-27 19:02:59
将来自外部的东西直接包含到工件中是一种糟糕的做法。您应该只将project2文件夹下的内容和项目2依赖项中的内容包含到project2中。(我根本不确定您正在做的事情是否可能。)
因此,如果您希望在project2中使用project1/properties,通常需要将project1/properties打包到project1的artefact中,并将对project1的依赖添加到project2中。如果由于某种原因这不起作用(例如,因为您想要将project1的内容移动到project2中的另一个位置),您可以使用maven-dependency-plugin dependency:copy-dependencies into project2的target到适当的位置来解压它。
https://stackoverflow.com/questions/11858649
复制相似问题