简体   繁体   English

通过make调用ant命令

[英]invoking an ant command via make

I'm trying to do soemthing which may not be done that often. 我正在尝试做一些事情,这种事情可能不会经常做。 It's part of our test code which uses a wide variety tools: java, ant, make, and xml. 它是使用多种工具的测试代码的一部分:java,ant,make和xml。

Our java testing tool parses XML. 我们的java测试工具解析XML。 It gets an argument via an XML tag from a file: 它通过XML标记从文件获取参数:

<TAG>-Darg1="argument1" -Darg2="argument2"</TAG>

Within the java code, I'm calling the make command. 在Java代码中,我正在调用make命令。 The make command is invoked from java (via ProcessBuilder). make命令是从Java(通过ProcessBuilder)调用的。

In the makefile, I am calling ant where the -Darg="argument1" -Darg2="argument2" args should be passed. 在生成文件中,我在应传递-Darg="argument1" -Darg2="argument2" args的位置调用ant。

But it's not working. 但这不起作用。

Anyways, it seems that the -D from the -Darg1= ... part is not compatible with make, so I'm trying to enclose that in a variable that I can pass through make to ant. 无论如何,似乎-Darg1= ...部分中的-D与make不兼容,因此我试图将其包含在我可以通过make传递给ant的变量中。 Within ant it's taking the variable " RULES_ARG " and treating that as one argument, instead of two. 在ant中,它使用变量“ RULES_ARG ”并将其视为一个参数,而不是两个参数。

I've tried various quoting mechanisms in xml: "-Darg1=argument1 -Darg2=argument2", "-Darg1="argument1" -Darg2="argument2"" 我已经尝试了xml中的各种引用机制:“ -Darg1 = argument1 -Darg2 = argument2”,“ -Darg1 =” argument1“ -Darg2 =” argument2“”

and also where it's invoked in java: "RULES_ARGS="+RulesArgs+" ", "RULES_ARGS=\\""+RulesArgs+"\\" " (in combination with the xml part). 以及在Java中调用的位置: "RULES_ARGS="+RulesArgs+" ", "RULES_ARGS=\\""+RulesArgs+"\\" " (与xml部分结合使用)。

etc. all with no desirable result. 等等,都没有令人满意的结果。

I was wondering if anyone has tried to do something similar, and the working approach to the problem? 我想知道是否有人尝试做类似的事情,以及解决该问题的可行方法?

Thanks in advance. 提前致谢。

Are you saying you're trying to run make with -D options? 您是说要使用-D选项运行make吗? That won't work because make doesn't support -D . 那行不通,因为make不支持-D

If you're trying to pass some flags through the make command line to be used on the ant invocation, then you should do something like this: when you run make set a variable on the make command line: 如果您试图通过make命令行传递一些标志以用于ant调用,那么您应该执行以下操作:在make命令行上运行make set变量时:

make ANTFLAGS='-DFOO -DBAR -DBAZ'

Then inside your makefile, when you run ant, pass that variable: 然后在makefile中,当您运行ant时,传递该变量:

runant:
         ant $(ANTFLAGS) ...

If that's not what you're trying to do please clarify your question. 如果这不是您要尝试的操作,请澄清您的问题。 For example, you say it's not working and no desirable result , but you don't give any details about what errors or incorrect behavior you see. 例如,您说它不起作用并且没有令人满意的结果 ,但是您没有提供有关看到的错误或不正确行为的任何详细信息。 Such error messages would go a long way towards clarifying exactly what's going on. 这样的错误消息将有助于弄清楚到底发生了什么。

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

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