【问题标题】:unalbe to create destination directory for ant target in eclipse无法在 Eclipse 中为 ant 目标创建目标目录
【发布时间】:2016-08-27 13:04:40
【问题描述】:

我正在学习 ant build-tool 并陷入第一次构建,我尽了最大努力,但无法找到如何动态创建目标文件夹的解决方案,因为我有以下 build.xml

<project name="Ant Demo" default="run">
    <target name="run" description="run method" depends="compile">
        <java classname="com.demo.HelloWorld">
            <classpath path="target" />
        </java>
        <echo>Run is complete</echo>
    </target>
    <target name="compile" description="target compile">
        <javac includeantruntime="false" srcdir="." destdir="target" />

    </target>
</project>

其实我关注的是一个turorial,据此目标目录应该会自动创建子文件夹但不工作,

edit我得到的输出是

compile:
run:
     [java] running tasks
     [echo] Run is complete
BUILD SUCCESSFUL
Total time: 359 milliseconds

但我看不到任何子文件夹作为目标文件夹的子目录

如何解决?

【问题讨论】:

    标签: java eclipse ant


    【解决方案1】:

    您的 ant 任务似乎按预期运行,因为您发布的 ant 日志中没有错误消息。 在target 目录中生成了您的类文件,但您看不到它们,因为 eclipse 不会自动刷新该文件夹。

    您可以通过right click 在目标文件夹上查看它们 > refresh

    或自动化

    右键单击build.xml(你的ant xml)>运行方式> Ant Build...>刷新选项卡>完成时刷新资源>包含所选资源的项目>应用

    或者,

    在你的 ant 构建文件中,添加

    <eclipse.refreshLocal resource="target" />
    

    行后

    <javac includeantruntime ...
    

    然后右键单击 build.xml(你的 ant xml)> Run as > Ant Build... > JRE tab > Run in the same jre as workspace > Apply

    【讨论】:

    • 感谢回复,现在我得到了目录结构,但我也需要在该结构中获取类文件(这是问题的最终目标),如果你不介意你能告诉我如何这样做(只是一个提示)
    猜你喜欢
    • 2020-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多