简体   繁体   English

是否可以从Ant中的命令行生成文件“ build.xml”?

[英]Is it possible to generate the file 'build.xml' from the command line in Ant?

I am looking to script my build process. 我正在为我的构建过程编写脚本。 Currently I am able to build the build.xml file manually, and then run the following command to create the JAR file: 当前,我能够手动构建build.xml文件,然后运行以下命令来创建JAR文件:

    system("ant -f ~/build.xml")

I would like to rebuild my build.xml file every time I run this script so that I ensure all changes are in the build.xml file. 我想每次运行此脚本时都重新build.xml文件,以确保所有更改都在build.xml文件中。 Is there an Ant command I can run to build this build.xml file? 我可以运行一个Ant命令来构建这个build.xml文件吗?

For reference, I am using IntelliJ IDEA currently to create my build.xml file. 作为参考,我目前正在使用IntelliJ IDEA创建我的build.xml文件。

There are other common ways to customize your build in Ant. 还有其他常见的方法可以在Ant中自定义构建。 Like: 喜欢:

  • Introducing properties (possibly excluded to the build.properties file) and 引入属性(可能不包含在build.properties文件中)和
  • regular expressions wherever feasible. 只要可行,就使用正则表达式

These should cover most of the use cases in Ant. 这些应该涵盖Ant中的大多数用例。

For the more sophisticated stuff, you can even go for more logic using ant-contrib tasks . 对于更复杂的内容,您甚至可以使用ant-contrib任务寻求更多的逻辑。

As an alternative: 作为备选:

  • If you'd still like to stick with generation of the custom build.xml file every time, you could go for some XSLT transformation where you would do so. 如果您仍然希望每次都生成定制的build.xml文件,则可以进行一些XSLT转换。 But that is not a common practice, I'd say. 我要说,但这不是一种普遍的做法。 Or 要么
  • go for Maven , as suggested in the comment or even 按照评论中的建议去Maven ,甚至
  • go for Grails Grails

However, to help you choose the fitting solution, you should tell us some more details on the build.xml changes you'd like to achieve. 但是,为了帮助您选择合适的解决方案,您应该告诉我们有关您想要实现的build.xml更改的更多详细信息。

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

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