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

时间:2016-06-17 15:31:33

标签: java eclipse git maven build

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

enter image description here

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

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

需要软件:

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

  • GIT中
  • 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步:

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

第3步:

克隆Git存储库:

-DskipTests

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

第4步:

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

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

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

第5步:

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

-Dnative=win32.win32.x86_64

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

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

编辑:

我已将参数-X添加到build命令中。不幸的是,我在15到20分钟后出错了。这次,我还添加了参数 ... [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 ,以获取调试信息:

-Dnative=win32.win32.x86_64

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

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

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

编辑:

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

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

最终编辑:

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

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

4 个答案:

答案 0 :(得分: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>
..
..

修改

正如评论中提到的,我按照你的步骤进行了操作并遇到了一些问题。我现在解决了大部分问题。如果其他人也遇到了很多错误,这里有一些解决方案。

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

  • 提示:要加快构建速度,您可以添加例如: &#34; -T 4&#34;到mvn命令以启用并行构建。我终于以&gt; mvn清除验证结束-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 =&#34; false&#34; (在默认情况下设置为&#34; true&#34;默认情况下)我能够继续构建。 我认为这是一个非常糟糕的解决方案,它不应该是禁用此类测试的问题的最终解决方案。

最后,我以项目org.eclipse.pde.build.tests中的错误结束并停止跟踪问题。 整个项目似乎在很多方面都是错误的配置,到目前为止我找不到更好的解决方案。人们应该记住黄金法则,不要做任何破坏构建的东西来避免这些问题。也许这些问题将在回购更新后解决。

答案 1 :(得分:2)

此处构建了多个项目

  1. SWT原生代。 (-Dnative =)
  2. IDE。 (独立于平台)
  3. 每天美国东部时间/美国东部时间19:00(由SWT团队)建立SWT本地人并推送到eclipse.platform.swt.binaries.git repo。这个构建需要相当多的依赖,如visual studio,xulrunner,WebKit等。对于尝试构建我不建议你尝试这个。

    CBI(Common Build Infrastructure)执行eclipse插件构建,签名和打包。此过程与平台无关。

    CBI构建于美国东部时间/美国东部时间每日20:00开始,swt.binaries仅在包装期间被提取。包装在整个过程中可能需要大约5分钟。因此,如果您只指定1个目标来构建,我并不期望有太大差异。

答案 2 :(得分:2)

要仅定位一个操作系统,您必须在父 pom.xml 文件中指定目标环境(请参阅Tycho - Target runtime environment):

<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>target-platform-configuration</artifactId>
    <version>${tycho-version}</version>
    <configuration>
        <environments>
            <environment>
                <os>win32</os>
                <ws>win32</ws>
                <arch>x86</arch>
            </environment>
        <environments>
    </configuration>
</plugin>

如果使用PDE Build而不是Maven / Tycho,则Ant属性为configs,例如-Dconfigs="win32, win32, x86"

仅供参考:Eclipse Platform CI which generates the Eclipse SDK archives

答案 3 :(得分:1)

来自https://wiki.eclipse.org/Platform-releng/Platform_Build#Building_natives

  

或者,您可以使用以下选项之一传递-Dnative =参数来编译指定本机的本机。

  • cocoa.macosx.x86
  • cocoa.macosx.x86_64
  • gtk.linux.x86
  • gtk.linux.x86_64
  • win32.win32.x86
  • win32.win32.x86_64
  • win32.wce_ppc.arm

arg将是-Dnative=win32.win32.x86_64