我需要使用Maven在我的.project
文件中添加新的 buildCommand 。
我的.project
文件(由Maven创建):
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>myProject</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
我必须添加以下 buildCommand :
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>auto,full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value><project>/.externalToolBuilders/myLuncher.launch</value>
</dictionary>
</arguments>
</buildCommand>
有人知道我该怎么做吗?
答案 0 :(得分:1)
您可以根据documentation:
更新maven pom.xml文件<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalBuildcommands>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>auto,full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value><project>/.externalToolBuilders/myLuncher.launch</value>
</dictionary>
</arguments>
</additionalBuildcommands>
</configuration>
</plugin>
然后,当您致电mvn eclipse:eclipse
时,它会使用您添加的buildCommand
答案 1 :(得分:0)
感谢您的answer阿提拉 - 经过一些小修改后,我确保了它的运作。我试图编辑你的帖子,但是不接受编辑......
我以下列方式使用了该插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.7</version>
<configuration>
<additionalBuildcommands>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>auto,full,incremental,</triggers>
<arguments>
<LaunchConfigHandle>
<project>/.externalToolBuilders/myLuncher.launch
</LaunchConfigHandle>
</arguments>
</buildCommand>
</additionalBuildcommands>
</configuration>
</plugin>
我使用版本2.7而不是2.9,因为它允许我使用命令eclipse:m2eclipse
然后使用带有m2eclipse插件的项目