简体   繁体   English

Netbeans中的Ant:覆盖运行目标不起作用

[英]Ant in Netbeans: overriding run target doesn't work

I am trying to override the "run" target in a Netbeans project. 我试图覆盖Netbeans项目中的“运行”目标。 What I'm doing is editing the file build.xml : 我正在做的是编辑文件build.xml

<project name="Test123" default="default" basedir=".">
    <import file="nbproject/build-impl.xml"/>

    <target depends="init,compile" name="run">
        <echo>AAAAAAAAAAAAAAAAAAAAAA</echo>
    </target>
    <target depends="init,compile-single" name="run-single">
        <echo>AAAAAAAAAAAAAAAAAAAAAA</echo>
    </target>
</project>

I tried to override both "run" and "run-single", but both things doesn't change anything. 我试图覆盖“ run”和“ run-single”,但两者都没有改变。 When pressing F6 , the project's Main class is executed as before. F6 ,将像以前一样执行项目的Main类。 The test message ( AAA... ) is not printed. 测试消息( AAA... )未打印。

EDIT: 编辑:
Created a bug report for Netbeans. 为Netbeans创建了一个错误报告

如我的错误报告的答案所述,解决方案是关闭保存时编译。

That seems to be correct. 这似乎是正确的。 Do not use F6, try to run the "run" target from the context menu on the build.xml file. 不要使用F6,请尝试从build.xml文件的上下文菜单中运行“运行”目标。 That should work. 那应该工作。

I think the default key binding for F6 is "Run Main Project" and that does not the same as "run". 我认为F6的默认键绑定是“运行主项目”,与“运行”不同。

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

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