Question

I have a problem in one of my existing projects which I can't solve by myself.

My Workspace contains 2 Projects, the MainTool (Logger) I'm working on and a second Tool (XMLParser) which both need to be maintained, compiled and Run independently.

Project Logger: com.######.se.logger

Project XML: com.######.se.xml

Now comes the problem:

The XMLParser reads a file, and creates objects of type com.######.se.**LOGGER**.rvctesting.Node.

The LogTool takes these Nodes like this:

//This works cause I added XMLParser to BuildPath from Logger
XMLParser p = new XMLParser();
p.parseXML(path);
List<Node> list = p.getNodeList();

The problem is that I need either 2 times Node.java (in each Project one) or 2 times the Parser cause otherwise, I have a Cycle in my BuildPath. (Logger depends on XMLParser and XMLParser depends on the Node.java from com.######.se.logger.rvctesting)

But I want to avoid that since this would be pretty redundant and of course hard to maintain. Another solution would be to merge both Projects into one Project. But then its even more harder to maintain and both Projects aren't independent any more.

I know that this description isn't really imaginable. Does anyone have an idea how to change the Project-Setup so that it fits my requirements?

Was it helpful?

Solution

You could use interfaces for the classes in Logger and create a third project Logger-api where you can place them. Both of your projects should depend on that one. This way Logger can depend on XML and Logger-api and XML can depend on Logger-api only.

OTHER TIPS

The solution is to make a third - library - project on which both original projects depends and yields a jar to use.

A build infrastructure, like that of maven is ideal for such dependency management. Every IDE, also eclipse has plugins for a nice integration.

It makes code reuse fun.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top