简体   繁体   English

如何从同一Java项目的jar文件中运行ant命令?

[英]How to run ant commands from a jar file of the same Java project?

I have a java project with a build.xml file, and multiple ant commands. 我有一个带有build.xml文件和多个ant命令的java项目。 I can create a jar file of this project, but I want to be able to use the jar to run those other ant commands. 我可以创建该项目的jar文件,但是我希望能够使用jar运行那些其他ant命令。

Questions: 问题:

  1. Is this even possible? 这有可能吗?
  2. Would it be better to create an executable jar file for each of the ant commands I need to run? 为我需要运行的每个ant命令创建一个可执行的jar文件会更好吗?
  1. Yes. 是。 A Jar file is a Zip archive with the .jar extension and the file layout for a Java executable. Jar文件是Zip归档文件,具有.jar扩展名和Java可执行文件的文件布局。 Just unpack the Jar file, and do what you want with the contents. 只需解压缩Jar文件,然后对其中的内容进行操作即可。

  2. Probably. 大概。 Either one tool that accepts arguments to change its behaviour, or one per specific task. 一种工具可以接受参数以更改其行为,或者一种工具可以针对特定任务。 Use whichever approach makes the most sense for your project. 使用最适合您的项目的方法。

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

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