【发布时间】:2012-08-08 06:13:14
【问题描述】:
我是 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 中查看生成的 .classpath 时,“some_real_folder”在那里,但“properties”却没有。看起来默认情况下 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”和链接资源“properties”都添加到项目2的.classpath中
【问题讨论】:
-
你能展示一下你项目的目录结构吗?您使用哪个 Eclipse 版本?你用m2e吗?
-
展示的并不多。我有: project1 \-- 属性(这是真正的文件夹) project2 \-- some_real_folder \-- 属性(这是链接资源) 我需要“some_real_folder”和链接的资源“属性”作为 . project2的类路径
-
抱歉,不知道如何让它看起来更漂亮。
-
只需在此处编辑您的帖子,您就可以获得更好的格式。
标签: maven maven-eclipse-plugin