Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have a Maven project consists of around 100 modules. I have reason to decompose the project to so many modules, and I don't think I should merge them in order to speed up the build process.

I have read a lot of projects by other people, e.g., the Maven project itself, and Apache Archiva, and Hudson project, they all consists of a lot of modules, nearly 100 maybe, more or less.

The problem is, to build them all need so much time, 3 hours for the first time build (this is acceptable because a lot of artifacts to download), and 15 minutes for the second build (this is not acceptable).

For automake, things are similarly, the first time you need to configure the project, to prepare the magical config.h file, it's far more complex then what maven does. But it's still fast, maybe 10 seconds on my Debian box. After then, make install requires maybe 10 minutes for the first time build. However, when everything get prepared, the .o object files are generated, they don't have to be rebuild at all for the second time build. (In Maven, everything rebuild at everytime.)

I'm very wondering, how guys working for Maven projects can bare this long time for each build, I'm just can't sit down calmly during each time Maven build, it took too long time, really.

share|improve this question
2  
I think this is better suited to Stack Overflow. However, don't repost it can be migrated if there's agreement that it does belong there. –  ChrisF Mar 1 '11 at 11:45
    
Hmm.. one's written in C, the other in Java. Hmm.... (I keed I keed :P) –  Billy ONeal Mar 1 '11 at 16:10
    
What is the bottleneck on the computer. Java needs more resources than C. –  user1249 Jan 25 '12 at 9:02
    
Does the -o flag (which makes an offline build) speed up the process? –  user1249 Sep 13 '12 at 15:30
add comment

4 Answers

up vote 2 down vote accepted

What part of your maven build is taking the longest? You may find that javac is your main bottleneck. Perhaps it's the unit test execution, try running your tests in parallel. Without more details it's really hard to give a useful answer. How big are the projects?

Are the builds fairly parallelizable? If you are using maven 3 (or switch to it, it's 99% compatible with 2.x) you can run parallel builds.

I think your blame for maven is misplaced, as far as performance is concerned it really doesn't add much overhead. I've converted several large projects and seen the builds speed up considerably.

share|improve this answer
    
Well, I guess you may try to build the Hudson project, for several times. That will give you some impacts. –  Xiè Jìléi Mar 2 '11 at 1:44
    
I was started to use Maven 3, as early as it's announced. Maven is fast if the project doesn't have too many modules. For example, a single module with 10000 classes is faster then 10 modules within each 1000 classes –  Xiè Jìléi Mar 2 '11 at 1:46
add comment

This comparison is meaningful only if they are building exactly the same project. If not, maybe you should try building a Make file to build the same project that you are building with Maven.

share|improve this answer
    
Yes. I would say this is an example to explain why Java is still slow, while people today consider Java is fast enough. –  Xiè Jìléi Mar 2 '11 at 1:49
    
It's not Java that's the problem. It's Maven. The same stuff built with a custom ANT script will build much faster. –  Berin Loritsch Mar 2 '11 at 4:06
    
But not necessarily correctly. Neither ANT nor he Java compiler understand source code dependencies. Changes to X.java may require recompilation of Y.java, even if the source to Y was not changed and does not have to change. The program fails with a 'MethodNotFound' exception. Now the programmer has little choice but do a full rebuild. –  kevin cline Mar 3 '11 at 2:53
add comment

Are you comparing like cases. IE are the two building about the same amount of code.

If builds are much slower in Maven it may be maven but more probable is the compiler itself. (Maven does not compile anything it just launches the compiler)

To make it go faster try seeing if there is a way to run 2-4 threads at once, not sure how to do this in Maven but in Make it would be 'make -j 4'. After that more ram will help, as will a solid state disk.

share|improve this answer
add comment

Maven is a complicated beast, much more complicated than necessary for my tastes. The key issue you are experiencing seems to have to do with the clean rebuild every time. Your releases you want to be a clean rebuild to ensure it is as safe as possible. For your debug builds, you simply want to compile what has changed.

The Java compiler is smart enough not to recompile something if the timestamp hasn't changed (similar to how GCC works). Many times, in a multi-module Maven build it is required to build ALL dependencies every time. This page states that Maven cannot detect when no changes have been made to a module.

The bottom line is that you might have a more direct comparison between ANT and Make/automake--but not Maven. Maven has too many auto-magic gadgetry built in that you have only limited control over. It can't make the same informed decisions that you can about your project because it is trying to solve the build problem for all projects. Maven is probably closer to SCons or Boost Build. Although you'll probably find those two much quicker to execute than Maven.

share|improve this answer
    
In Make, the dependency unit is the file itself, while in Maven, the dependency unit is the project described by pom.xml. I think one shortage is, if main depends on foo, and foo depends on bar, in Make, you make main and then foo and bar are updated. But in Maven, the declared dependencies are not automatic rebuilt, you must rebuild foo and bar, and then you can make main. This is not necessary for jar packaging, however, for war packaging (war1), which depends on another war (war2), war2 must be clean rebuilt before build war1. –  Xiè Jìléi Mar 2 '11 at 2:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.