简体   繁体   English

在eclipse项目中为junit和source两个单独的JRE

[英]Two separate JREs for junit and source in eclipse project

Below is my project structure. 以下是我的项目结构。

-project
   -sources
       -my.package
             -MyClass.java
   -test
       -my.package
             -MyClassTest.java

I want to use JDK version less than 1.5 for my source. 我想使用低于1.5的JDK版本来源。

Where as my junit test classes needs latest JDK. 我的junit测试类需要最新的JDK。

Is there any possibility to use two different JDKs for same project. 有没有可能为同一个项目使用两个不同的JDK。

Current solution: I can configure latest JDK for the project and can compile using different targets one for source and one for test. javac -target.

Is that correct way to do? 这是正确的方法吗? or Please suggest any correct solution. 或建议任何正确的解决方案。

Thanks in advance. 提前致谢。

In an Ant build, you can freely specify different JDK and compiler settings for different source folders. 在Ant构建中,您可以为不同的源文件夹自由指定不同的JDK和编译器设置。

But for Eclipse compilation, I think you will be restricted to using one JDK and compiler settings per-project. 但是对于Eclipse编译,我认为您将被限制为每个项目使用一个JDK和编译器设置。 I don't think you can specify separate compiler per folder in an Eclipse project. 我不认为你可以在Eclipse项目中为每个文件夹指定单独的编译器。

Options: 选项:

  • Treat these folders as separate Eclipse projects. 将这些文件夹视为单独的Eclipse项目。 Or, 要么,

  • Implement Ant build for both folders, but Eclipse build only for one of them. 为两个文件夹实现Ant构建,但Eclipse仅针对其中一个构建。 For example, your junit classes would be built by Ant only. 例如,您的junit类只能由Ant构建。

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

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