问题描述
我创建了自己的build.xml,其中包含:
I created my own build.xml which has:
<target name="compile">
<mkdir dir="build"/>
<javac destdir="build">
<src path="src"/>
</javac>
</target>
<target name="build" depends="compile">
<mkdir dir="dist"/>
<jar destfile="dist/app.jar" basedir="build" />
</target>
<target name="run" depends="compile">
<java classname="webserver.Loader" classpath="build" fork="true" />
</target>
效果很好。当我调用ant run所以它编译并运行我的应用程序,但我的应用程序有一个带有图标的包,它没有移动到文件夹build,所以我的应用程序以一个例外结束,它无法找到我的图标。当我自己移动它然后它可以工作。
It works great. When I call ant run so it compiles and runs my application, but my application has a package with icons and it isn't moved to a folder "build" so my application ends with an exception that it couldn't locate my icons. When I move them by myself then it works.
我试图使用
<copy todir="build/app/icons">
<fileset dir="src/app/icons"/>
</copy>
它有效,但我想在没有复制命令的情况下这样做。 javac有参数吗?或其他什么?
It works, but I would like to do it without the copy command. Is there any parameter to javac? Or something else?
感谢您的回答。
推荐答案
对不起,您需要手动复制非Java文件。资源在技术上不是来源。命令行javac不会将资源文件从源目录复制到输出目录,ant的javac任务也不会。
Sorry, you will need to copy non-java files manually. Resources are technically not "source". The command-line javac will not copy resource files from your source directory to the output directory, neither will ant's javac task.
这篇关于Ant编译不会复制资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!