Here is my aggregator pom (taking out other 67 modules) ------------------------------------------------------------
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>cnp</groupId> <artifactId>packaging-pom</artifactId> <version>1</version> <packaging>pom</packaging> <modules> <module>60000-demo-service/demo-service</module> <module>60002-service1/service1</module> <module>60003-service2/service2</module> </modules> <profiles> <profile> <id>consumer-pact-test</id> <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> <executions> <execution> <!-- This must match the maven execution ID defined in the build config to override--> <id>default-test</id> <phase>test</phase> <goals> <goal>test</goal> </goals> <configuration> <!-- Donot run any normal unit test --> <excludes> <exclude>**/Test*.java</exclude> <exclude>**/*Test.java</exclude> <exclude>**/*Tests.java</exclude> <exclude>**/*TestCase.java</exclude> </excludes> <!-- Only run consumer pact test--> <includes> <include>**/*CPT</include> </includes> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile> <profile> <id>provider-pact-test</id> <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> <executions> <execution> <!-- This must match the maven execution ID defined in the build config to override--> <id>default-test</id> <phase>test</phase> <goals> <goal>test</goal> </goals> <configuration> <!-- Donot run any normal unit test --> <excludes> <exclude>**/Test*.java</exclude> <exclude>**/*Test.java</exclude> <exclude>**/*Tests.java</exclude> <exclude>**/*TestCase.java</exclude> </excludes> </configuration> </execution> <execution> <phase>integration-test</phase> <goals> <goal>test</goal> </goals> <configuration> <excludes> <exclude>**/Test*</exclude> <exclude>**/*Test</exclude> <exclude>**/*Tests</exclude> <exclude>**/*TestCase</exclude> </excludes> <includes> <include>**/*PPT</include> </includes> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>3.0.0-M1</version> <configuration> <skip>true</skip> </configuration> <inherited>false</inherited> </plugin> <plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>4.1.17</version> <inherited>true</inherited> </plugin> </plugins> </build> </project> ------------------------------------------------------------ With this pom, if i run: mvn --activate-profiles provider-pact-test -Dpackbroker.scheme=http -Dpactbroker.host=localhost -Dpactbroker.port=9292 -Dpactbroker.auth.username=pact_workshop -Dpactbroker.auth.password=pact_workshop -Dpact.provider.version="7.0.36-$(git rev-parse --short HEAD)" -f all-modules-pom.xml verify then i see all the unit test (end with *Test) running: [image: image.png] If i run mvn --activate-profiles provider-pact-test -Dpackbroker.scheme=http -Dpactbroker.host=localhost -Dpactbroker.port=9292 -Dpactbroker.auth.username=pact_workshop -Dpactbroker.auth.password=pact_workshop -Dpact.provider.version="7.0.36-$(git rev-parse --short HEAD)" --projects cn:demo-service --also-make -f all-modules-pom.xml verify i see the unit tests ran and at the end, i got thiw warning [WARNING] The requested profile "provider-pact-test" could not be activated because it does not exist. this show that the profiles defined at aggregator are not passed down to the module. The only way i am able to make it work is to add the profiles to all the poms of the modules. On Wed, 28 Sept 2022 at 18:06, Delany <delany.middle...@gmail.com> wrote: > Shouldn't matter. Please give full pom. > Delany > > On Wed, 28 Sep 2022, 23:15 Thai Le, <lnthai2...@gmail.com> wrote: > > > Thanks for your input. That's the first thing I tried. Unfortunately, if > I > > do that none of the modules recognized the profiles. > > > > On Wed, Sep 28, 2022, 17:08 Delany <delany.middle...@gmail.com> wrote: > > > > > Why did you duplicate modules in the profiles? Just leave them under > > > project. > > > Delany > > > > > > > > > On Wed, 28 Sep 2022, 21:32 Thai Le, <lnthai2...@gmail.com> wrote: > > > > > > > Hello, > > > > > > > > I have an aggregator pom with 70 modules to be built. > > > > <project> > > > > <modelVersion>4.0.0</modelVersion> > > > > <groupId>company</groupId> > > > > <artifactId>packaging-pom</artifactId> > > > > <version>1</version> > > > > <packaging>pom</packaging> > > > > <modules> 70 modules listed here </modules> > > > > </project> > > > > Recently we are introducing pact testing into our build pipeline so I > > > made > > > > 2 profiles. One is for running pact consumer test which excludes all > > the > > > > unit tests ending with *Test and only includes the consumer test. The > > > other > > > > one is for running pact provider tests which excludes all unit tests > > and > > > > pact consumer tests so that only pact provider tests can run. The 2 > > > > profiles should be applied to all the 70 modules. One way to do that > is > > > to > > > > put the modules inside each profile thus the modules are duplicated. > > > > <project> > > > > <modelVersion>4.0.0</modelVersion> > > > > <groupId>company</groupId> > > > > <artifactId>packaging-pom</artifactId> > > > > <version>1</version> > > > > <packaging>pom</packaging> > > > > > > > > <profiles> > > > > <profile> > > > > <id>consumer-pact-test</id> > > > > *<modules> 70 modules listed here </modules>* > > > > <build>...</build> > > > > </profile> > > > > > > > > <profile> > > > > <id>provider-pact-test</id> > > > > *<modules> 70 modules listed here </modules>* > > > > <build>...</build> > > > > </profile> > > > > > > > > </profiles> > > > > </project> > > > > Imagine if I had to add 10 more profiles. Is there other ways to > share > > > the > > > > same modules between multiple profiles without duplicating them ? > > > > > > > > Regards > > > > > > > > Thai Le > > > > > > > > > > -- Where there is will, there is a way