Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a Maven module not export a jar?

Tags:

maven-2

I have a Maven build with three modules.

  • Module A exports a jar.
  • Module B depends on A and exports a jar.
  • Module C is a set of regression tests that depend on A and B.

The reason the regression tests aren't just part of module B is that they should be able to run against multiple versions of A and B to ensure backwards compatibility. I want to be able to run deploy from the top level build to create A.jar and B.jar, but not C.jar. Is this possible?

like image 465
Craig P. Motlin Avatar asked Feb 05 '10 23:02

Craig P. Motlin


People also ask

Does Maven need plugin jar?

The maven jar plugin provides the capability to build jars files, if you define that your project is packaged as a jar file, maven will call implicitely to this plugin. We don´t need to define it inside pom. xml it will be downloaded and executed when maven needs it.

Can two Maven modules depend on each other?

Because modules within a multi-module build can depend on each other, it is important that the reactor sorts all the projects in a way that guarantees any project is built before it is required. The following relationships are honoured when sorting projects: a project dependency on another module in the build.


4 Answers

<properties>
     <maven.deploy.skip>true</maven.deploy.skip>
</properties>

If you don't need to create a JAR at all, you might want to add two more properties:

<jar.skipIfEmpty>true</jar.skipIfEmpty>
<maven.install.skip>true</maven.install.skip>

Note that you still need maven.deploy.skip, otherwise the build will fail during deployment.

like image 105
Craig P. Motlin Avatar answered Oct 11 '22 09:10

Craig P. Motlin


The maven deploy plugin includes a skip options that prevents artifact deployment.

<plugin>
  <artifactId>maven-deploy-plugin</artifactId>
  <configuration>
      <skip>true</skip>
  </configuration>
</plugin>

You can try adding that to project C.

like image 28
sal Avatar answered Oct 11 '22 11:10

sal


Use below for module C:

<packaging>pom</packaging>
like image 37
Taylor Leese Avatar answered Oct 11 '22 09:10

Taylor Leese


Use a packaging of type pom for C and rebind all required plugins:

<project>
  ...
  <packaging>pom</packaging>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <executions>
          <execution>
            <id>test-compile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>process-test-resources</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testResources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <executions>
          <execution>
            <id>test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
    ...
  </build>
  ...
</project>
like image 29
Pascal Thivent Avatar answered Oct 11 '22 10:10

Pascal Thivent