简体   繁体   English

用两个jdk版本编译Ant项目

[英]Compile Ant project with two jdk versions

I am working on Ant project.我正在从事 Ant 项目。 I am using GWT for client side.我在客户端使用 GWT。 Means both client side and Server-side code is written in java. But now we have to upgrade jdk version from jdk-1.8 to jdk-11 for hibernate upgradation.意味着客户端和服务器端代码都写在 java 中。但是现在我们必须将 jdk 版本从 jdk-1.8 升级到 jdk-11 以进行 hibernate 升级。 But jdk-11 does not support GWT or we don't want to upgrade GWT.但是jdk-11不支持GWT或者我们不想升级GWT。

Now I have to compile and build client-side code with jdk-1.8 and server-side code with jdk-11 with single command ie "ant war.all".现在我必须使用 jdk-1.8 编译和构建客户端代码,使用 jdk-11 编译和构建服务器端代码,使用单个命令即“ant war.all”。 Is it possible?可能吗? if yes then What will be the procedure for this?如果是,那么这将是什么程序?

I am using the below method to build both server- and client-side code with JAVA 8 while having default JDK set to JAVA 11. I'm not sure if it would work when compilation of server- and client-side code use different JDKs - give it a try.我正在使用以下方法使用 JAVA 8 构建服务器端和客户端代码,同时将默认 JDK 设置为 JAVA 11。我不确定当服务器端和客户端代码的编译使用不同的 JDK 时它是否有效- 试试看。


In Ant build.xml you have javac command to compile java source to bytecode.在 Ant build.xml ,您有javac命令将 java 源代码编译为字节码。 This is the server side.这是服务器端。

The javac command has fork and executable parameters which can be used to set the path to the external javac executable. javac命令具有forkexecutable参数,可用于设置外部 javac 可执行文件的路径。

fork: Whether to execute javac using the JDK compiler externally. fork:是否在外部使用JDK编译器执行javac。

executable: Complete path to the javac executable to use in case of fork is yes.可执行文件:在 fork 的情况下使用的 javac 可执行文件的完整路径是。

<javac
       fork="yes"
       executable="/path/to/javac"
       ...

For the client side the java command is used to execute GWT compiler.对于客户端, java命令用于执行 GWT 编译器。 The java command also has a fork parameter that triggers the class execution in another JVM (other than the one Ant is currently using), and a jvm parameter - the command used to invoke JVM. java命令还有一个fork参数,它会触发另一个 JVM 中的 class 执行(不同于 Ant 当前正在使用的那个),以及一个jvm参数——用于调用 JVM 的命令。

<java
      fork="true"
      jvm="/path/to/java"
      ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM