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

K.M*_*ier 14 java eclipse git build maven

这篇文章是关于从源代码构建整个Eclipse IDE的 - 更具体地说,是如何指定要为其构建可执行文件的目标OS.

在此输入图像描述

我找到了以下教程来指导我完成构建过程: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 :

C:\磁盘中创建一个新文件夹.我们来命名吧C:\myEclipse.这将是我们在其中提取最新Eclipse版本的Git存储库的文件夹.

第2步 :

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

第3步:

克隆Git存储库:

git clone -b master --recursive git://git.eclipse.org/gitroot/platform/eclipse.platform.releng.aggregator.git
Run Code Online (Sandbox Code Playgroud)

现在您应该耐心地将所有源代码复制到本地文件夹.

第4步 :

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

mvn clean verify -DskipTests
Run Code Online (Sandbox Code Playgroud)

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

第5步:

构建的结果现在应该在以下文件夹中:

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

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

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


编辑:

我已将参数添加-Dnative=win32.win32.x86_64到build命令中.不幸的是,我在15到20分钟后出错了.这一次,我也添加了参数-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
Run Code Online (Sandbox Code Playgroud)

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

PS:我还有一些与Eclipse"从头开始构建"主题相关的其他问题.如果你有兴趣:

让我们团结一致自己构建Eclipse IDE - 并根据我们的需求进行调整;-)


编辑:

先生/的Mss.扎普尔写了一篇有趣的评论.-Dnative在他/她阅读以下链接后,他/她认为论证不正确:http: //comments.gmane.org/gmane.comp.ide.eclipse.cbi.devel/896

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


最终编辑:

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

我还有19个小时可以获得50分的赏金.如果您在自己的机器上成功地从这个问题中重现了STEPS 1..5,请告诉我,并成功为一个特定的操作系统从头开始构建Eclipse IDE.我会奖励你奖金:-)

Ste*_*zel 5

此代码段取自导出到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>
..
..
Run Code Online (Sandbox Code Playgroud)

编辑

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

  • 在文件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中以错误结束并停止跟踪问题.整个项目似乎在很多方面都是错误的配置,到目前为止我找不到更好的解决方案.人们应该记住黄金法则,不要做任何破坏构建的东西来避免这些问题.也许这些问题将在对repo进行一些更新后解决.