Search code examples
javamavenintellij-ideateamcity

How to build a sub-module in IntelliJ's TeamCity via Maven?


I have a parent project which contains several sub modules created with Maven.

I need to run the sub modules one by one and then last one is report generator module in team city using Maven. How to do this?

The main project is aggregrator project contains sub modules which are automation testing and report generator project.

Report Generator project has no artifact dependency but it's has a dependency on the output report file generated from other submodules. The report module will grab the HTML report file from relative directory prior running the sub modules. Once the HTML report file is grabbed, it creates a .zip file that contains several reports which is sent out in a single shot.

I want to build a sub-module created with Maven in IntelliJ's TeamCity. How can we achieve that?


Solution

  • Steps to run the submodule in the IntellJ's teamcity with Maven:

    1. I assume there is a parent Maven project created/import already in the team city. For example: I imported a project with the name 'aggregator'.

    enter image description here

    1. Now I will create a submodule via teamcity. Click to Administration option on the top right hand corner beside the profile logo.

    enter image description here

    1. Click on Projects option on the left side and then click on the parent name to open the Project tab.

    enter image description here

    1. Scroll down at the end, you will find a subprojects tab. There will be + button to create new sub module within the parent project.

    enter image description here

    1. After clicking on + button, it will land you to the page where it will ask sub-module to create via repository url or manually.

    I will be doing it manually for now. I give the name of the sub module as 'report-generator'.

    enter image description here

    1. Click on the create button. It will create the sub-module successfully with the message.

    Project "Aggregator / report-generator" has been successfully created. You can now create a build configuration.

    enter image description here

    1. Now, you have to create build configuration. On the sub-module project page, you will find the tab there. Go there and click on the plus button.

    enter image description here

    1. Enter any name for the build configuration and click on the create.

    enter image description here

    1. Click on Attach existing VCS Root and select the parent module's one. Or you can create a new VCS root by clicking on Create new VCS Root.

    Now, as soon as you select this, the teamcity will auto-detect the presence of the build tools and setting that you are using for parent project and recommend it if you want to use it for sub-module also.

    In your case, you want to run the sub-module with maven. So, in that case, select Maven as build step.

    enter image description here

    1. Click on Use selected and you are done.

    enter image description here

    1. Click on Run to execute sub-module build and it will use Maven as build step from parent.

    enter image description here

    Successful Execution of the sub-module via Maven build step.

    enter image description here