有没有办法使用 mvn eclipse:eclipse 在 .classpath 中添加自定义行?
我正在使用 mvn eclipse:eclipse
命令生成我的 .project
和 .classpath
。
但是,由于某些原因,我想在 .classpath 文件中添加一行。我的 pom.xml
中是否有可以用来实现此目的的配置?
请注意,不能使用
,因为这会删除 .classpath
的内容。
我正在使用 maven 3.0.2 和 maven-eclipse-plugin 2.8。
I am using mvn eclipse:eclipse
command to generate my .project
and .classpath
.
However, for some reasons, I want to add one line in the .classpath
file. Is there a configuration in my pom.xml
that I can use to achieve that?
Note that <additionalConfig>
cannot be used, as this will erase the content of the .classpath
.
I am using maven 3.0.2 and maven-eclipse-plugin 2.8.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于那条线是什么。
buildhelper-maven-plugin 到
添加源文件夹
之前的生命周期阶段
generate-sources
,这将自动被拾取
日食插件。
可以使用 classpathContainers
参数
如果您想更改输出文件夹(从
target/classes
和target/test-classes
更改为其他文件夹),请在 Maven 构建配置中更改它们:<预置><代码><构建>
anotherdir
yetanotherdir
<目录>somedir
您可以独立配置这三者中的每一个,并且 Eclipse 插件将拾取所做的更改,但将
outputDirectory
和testOutputDirectory
放入< code>directory (通常通过引用${project.build.directory}
),否则您会破坏mvn clean
等标准功能(它会清理$ {project.build.directory}
):<预置><代码><构建>
${project.build.directory}/main-classes
<目录>bin
参考:
更新:在你的情况下,我猜唯一可能的解决方案是以编程方式编辑
.classpath
文件。我可能会做这样的事情:generate-resources
)${project.basedir}/.classpath
(因为您只希望它在 Eclipse 项目中处于活动状态)此解决方案的问题: eclipse:eclipse 是一个目标,而不是一个阶段,因此不可能自动执行此操作,因此您必须执行以下操作:
或者也许这也可以工作:
It depends on what that line is.
buildhelper-maven-plugin to
add a source folder in a
lifecycle phase before
generate-sources
, this willautomatically be picked up by the
eclipse plugin.
can use the classpathContainers
parameter
If you want to change the output folders (from
target/classes
andtarget/test-classes
to something else), change them in the maven build configuration:You can configure each of those three independently, and the changes will be picked up by the eclipse plugin, but it's considered good practice to put
outputDirectory
andtestOutputDirectory
insidedirectory
(usually by referencing${project.build.directory}
), otherwise you break standard functionality likemvn clean
(it cleans${project.build.directory}
):Reference:
Update: in your case I guess the only possible solution is to programmatically edit the
.classpath
file. What I would probably do is something like this:<profile>
named eclipse (or whatever)generate-resources
)<file><exists>${project.basedir}/.classpath</exists></file>
(because you only want it to be active in an eclipse project)The problem with this solution:
eclipse:eclipse
is a goal, not a phase, so it's not possible to execute this automatically, so you'll have to do something like this:or perhaps this will also work: