继续开发插件

Continue development of Plugin

有一个由 Maven 管理的 Eclipse 插件包含此配置:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>wonttellya</groupId>
        <artifactId>wonttellya</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
        <dependencies>
            ...
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.10</version>
                <configuration>
                    <pde>true</pde>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

在控制台 I 运行

C:\Users\user\git\wonttellya\mvn 
         eclipse:eclipse -Declipse.workspace=C:\Users\user\workspace2
...
Using Eclipse Workspace: C:\Users\user\workspace2    
...
BUILD SUCCESS

如果我在工作区中打开 Eclipse,则没有项目。

首先,你要明白maven-eclipse-plugin的目的是,引用它的文档:

to generate Eclipse IDE files (*.classpath, *.project, *.wtpmodules and the .settings folder) for use with a project.

它的目标不是创建整个项目,而是从 现有 项目构建 Eclipse 块。

对于 PDE 支持也是如此。 Quoting its documentation:

Note that the scope of the maven-eclipse-plugin is to synchronise the Eclipse .project and .classpath files with the configuration found in the pom file. Once you have finished configuring the Eclipse plugin as below, and once you have run the eclipse:eclipse goal, you will be in a position to build your plugin code with the Eclipse IDE, or the Eclipse headless PDE build. The Eclipse headless PDE build can be triggered from within Maven using the pde-maven-plugin.

因此,您的配置仅允许为现有项目创建正确的 .project.classpath 文件,仅此而已。完成此配置且 eclipse:eclipse 目标为 运行 后,您将需要执行以下步骤:

  • 打开 Eclipse 并导入现有项目,方法是转到 "File > Import... > Existing Projects into Workspace"。
  • 右键单击新项目并select "Configure > Convert to Plugins Projects..."。确认这个选择。

然后您将能够直接在 IDE.

中构建您的 Eclipse 插件

请注意,我不建议使用此解决方案,我建议您改用 Tycho,这可能是您可以对此插件进行的改进(参考 this question)。

确保在 运行 安装 maven 之前更新项目 尝试用鼠标右键单击您的项目,然后转到 maven-->update project

对于不同的条款 您可以使用带存档 (.zip) 的导出和导入,您可以管理插件并简单地将您的项目转移到不同的工作区