基于一个源文件的依赖关系创建一个Java Eclipse项目的子集 [英] Create a subset of a Java Eclipse project based on dependencies of one source file

查看:244
本文介绍了基于一个源文件的依赖关系创建一个Java Eclipse项目的子集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个库Eclipse项目/工作区,其中包含偶尔提供给客户的功能。我们都是研究人员,所以这非常非正式地完成;我使用文档制作一个JAR和一个Word文件,并将其发送给他们。



我更倾向于向他们发送一个仅包含实际需要的JAR文件,以简化的东西。如果他们需要X,Y,Z和W类,那么我发送一个包含X,Y,Z和W的JAR文件,以及所有依赖的类。



现在我以绝望的手动方式(我创建一个新项目,拖动X,Y,Z和W,然后拖动任何我需要修复编译器错误)。在Eclipse中自动化的方法是什么?



编辑:为了清楚,所涉及的Eclipse项目包含比客户实际需要的更多的类。 p>

编辑:另外没有反思;我可以确信编译器知道发生了什么。我是编写代码的人,我避免像瘟疫这样的反思。我唯一使用反射的地方是模仿Collections.toArray(),在这种情况下,唯一可能导致问题的类是用户提供的类。

解决方案

Byecycle,Eclipse插件将有所帮助,但已从Sourceforge中删除。没有得到彻底的自动化过程,而是在确定依赖性。我不知道是否可以让它在Ganymede / Galileo上工作,因为我已经使用了很长时间了。



更新



类依赖关系分析器工具可能会更有帮助,因为它附带了可以使用的插件扩展API来创建一个插件来完成您打算做的任务。



更新#2



如果您想知道Ant的用法,您可以使用ClassFileSet类型来获取一个类及其依赖关系列表。这可以在复制任务中引用以复制所需的类文件。请注意,这不会复制源文件。



在内部,此方法取决于 BCEL库,所以如果你想执行一个源的副本,你可以尝试编写代码来检查一个.class文件的依赖关系,并将这些源复制到另一个目录。 / p>

I have a library Eclipse project/workspace containing functionality that is occasionally delivered to a customer. We're all researchers so this is done very informally; I make a JAR and a Word file with documentation, and send it to them.

I prefer to send them a JAR file that only contains what they actually need, to simplify things. If they need classes X, Y, Z and W, then I send a JAR file containing X, Y, Z, and W, as well as all of the classes that those depend on.

Right now I am doing this in a hopelessly manual way (I create a new project, drag over X, Y, Z, and W, and then drag over anything I need to fix the compiler errors). What's the right way to automate it in Eclipse?

EDIT: Just to be clear, the Eclipse projects involved contain many more classes than are actually needed by the customer.

EDIT: Also, there is no reflection involved; I can be confident that the compiler knows what is going on. I'm the one who wrote the code, and I avoid reflection like the plague. The only place I used reflection is to imitate Collections.toArray(), and in that case the only class that could cause a problem is one that the user provided.

解决方案

Byecycle, an Eclipse plugin would help, but it has been removed from Sourceforge. Not in getting a thorough automated process, but in determining the dependencies. I'm not sure whether you can get it to work on Ganymede/Galileo, since I've used this a long time back.

Update

The Class Dependency Analyzer Tool might prove to be more helpful, since it comes with a plug-in extension API that could be used to create a plug-in to perform exactly the task that you intend to do.

Update #2

In case you were wondering about the usage of Ant, you can use the ClassFileSet type to obtain a class and its list of dependencies. This can be referenced inside a copy task to copy the required class files. Do note that this doesn't copy source files.

Internally, this method depends on the BCEL library, so if you wish to perform a copy of sources, you could attempt to write code to examine a .class file's dependencies, and copy the sources over to another directory.

这篇关于基于一个源文件的依赖关系创建一个Java Eclipse项目的子集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆