I have a Maven module named synapse.

main
  java
    package1
      A.java

test
  java
    common
      C.java
    package1
      ATest.java

Can someone let me know if in Maven I can create a non-executable jar
containing all non-test code (main/) and another test-jar containing only
the code under the package test/java/common?

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.

   - Maven Version - 3.8.4
   - Java 17

Reply via email to