I have multi-module maven projects such as proj-a, proj-b, proj-c. Among these projects, there is a project named assemler which basically creates a zip file for all the jar files generated by the pom of multi module project. The assembler project uses maven-assembly-plugin for preparing the zip file. My problem is that the pom file of the multi module project does not fail on compilation error. Subsequently, assembler pom creates the zip file regardless there is compilation error or not. How can I stop the assembler project to create the zip file if there is a compilation error?
Here is the pom.xml of the multi module project
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>com.my.projects</groupId>
<artifactId>packer</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<modules>
<module>../../com.proj-a</module>
<module>../../com.proj-b</module>
<module>../../com.proj-c</module>
...........
<!-- assembling all jars -->
<module>./assembler</module>
</modules>
the pom.xml of assembler is
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>com.my.projects</groupId>
<artifactId>assembler</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>com.my.projects</groupId>
<artifactId>com.proj-a</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.my.projects</groupId>
<artifactId>com.proj-b</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.my.projects</groupId>
<artifactId>com.proj-c</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-bundles</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>release-all-for-test</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>/src/resources/assembly-descriptor.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And the assembly-descriptor.xml is
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>dist-assembly</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<useTransitiveDependencies>false</useTransitiveDependencies>
<outputDirectory>/out-put/WEB-INF/lib</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<unpack>false</unpack>
</dependencySet>
</dependencySets>
</assembly>
Check the maven-compiler-plugin configuration in the modules proj-a, proj-b, proj-c and also their parent modules. The plugin might have been configured not to fail on compilation errors. It usually should fail on compilation errors. The plugin's option is called failOnError. https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#failOnError