How can I run ANT from a batch file without having an Environment Variable set?

こ雲淡風輕ζ 提交于 2019-12-12 17:05:42

问题


I want to include ANT, the JavaSDK and FlexSDK into my project directory. I need people in my company to be able to compile from source code.

I have a build.bat file which starts with :

ant blah/blah/blah

But what if I want to run ANT directly without the system environment variable? If I remove these from the system ant is not recognised.

I am a real newbie here, but I want to do something like this:

start "${basedir}\libs\ant\bin" ant -lib ${basedir}/libs/ant/lib/flexTasks.jar
pause

This is so that other people dont need to install a whole load of software... IT would all be contained in the folder.


回答1:


Just set those environment variables in the same batchfile, i.e. something like :

set ANT_HOME=C:\ant182
set ANT_ARGS=-lib C:\antxtralibs
set JAVA_HOME=C:\jdk160_30
set PATH=%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin

:: default
ant -f %1

:: debug
:: ant -debug -f %1


来源:https://stackoverflow.com/questions/9284244/how-can-i-run-ant-from-a-batch-file-without-having-an-environment-variable-set

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!