如何构建 EclipseLink 2.7.0

How to build EclipseLink 2.7.0

我从这里 https://github.com/eclipse/eclipselink.runtime 下载了 eclipselink。里面有很多子项目。其中一些可以使用 maven 构建,一些使用 ant,一些使用 gradle。

但是,我要构建的org.eclipse.persistence.core是maven项目。但是当我尝试构建它时(无论是父项目)我得到异常:

Scanning for projects...
Computing target platform for MavenProject: org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:2.7.0-SNAPSHOT @ /home/TEMP/eclipselink.runtime-master/jpa/org.eclipse.persistence.jpa.jpql/pom.xml
Fetching p2.index from http://download.eclipse.org/tools/orbit/downloads/drops/R20130827064939/repository/ (0B at 0B/s)
Adding repository http://download.eclipse.org/tools/orbit/downloads/drops/R20130827064939/repository
Fetching p2.index from http://download.eclipse.org/releases/luna/ (0B at 0B/s)
Adding repository http://download.eclipse.org/releases/luna
Fetching p2.index from http://download.eclipse.org/releases/luna/201406250900/ (0B at 0B/s)
Fetching p2.index from http://download.eclipse.org/releases/luna/201409261001/ (0B at 0B/s)
Fetching p2.index from http://download.eclipse.org/releases/luna/201501121000/ (0B at 0B/s)
Fetching p2.index from http://download.eclipse.org/releases/luna/201502271000/ (0B at 0B/s)
Resolving dependencies of MavenProject: org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:2.7.0-SNAPSHOT @ /home/TEMP/eclipselink.runtime-master/jpa/org.eclipse.persistence.jpa.jpql/pom.xml
Resolving class path of MavenProject: org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:2.7.0-SNAPSHOT @ /home/TEMP/eclipselink.runtime-master/jpa/org.eclipse.persistence.jpa.jpql/pom.xml
Computing target platform for MavenProject: org.eclipse.persistence:org.eclipse.persistence.core:2.7.0-SNAPSHOT @ /home/TEMP/eclipselink.runtime-master/foundation/org.eclipse.persistence.core/pom.xml
Resolving dependencies of MavenProject: org.eclipse.persistence:org.eclipse.persistence.core:2.7.0-SNAPSHOT @ /home/TEMP/eclipselink.runtime-master/foundation/org.eclipse.persistence.core/pom.xml
{osgi.os=linux, osgi.ws=gtk, org.eclipse.update.install.features=true, osgi.arch=x86_64}
Cannot resolve project dependencies:
  Software being installed: org.eclipse.persistence.core 2.7.0.qualifier
  Missing requirement: org.eclipse.persistence.core 2.7.0.qualifier requires 'bundle org.eclipse.persistence.antlr 3.5.2' but it could not be found

See http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting for help.
Cannot resolve dependencies of MavenProject: org.eclipse.persistence:org.eclipse.persistence.core:2.7.0-SNAPSHOT @ /home/TEMP/eclipselink.runtime-master/foundation/org.eclipse.persistence.core/pom.xml: See log for details -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles: 
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MavenExecutionException

jar org.eclipse.persistence.antlr 3.5.2 已经在我下载的 zip 中,而且还有它的源代码,可以使用 ant 构建。
我可以将这个 jar 添加为依赖项,但我认为这不是正确的方法 - 因为这个 zip 文件中有很多 jar。

问题:如何搭建?

我在一个项目中遇到了相同类型的问题。有一个父项目。还有另一个项目。但他们彼此依赖。下面给出了我必须做的才能使其 运行 可用。

您必须确定需要先构建哪个。然后下一个,然后下一个。如果您没有文档,那么识别起来既困难又费时。

另一件事:

运行 EclipseLink 2.7.0 的最低要求是 Java 8。请确保您已安装 Java 8 并且它正在运行。

您可以使用 this guide 构建 EclipseLink。

某些元素可能已过时,但您应该没有问题。

确实 pom.xml 文件具有误导性,这些项目不是 Maven 项目,或者 - 至少 - 不打算直接通过 Maven 构建。整个构建是一个 ant 构建,由于需要使用 Tycho 集成,它使用 Maven 作为支持工具。

查看 antbuild.xml ant build file, you would see it is invoking Maven via its Java main class (Maven is built in Java and the entry point is an old plain Java main after all): org.codehaus.plexus.classworlds.launcher.Launcher, in its build-core 目标。

所以工作流程是:

  • 开始 ant 构建,从根文件夹调用 ant -f antbuild.xml
  • Ant 随后将调用 Maven 构建作为嵌套构建
  • 嵌套的 Maven 构建在 multi-module/aggregator 项目上,这反过来将构建几个 Maven 模块(子项目),从位于 [=22] 下的 root/parent Maven pom.xml 开始=]

请注意,您需要:

  • Maven 3 构建它,作为上述父 pom 文件的 prerequisites
  • M2_HOMEenv变量集,指向你的maven安装文件夹
  • 使用 Ant 1.9+

但是,作为最小设置的一部分,默认构建不会 运行 正确(成功),因为 junit 缺少由 echo 指定的库声明如下:

[echo] junit.lib = '${junit.lib}' (if not set tests may not compile; let alone run)

因此,最小调用为:

ant -f antbuild.xml -Djunit.lib=<path_to_junit_jar>

例如,您可以直接指向您的 Maven 存储库,如下所示(对我有用):

ant -f antbuild.xml -DC:\data\m2\repository\junit\junit.12\junit-4.12.jar

或者,您可以在 antbuild.properties file, here:

中指定路径
# The directory that holds the oracle-specific jar files.   
# You can either put the jars in this directory, or specify your own directory.   
junit.lib=../extension.lib.external/junit.jar

jmockit也应如此,否则会导致一些编译错误,但不影响成功构建。

jmockit.jar属性可以设置在antbuild.properties file of the eclipse.moxy.test module, here:

#JMockit   
jmockit.jar=jmockit-1.10.jar

或者,再次按照以下示例通过命令行:

ant -f antbuild.xml -Djunit.lib=C:\data\m2\repository\junit\junit.12\junit-4.12.jar -Djmockit.jar=C:\data\m2\repository\org\jmockit\jmockit.10\jmockit-1.10.jar

上面的命令让我成功构建,完全没有编译错误。仅出现有关使用已弃用或内部 API.

的警告