As suggested the below config is working fine <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.3.0</version> <executions> <execution> <goals> <goal>test-jar</goal> </goals> <configuration> <includes> <include>common/**</include> </includes> </configuration> </execution> </executions> </plugin> </plugins>
But I am still facing issues in the below case. Let's say I have a module agent which depends on synapse and its test-jar. <dependency> <groupId>com.sp</groupId> <artifactId>synapse</artifactId> <version>0.0.1-SNAPSHOT</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.spotnana</groupId> <artifactId>synapse</artifactId> <version>0.0.1-SNAPSHOT</version> <classifier>tests</classifier> <type>test-jar</type> <scope>test</scope> </dependency> Now if I am trying to do mvn package --projects=:agent -T 2 --also-make I am getting NoClassDefFound for common/C.java while tests are being executed in the agent module. To get around this I had to do 1. mvn package --projects=:agent,:synapse -T 2 --also-make 2. and remove the configuration.includes section in test-jar execution goal Is this the expected behaviour with --also-make? On Fri, Mar 22, 2024 at 4:34 PM Stanimir Stamenkov <s7a...@netscape.net.invalid> wrote: > See my reply below the quote... > > Fri, 22 Mar 2024, /Debraj Manna/: > > > [...] > > I tried the below > > > > <build> > > <plugins> > > <plugin> > > <groupId>org.springframework.boot</groupId> > > <artifactId>spring-boot-maven-plugin</artifactId> > > <configuration> > > <skip>true</skip> > > </configuration> > > </plugin> > > <plugin> > > <groupId>org.apache.maven.plugins</groupId> > > <artifactId>maven-jar-plugin</artifactId> > > <version>3.3.0</version> > > <configuration> > > <includes> > > <include>common/**</include> > > </includes> > > </configuration> > > <executions> > > <execution> > > <goals> > > <goal>test-jar</goal> > > </goals> > > </execution> > > </executions> > > </plugin> > > </plugin> > > </plugins></build> > > > > I am observing that the test-jar is getting created as expected > containing > > only the code from test/java/common but the non-executable, non-test jar > > does not contain the code from main/java/package1. > > The easiest way is probably what Gary Gregory has suggested – extract > the common code in its own module. > > Your main JAR is likely missing classes as you've applied <includes> > configuration globally to the maven-jar-plugin, and not just to the > "test-jar" execution: > > <executions> > <execution> > <goals> > <goal>test-jar</goal> > </goals> > <configuration> > <includes> > <include>common/**</include> > </includes> > </configuration> > </execution> > </executions> > > You may wish to give the execution a non-default ID, and produce > additional JAR with a different classifier: > > <executions> > <execution> > <id>common-test-jar</id> > <goals> > <goal>test-jar</goal> > </goals> > <configuration> > <classifier>tests-common</classifier> > <includes> > <include>common/**</include> > </includes> > </configuration> > </execution> > </executions> > > You'll then use the given classifier when specifying this JAR as a test > dependency to other modules. > > See also: "How to create an additional attached jar artifact from the > project" > < > https://maven.apache.org/plugins/maven-jar-plugin/examples/attached-jar.html > > > > -- > Stanimir > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org > For additional commands, e-mail: users-h...@maven.apache.org > >