简体   繁体   English

Eclipse Ant类路径配置无用

[英]Eclipse Ant classpath configuration useless

A simple question for any Eclipse project using Ant. 对于使用Ant的任何Eclipse项目,这都是一个简单的问题。

In the Ant configuration for my project's build.xml (Right click on build.xml > Run as... > Ant build... ), in the Classpath tab, I add the JARs I need. 在项目的build.xml的Ant配置中(右键单击build.xml > Run as ... > Ant build ... ),在Classpath选项卡中,添加所需的JAR。 When executing the build, during the javac task, the JARs' classes and packages are not found. 执行构建时,在javac任务期间,找不到JAR的类和包。

Why? 为什么? Does javac only takes the classpath given by the task's <classpath> subelement? javac是否仅采用任务的<classpath>子元素给定的<classpath> Then what is the use of the Ant configuration classpath? 那么,Ant配置类路径的用途是什么?

The classpath selected in the "run as" section is the classpath available to Ant while Ant is running, NOT the classpath available to javac. 在“运行方式”部分中选择的类路径是Ant运行时可用于Ant的类路径,而不是javac可用的类路径。 This used to be included in the javac classpath in older versions of Ant, but is a bad practice that should be avoided. 在以前的Ant版本中,它曾经包含在javac类路径中,但是这是一种不良习惯,应该避免。 The purpose of having an Ant script is so you can have fine control over the classpath and reproduce your builds in other environments. 拥有Ant脚本的目的是使您可以更好地控制类路径,并在其他环境中重现您的构建。 Having the classpath set via "mystery" Eclipse settings is counter-productive to that goal. 通过“神秘” Eclipse设置来设置类路径会适得其反。

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

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