Multiple Java Projects and Refactoring

I recently joined a project that uses several different projects. Many of these projects depend on each other, using JAR files of another project included in the library, so at any time when you change one project, you need to know which other project uses it and update it. I would like to make it a lot easier and thought about merging all this java code into one project in separate packages. Is it possible to do this, and then deploy only some of the packages in the bank. I would like not to deploy only part of it, but was hacked, if possible.

Is there a better way to handle this?

+4
source share
5 answers

Approach 1: Using Hudson

If you use a continuous integration server such as Hudson , you can set up / down projects (see Terminology ).

A project may have one or more downstream projects. Subordinate projects are added to the build queue if the current project is built successfully. You can configure it to add a downstream project to the call queue, even if the current project is unstable (disabled by default).

This means that if someone checks the code in one project, at least you will get an early warning if it breaks other assemblies.

Approach 2: Using Maven

If the projects are not too complicated, perhaps you can create a main project and create child modules of this project. However, distorting the design in the form Maven loves can be quite complicated.

+4
source

If you use Eclipse (or any decent IDE), you can simply make one project dependent on another and provide this aspect of the configuration in your SVN and accept the checks in build scripts.

Note that if one project depends on a specific version of another project, a jar file is a much simpler way to manage this. Basic refactoring can immediately mean a lot of work in all other projects in order to rectify the situation, while you could just put a new bank in each project as needed and complete the migration.

+3
source

I think that probably everything depends on the specific project, but I think that I will keep all the projects separately. This will help maintain the integrity of the entire system. You can use a tool like maven to manage all dependencies between projects. Dependency management, like this, is one of the main benefits of maven.

+2
source

Using Ant as a build tool, you can put your project in any way you want. However, leaving parts of your code from the distribution, it looks like it will be error prone; you may accidentally leave the necessary classes (presumably all your classes are necessary).

Regarding saving code in different projects, I have a free guide. Store code that changes together in one project and packs it into your own jar file. This works best when some of your codes can be broken down into utility libraries that change less frequently than your main application.

For example, you might have an application in which you created web service client classes from the WSDL web service (using something like the Axis library). The web service interface is likely to change infrequently, so you do not want the regeneration step to be constantly repeated in your main application assembly. Create a separate project for this part so that you only need to recreate the web service client classes when changing the WSDL. Create a separate jar and use it in your main application. This style also allows other projects to reuse these utility modules.

When doing this style, you must put the version number in the jar manifest so that you can keep track of which applications use which versions of your module. Depending on how much you want to do this, you can also save a text file in a bank that details the changes that have occurred for each revision (like an open source library).

+1
source

All this is possible (we had the same situation a few years ago). How difficult or easy it will be depends on your IDE (refactoring, merging, organizing a new project) and you create a tool (deployment). We used IDEA as an IDE and Ant as a build tool, and it was not too complicated. One Sunday (no one works + commits), 2 people on one computer.

I'm not sure what you mean by

"deploy only some of the packages in the bank"

I think you will need all of them at work, right? As I understand it, they depend on each other.

0
source

All Articles