[英]Ant: How to compile jar that includes source attachment
How do I create a jar with Ant that includes the source attachment? 如何使用包含源附件的Ant创建jar?
Maven does this, but I'm living maven-free since '03 (well, 2009, but it doesn't rhyme). Maven做到了这一点,但我从03年起就开始没有maven了(好吧,2009年,但它没有押韵)。
I can't see any options in the javac task which does this. 我无法在javac任务中看到任何选项。
I tried including the source .java files in the fileset passed to the javac task, but this didn't work. 我尝试将源.java文件包含在传递给javac任务的文件集中,但这不起作用。 When I try to view the source through something like Eclipse, I still get the 'no source attachment' display. 当我尝试通过Eclipse之类的东西查看源代码时,我仍然可以获得“无源附件”显示。
Any suggestions? 有什么建议?
You need two things to make it work in Eclipse: 你需要两件事才能让它在Eclipse中运行:
.java
file exists in the same folder in the JAR as the corresponding .class
file; 在文件集中包含源文件,以便每个.java
文件与相应的.class
文件存在于JAR中的同一文件夹中; <javac>
task, add the following parameter: debug="on"
. 在<javac>
任务中,添加以下参数: debug="on"
。 That way, you encode information into the .class
files about the corresponding .java
files that tools like Eclipse need in order to connect the two together. 这样,您就可以将信息编码到.class
文件中,这些文件与Eclipse之类的工具所需的相应.java
文件相关联,以便将两者连接在一起。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.