【问题标题】:How to build EclipseLink 2.7.0如何构建 EclipseLink 2.7.0
【发布时间】:2016-10-12 17:51:32
【问题描述】:

我从这里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。

问题:如何构建它?

【问题讨论】:

    标签: java maven eclipselink maven-3 tycho


    【解决方案1】:

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

    查看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 模块(子项目),从位于 buildsystem/org.eclipse.persistence.parent 下的根/父 Maven pom.xml 开始

    请注意,您需要:

    • Maven 3 构建它,作为上述父 pom 文件的prerequisites
    • 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属性可以在eclipse.moxy.test模块的antbuild.properties文件中设置,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 的警告。

    【讨论】:

    • 我按照你写的做了,但我得到了[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.23.0:compile (default-compile) on project org.eclipse.persistence.nosql: Compilation failure: Compilation failure: [java] [ERROR] /home/TEMP/eclipselink.runtime-master/foundation/org.eclipse.persistence.nosql/src/org/eclipse/persistence/eis/adapters/jms/JMSEISConnectionSpec.java:[1]
    • @JimJim2000 我构建成功了,虽然只是注意到一些关于 Mockito 的编译错误,我会相应地更新答案。不过nosql模块构建成功,编译错误并没有影响最终的构建结果,我会进一步调查
    【解决方案2】:

    您可以使用this guide 来构建EclipseLink。

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

    【讨论】:

      【解决方案3】:

      我在一个项目中遇到了相同类型的问题。有一个父项目。还有另一个项目。但它们是相互依赖的。下面给出了我必须做的使它可运行的操作。

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

      另一件事:

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

      【讨论】:

      • 为什么你认为最低要求是 Java 8?根据 Eclipselink 文档,它是 JDK 1.6.0 或更高版本:@987654321 @
      • 我的错,在使用 JDK 1.7 进一步测试 eclipselink xjc 时,我得到一个 org/eclipse/persistence/jaxb/xjc/MOXyXJC : Unsupported major.minor version 52.0 错误 -那个“官方”文件一定是不正确的。它在更改 JAVA_HOME env var 以指向 JDK 1.8 后工作。
      猜你喜欢
      • 2017-08-26
      • 2018-02-02
      • 2022-11-11
      • 1970-01-01
      • 2021-11-07
      • 1970-01-01
      • 2019-12-14
      • 1970-01-01
      相关资源
      最近更新 更多