En Eclipse, ¿cómo puedo mover archivos de proyecto sin dependencias en una biblioteca a un proyecto más abstracto?

I have two Eclipse projects: one that depends upon a certain library (android.jar) and one that is more abstract and doesn't contain that dependency.

I am in the process of migrating all classes that have sin dependencias on the package, in my case android.*, to the more abstract project. Is there a Eclipse feature that can help automate the move?

Ideally, there would be feature that directly lets you automatically search for and move files that can be relocated to a new project. It would find files that that are:

  • independent of a specified package (with wildcards)
  • independent of other files within the same project that are dependent on the same package (in other words, no indirect dependencies on the package)

preguntado el 10 de marzo de 12 a las 13:03

Is it a viable way of doing it? What if A doesn't depend on android, but depends on B which depends on android? -

Your edit indeed expresses the same concern as my comment. I don't think this is a task that can (or should) be automated. You should refactor based on the functionality that each class, set of classes, or package offers, and you might have to re-design the code to make android-dependent classes not dependent, but still usable in an android context (using interfaces, abstractions, strategies and other OO patterns). -

@JBNizet I'm confused why you wouldn't want to automate the task? Keeping these independent files in a separate project that is independent of android.jar would help provide a clear break from dependencies on Android. It would also ensure that dependencies don't accidentally leak back into the classes. Your ideas about creating new independent classes are perfectly valid and good, but I don't see how they relate to--or discourage the automated refactoring. This refactoring would help to automatically relocate files where the redesigns you suggested have already been performed. -

I'm not saying the refactoring shouldn't be done. What I'm saying is that it should probably be done manually, and think about the design while doing so. Suppose 100 classes all depend on class A, which has a tiny dependency on android. That makes these 100 classes ineligible for being moved. Maybe this class A should be manually refectored to eliminate the direct dependency to android (using a dependency to an android-independent interface rather than a concrete android implementation, for example). All those 100 classes would then be eligible for being moved. Doing so requires manual design. -

Still, I completely agree with your claims, however I don't understand how it makes the refactoring any less useful. If the goal is to eliminate as many dependencies as possible, once the already-independent classes have been identified and relocated, the developer can more clearly see the ones that require manual work to decouple the classes as you describe. Then, once that work has been done, the move can be automated again, and so on. -

1 Respuestas

envié un Solicitud de mejora de Eclipse para apoyar tal refactorización. Mientras tanto, encontré algunas herramientas prometedoras para ayudar con el análisis de desacoplamiento y dependencia.

  • eDepende es un complemento de visor de dependencias que incluye un diagrama de dependencia de clase/paquete que muestra las dependencias de los elementos, las relaciones con las bibliotecas/otros proyectos y los ciclos de dependencia. También puede enumerar las clases de búsqueda que causaron las dependencias.
  • STAN análisis de estructura para Java
  • n alambre
  • Analizador de dependencia de clases
  • Buscador de dependencias

Preguntas relacionadas: 1

contestado el 23 de mayo de 17 a las 13:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.