0

我需要使用 Maven在我的文件中添加一个新的buildCommand 。.project

我的.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>&lt;project&gt;/.externalToolBuilders/myLuncher.launch</value>
            </dictionary>
        </arguments>
    </buildCommand>

有人知道我该怎么做吗?

4

2 回答 2

1

您可以根据文档更新您的 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>&lt;project&gt;/.externalToolBuilders/myLuncher.launch</value>
        </dictionary>
      </arguments>
    </additionalBuildcommands>
  </configuration>
</plugin>

然后,当您调用mvn eclipse:eclipse它时,它将重新生成您添加的 .project 文件buildCommand

于 2012-05-09T21:03:36.063 回答
0

感谢您的回答Attila - 我做了一些小的修改。我试图编辑您的帖子,但编辑不被接受...

我通过以下方式使用插件:

<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>
                    &lt;project&gt;/.externalToolBuilders/myLuncher.launch
                    </LaunchConfigHandle>
                </arguments>
            </buildCommand>
        </additionalBuildcommands>  
    </configuration>
</plugin>

我使用版本 2.7 而不是 2.9,因为它允许我使用命令eclipse:m2eclipse,然后使用带有 m2eclipse 插件的项目

于 2012-05-11T12:41:34.010 回答