从头开始构建 Eclipse IDE - 如何指定目标操作系统?

2022-09-03 15:29:18

这篇文章是关于从源代码构建整个Eclipse IDE的 - 特别是如何指定要为其构建可执行文件的目标操作系统。

enter image description here

我找到了以下教程来指导我完成构建过程:http://www.vogella.com/tutorials/EclipsePlatformDevelopment/article.html

特别是该教程的第13章很有帮助。我将在这里逐一描述需要采取的步骤 - 因此您无需阅读vogella教程。

所需软件 :

显然,您需要在(Windows)计算机上安装以下软件:

  • 吉特
  • Maven 版本 3.3.1(确保将提取 Maven 的 bin 文件夹添加到 PATH 中。有关安装说明,请参阅 https://maven.apache.org/install.html)
  • Oracle 1.8 JDK 或更高版本(不要忘记设置JAVA_HOME环境变量)

现在,您可以开始了:

步骤 1 :

在磁盘中创建新文件夹。让我们给它起个名字。这将是我们在其中拉取最新Eclipse版本的Git存储库的文件夹。C:\C:\myEclipse

步骤 2 :

使用管理员权限打开 Windows 外壳程序(如果您在桌面上创建了一个,请右键单击图标,然后选择 )。通过命令转到该文件夹。现在键入以下命令:。这会通知 Git 存储库中可能会出现长名称。忘记此命令,它将导致以后的错误。cmdcmdopen with admin rightscd C:\myEclipsegit config --system core.longpaths true

步骤 3 :

克隆 Git 存储库:

git clone -b master --recursive git://git.eclipse.org/gitroot/platform/eclipse.platform.releng.aggregator.git

现在,您应该对所有源代码复制到本地文件夹有一些耐心。

步骤 4 :

最后,是时候开始构建了。构建过程已经需要几个小时,因此跳过单元测试是明智的。因此,不要忘记添加参数。这是启动构建的命令:-DskipTests

mvn clean verify -DskipTests

几个小时后,构建应该完成。

步骤 5 :

生成的结果现在应位于以下文件夹中:

C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.releng.tychoeclipsebuilder\sdk\target\products

请注意,Eclipse IDE 是为所有可能的目标计算机构建的。32位Windows,64位Windows,Macintosh,Linux,...难怪需要几个小时!我只想为一个目标构建 - 例如我的64位Windows计算机。这有望显著缩短构建时间,并允许我更快地验证代码更改。

有谁知道如何实现这一目标?


编辑:

我已将参数添加到 build 命令中。不幸的是,我在15到20分钟后收到错误。这一次,我还添加了参数,以获取调试信息:-Dnative=win32.win32.x86_64-X

                      ...

[INFO] equinox-sdk ........................................ SKIPPED
[INFO] org.eclipse.rcp.id ................................. SKIPPED
[INFO] org.eclipse.rcp.sdk.id ............................. SKIPPED
[INFO] org.eclipse.platform.ide ........................... SKIPPED
[INFO] org.eclipse.platform.sdk ........................... SKIPPED
[INFO] org.eclipse.sdk.ide ................................ SKIPPED
[INFO] eclipse-junit-tests ................................ SKIPPED
[INFO] eclipse.platform.repository ........................ SKIPPED
[INFO] platform-aggregator ................................ SKIPPED
[INFO] -----------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] -----------------------------------------------------------------------
[INFO] Total time: 23:54 min
[INFO] Finished at: 2016-06-19T18:12:14+02:00
[INFO] Final Memory: 668M/3263M
[INFO] -----------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8: run (natives) on project org.eclipse.swt.win32.win32.x86_64: An Ant BuildException has occured: The following error occurred while executing this line:
[ERROR] C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt\bundles\org.eclipse.swt\buildSWT.xml:915: The following error occurred while executing this line:
[ERROR] C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt\bundles\org.eclipse.swt\buildSWT.xml:1012: exec returned: 1
[ERROR] around Ant part ...<ant antfile="build.xml" target="build_libraries"/>... @ 4:54 in C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt.binaries\bundles\org.eclipse.swt.win32.win32.x86_64\target\antrun\build-main.xml
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:
    run (natives) on project org.eclipse.swt.win32.win32.x86_64:
        An Ant BuildException has occured:
            The following error occurred while executing this line:
            C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt\bundles\org.eclipse.swt\buildSWT.xml:915: The following error occurred while executing this line:
            C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt\bundles\org.eclipse.swt\buildSWT.xml:1012: exec returned: 1 around Ant part ...<ant antfile="build.xml" target="build_libraries"/>... @ 4:54 in C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt.binaries\bundles\org.eclipse.swt.win32.win32.x86_64\target\antrun\build-main.xml
                at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
                at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 
                at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 
                at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
                at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
                at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
                at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
                at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
                at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
                at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
                at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
                at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
                at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:498)
                at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
                at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
                at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
                at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    Caused by:
        org.apache.maven.plugin.MojoExecutionException:
            An Ant BuildException has occured:

                The following error occurred while executing this line:
                C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt\bundles\org.eclipse.swt\buildSWT.xml:915:

                The following error occurred while executing this line:
                C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt\bundles\org.eclipse.swt\buildSWT.xml:1012: exec returned: 1 around Ant part ...<ant antfile="build.xml" target="build_libraries"/>... @ 4:54 in C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt.binaries\bundles\org.eclipse.swt.win32.win32.x86_64\target\antrun\build-main.xml
                    at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:342)
                    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default BuildPluginManager.java:134)
                    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
                    ... 20 more
                Caused by: C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt.binaries\bundles\org.eclipse.swt.win32.win32.x86_64\target\antrun\build-main.xml

                :4: The following error occurred while executing this line:
                C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt\bundles\org.eclipse.swt\buildSWT.xml

                :915:The following error occurred while executing this line:
                C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt\bundles\org.eclipse.swt\buildSWT.xml:1012: exec returned: 1
                    at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:568)
                    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:443)
                    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
                    at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                    at java.lang.reflect.Method.invoke(Method.java:498)
                    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
                    at org.apache.tools.ant.Task.perform(Task.java:348)
                    at org.apache.tools.ant.Target.execute(Target.java:435)
                    at org.apache.tools.ant.Target.performTasks(Target.java:456)
                    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
                    at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
                    at org.apache.maven.plugin.antrun.AntRunMojo.execute(AntRunMojo.java:313)
                    ... 22 more
                Caused by: C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt\bundles\org.eclipse.swt\buildSWT.xml

                :915: The following error occurred while executing this line:
                C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt\bundles\org.eclipse.swt\buildSWT.xml:1012: exec returned: 1
                    at org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:568)
                    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:443)
                    at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
                    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
                    at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                    at java.lang.reflect.Method.invoke(Method.java:498)
                    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
                    at org.apache.tools.ant.Task.perform(Task.java:348)
                    at org.apache.tools.ant.Target.execute(Target.java:435)
                    at org.apache.tools.ant.Target.performTasks(Target.java:456)
                    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
                    at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
                    at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
                    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
                    ... 33 more

                Caused by: C:\myEclipse\eclipse.platform.releng.aggregator\eclipse.platform.swt\bundles\org.eclipse.swt\buildSWT.xml:1012: exec returned: 1
                    at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:643)
                    at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:669)
                    at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:495)
                    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
                    at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                    at java.lang.reflect.Method.invoke(Method.java:498)
                    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
                    at org.apache.tools.ant.Task.perform(Task.java:348)
                    at org.apache.tools.ant.Target.execute(Target.java:435)
                    at org.apache.tools.ant.Target.performTasks(Target.java:456)
                    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
                    at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
                    at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
                    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
                    ... 46 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command

[ERROR]   mvn <goals> -rf :org.eclipse.swt.win32.win32.x86_64

我仍然没有答案,所以我开始了赏金。请在计算机上重现步骤 1 直到步骤 5(将参数添加到第四步)。您是否仅针对一个操作系统目标(最好是 Windows 64 位)成功构建了 Eclipse IDE?与面向所有操作系统的常规构建过程相比,构建速度是否更快?-Dnative=win32.win32.x86_64

PS:我还有其他一些与Eclipse“从头开始构建”主题相关的问题。如果您有兴趣:

让我们大家团结起来,自己构建Eclipse IDE - 并根据我们的需求进行调整;-)


编辑:

Zapl先生/女士写了一个有趣的评论。他/她认为论点不正确,在他/她阅读以下链接后:http://comments.gmane.org/gmane.comp.ide.eclipse.cbi.devel/896-Dnative

希望我们现在能更接近答案:-)


最终编辑 :

突然间,这个问题引起了社区的注意。我在短时间内得到了很多建议/答案。我现在无法验证其中的每一个,因为构建过程大约需要2个小时。

我还有 19 个小时的时间来奖励 50 点赏金。如果您在自己的计算机上成功复制了此问题的步骤 1..5,并且成功地为一个特定的操作系统从头开始构建 Eclipse IDE,请告诉我。我会奖励你奖金:-)


答案 1

此代码段取自导出到win32.win32.x86_64的工作 pom.xml。也许您的项目不需要某些部分,但这可能是将其添加到pom文件中的良好起点。

..
..
<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-maven-plugin</artifactId>
            <version>0.20.0</version>
            <extensions>true</extensions>
        </plugin>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>target-platform-configuration</artifactId>
            <version>0.20.0</version>
            <configuration>
                <resolver>p2</resolver>
                <environments>
                    <environment>
                        <os>win32</os>
                        <ws>win32</ws>
                        <arch>x86_64</arch>
                    </environment>
                </environments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-compiler-plugin</artifactId>
            <version>0.20.0</version>
            <configuration>
                <compilerArgument>-err:-forbidden</compilerArgument>
            </configuration>
        </plugin>
    </plugins>
</build>
..
..

编辑

正如评论中提到的,我遵循了您的步骤并遇到了一些问题。我现在解决了大部分问题。如果其他人也收到很多错误,这里有一些解决方案。

  • 在文件 eclipse.pde.ui/pom.xml第 19 行:版本是 4.6.0-SNAPSHOT,但必须是 4.7.0-SNAPSHOT

  • 提示:要加快构建速度,您可以在 mvn 命令中添加例如“-T 4”以启用并行构建。我最终以>mvn clean verify -DSkipTests -T 4 -Dnative=win32.win32.x86_64

在此修复之后,我能够运行,直到我遇到初始问题中提到的相同错误。我转到项目文件夹\eclipse.platform.swt.binaries\bundles\org.eclipse.swt.win32.win32.x86_64并启动了Ant构建(Apache Ant版本1.9.7),它完成了没有错误。但是当它被Maven构建执行时,我得到了同样的错误。因此,我检查了文件 \eclipse.platform.swt\bundles\org.eclipse.swt\buildSWT.xml 的第 915 行和第 1012 行。在两行中设置failonerror=“false”(默认情况下设置为“true”)后,我能够继续构建。我认为这是一个非常糟糕的解决方案,它不应该是禁用此类测试的问题的最终解决方案。

最后,我以项目 org.eclipse.pde.build.tests 中的错误结束,并停止关注这些问题。整个项目似乎在许多部分配置错误,到目前为止,我找不到更好的解决方案。人们应该记住黄金法则,不要提交任何破坏构建的东西来避免这些问题。也许在对存储库进行几次更新后,问题将得到解决。


答案 2

这里构建了多个项目

  1. SWT本地人。(-Dnative=)
  2. 艾德。(独立于平台)

SWT原住民每天在东部时间/美国东部时间19:00构建(由SWT团队)并推送到eclipse.platform.swt.binaries.git repo。这个版本需要相当多的依赖关系,如Visual Studio,xulrunner,WebKit等。对于尝试构建,我不建议您尝试此操作。

CBI(通用构建基础架构)执行 eclipse 插件构建、签名和打包。此过程与平台无关。

CBI 构建从每天 20:00 EST/EDT 开始,swt.二进制文件仅在打包过程中被拾取。在整个过程中,包装可能需要大约5分钟。因此,如果您只指定要构建的目标,我预计不会有太大差异。


推荐