简体   繁体   English

ant如何拾取Java结果并将其用作属性值?

[英]How can ant pickup java result and use as property value?

I search many places still not able to find what I am looking for. 我搜索了许多仍然找不到我想要的地方。 not sure if this is possible or not. 不知道这是否可能。 While ant script is running the java code, the result should stay alive in jvm so how can I print it out at ant script side and not from java?? 当ant脚本运行Java代码时,结果应在jvm中保持有效,因此我如何在ant脚本端而不是从Java打印出来? because I want to use the result again at my other part of ant script. 因为我想在ant脚本的其他部分再次使用结果。

say, I after java method and I have 说,我在java方法之后,我有

String result= "appleResultString";
return result;

Is there a way in ant script can pick up the the result while in the same jvm 在同一个jvm中,ant脚本中是否有办法获取结果

<target name="test">
    <java classname="mytest" fork="true" >
    <classpath refid="classpath"/>
    <property="eat" value=${result}>
    </java>

<jmeter jmeterhome="homepath"
        testplan="name.jmx"
        resultlog="name.html">
  <jvmarg value="-Djavax.net.ssl.keyStore=pathToKey/>
  <jvmarg value="-Djavax.net.ssl.keyStorePassword= ${eat}/>
</jmeter>

    </target>

Thanks! 谢谢!

You can set a system property in your Java program, and Ant will capture it, but you must make sure you don't fork your <java> task. 您可以在Java程序中设置一个系统属性,Ant会捕获它,但是必须确保不要分叉 <java>任务。

Another possibility is to output the value, and capture that value in the outputproperty parameter of the <java> task. 另一种可能性是输出该值,并在<java>任务的outputproperty参数中捕获该值。 You already stated you can't use the return value. 您已经说过您不能使用返回值。

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

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