java - 如何构建 EclipseLink 2.7.0

标签 java maven eclipselink maven-3 tycho

我从这里下载了 eclipselink https://github.com/eclipse/eclipselink.runtime .里面有很多子项目。其中一些可以使用 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。

问题:如何构建?

最佳答案

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

查看 antbuild.xml ant 构建文件,您会看到它正在通过其 Java 主类调用 Maven(Maven 是用 Java 构建的,毕竟入口点是一个旧的普通 Java 主类):org.codehaus.plexus.classworlds.launcher.Launcher ,在其 build-core 中目标。

所以工作流程是:

  • 从根文件夹启动 ant 构建,调用 ant -f antbuild.xml
  • 然后 Ant 将调用 Maven 构建作为嵌套构建
  • 嵌套的 Maven 构建在多模块/聚合器项目上,这反过来将构建多个 Maven 模块(子项目),从位于 下的根/父 Maven pom.xml 开始>buildsystem/org.eclipse.persistence.parent

请注意,您需要:

  • Maven 3 构建它,作为上述父 pom 文件的 先决条件
  • M2_HOME环境变量集,指向你的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\4.12\junit-4.12.jar

或者,您可以在 antbuild.properties 中指定路径文件,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 中设置eclipse.moxy.test 的文件模块,here :

#JMockit   
jmockit.jar=jmockit-1.10.jar

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

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

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

关于java - 如何构建 EclipseLink 2.7.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37770644/

相关文章:

java - 如何防止客户端访问JSP页面

java - 通过 Java Eclipse 进行 Android 开发 : I am Exporting But It Is Not Exporting As . apk 文件

java - jsp文件中的springmvc maven链接文件

java - 使用扩展类的方法

java - 未找到 maven-compiler-plugin

java - 一次解压 maven 依赖项以加速 maven 构建

java - 加速实体管理器3000条记录的提交

java - JPA、Eclipselink - 关系在新事务中被删除

javax.persistence.* 来源,在哪里?

java - HtmlUnit:点击无响应时登录HtmlElement