best targets for maven build step? better to have step per child project or not?

 It seems the default maven build step targets are "clean test"

But I don't understand that, since the cleaning of the directory is apparently taken care of by other build configuration (so why "clean").

And we might not always want tests to run.

And if we don't have an "package" target, how will it find artifacts to push?

 Second question - when i have a typical java product with a dozen or so child projects (some jar artifacts, some tar.gz artifacts), it seems it could be done either of these ways:

- have a single maven build step that executes the top-level parent pom (and then it will build all child modules) 

- or have separately defined build steps, one per child project

Are there any pros/cons to doing it one way or the other?

0
1 comment

Hi,

regarding your maven targets question:
1) We need to provide a sane default value. "clean test" ensures that the folder doesn't contain previous information from previous builds (not all builds take care of it), and builds and tests the product, which is basically the most common scenario for any build. Many builds don't create packages and thus have no artifacts to push, so we would be providing a default that fails in many instances. That's why "clean test" is the default. If you are interested in other goals, of course feel free to run them, the default is just the default, not the mandatory value.

2) Yes, there are pros and cons, and they depend on your project. I cannot list all of them because they are many, but some basic that come to mind:

-Having multiple build configurations for each part of the subproject allows reusing those artifacts in different builds directly from within teamcity, independently of them being run with maven, scripts or download them separately.

-Having multiple build configurations allows you to have more granular control and overview over which parts of the build work and which parts fail without having to dig into the logs.

-Having multiple build configurations allows you to parallelize different subtasks that can be run simultaneously on different build agents. Running a single project can only run the maven process, which will at most parallelize the build among the CPU of the agent if it supports it and is configured to do it.

-Having a single configuration implies less maintenance overhead, as you only have to care of one build configuration instead of many.

-Having a single configuration will run a bit faster from not having to transfer the artifacts from one agent to the other.

0

Please sign in to leave a comment.