1

I'm new to Java and Maven, so the premise of the question may be a little shaky. I'm working on a complicated Java project that uses Maven, and IntelliJ is my IDE. To build the entire project, it takes like 25 minutes (yes, it's big). What I really want to know is.. if I change code in Module A, what other modules in my project depend on Module A such that, after mvn clean install'ing Module A, I would also need to recompile those other modules that depend on Module A. Basically, I don't want to have to spend 25 minutes rebuilding the entire project every time I make a small code change because I don't understand the dependency structure.

Is this making sense? I can look in the Project Structure dialog in IntelliJ and it'll tell me what Module A depends on, but I want to know what depends on Module A. So the reverse, I think.

Any help is appreciated. Thanks.

Matt
  • 23,363
  • 39
  • 111
  • 152
  • 1
    Have you tried scaling it down (as opposed to building the whole project) then trying to call mvn clean install and comparing times? I agree that 25 minutes is too much but trying the same concept with a program that runs in 2 minutes and seeing might be better if that makes sense – Salman Salman Jul 29 '16 at 15:27
  • 2
    Sounds like you are looking for the the `-amd` switch http://stackoverflow.com/questions/25480598/how-to-build-dependent-project-when-building-a-module-in-maven, i.e. you would run `mvn clean install -pl moduleA -amd` from the parent. You may also want `-am` which would include the modules `moduleA` depends on. – Tunaki Jul 29 '16 at 15:27
  • I would agree trying to break down the projects is a good way to go in future. To get a project map, open the Maven projects tool window and select your project in the list, right mouse click and select show dependencies. Not sure how long this will take, but it will eventually show a module diagram. – PeterS Jul 29 '16 at 15:31
  • If you're brave you can build with `-DskipTests` to speed it up. I've never tried `-amd` switch but it sounds promising, as Tunaki suggested, can you try that? Otherwise `mvn dependency:tree` can always help you visualise the dependencies. – vikingsteve Jul 29 '16 at 15:52
  • Thanks all. The -amd switch is new to me. I'll check it out. @vikingsteve: the 25 minutes is actually with the -DskipTests flag. Crazy. – Matt Jul 29 '16 at 19:21
  • @PeterS: Your suggestion will show me what Module A depends on, if that's what I right-click. What I want to know is what depends on Module A, so the opposite. Is there a way to show that? – Matt Jul 29 '16 at 19:22
  • I tend to just try and remember the dependencies in this situation after checking them once. But if you are just developing locally you could use something like jrebel? – vikingsteve Jul 29 '16 at 19:35
  • @MattPowell no there isn't really, As there could be infinite number of projects referring to Module A. Not sure how your overall project is laid out, if you have an overall aggregator or parent project then this would shown how many times this is referred to. Therefore, if you have such a parent project, right mouse click on that and then you can find the referrences to module A. – PeterS Aug 01 '16 at 08:45
  • @MattPowell You are probably beginning to see that the best way is to have separate projects for each module and store those artefacts in something like Nexus. Therefore when you build the large project you don't need to build each individual jar and you will just collate the latest artefacts out of Nexus. – PeterS Aug 01 '16 at 08:46
  • https://youtrack.jetbrains.com/issue/IDEA-173643 –  May 30 '17 at 15:20

0 Answers0