0

I have a problem running unit test of a maven project.

The project used to be one pom. I split it up into three poms.

My maven is like this. There are three of these poms which looks all like this.

<?xml version="1.0" encoding="UTF-8"?>
<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>com.mycompany</groupId>
<artifactId>client</artifactId>
<version>1.0</version>

<parent>
    <groupId>com.mycompany</groupId>
    <artifactId>base-pom</artifactId>
    <relativePath>../../build/shared/pom.xml</relativePath>
    <version>1.0</version>
</parent>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12</version>
            <configuration>
                <includes>
                    <include>**/*Test.java</include>
                </includes>
                <forkMode>never</forkMode>
                <useFile>false</useFile>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
   ....
</dependencies>

The top level pom is:

<groupId>com.mycompany</groupId>
<artifactId>project</artifactId>
<version>1.0</version>
<packaging>pom</packaging>

<modules>
    <module>modules/shared</module>
    <module>modules/client</module>
    <module>modules/adapter</module>
</modules>

The parent POM, which is shared by all the modules are:

<groupId>com.mycompany</groupId>
<artifactId>base-pom</artifactId>
<version>1.0</version>
<packaging>pom</packaging>

<parent>
    <groupId>com.mycompany</groupId>
    <artifactId>mycompany-parent</artifactId>
    <version>1.0.8</version>
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.sourceEncoding>UTF-8</project.reporting.sourceEncoding>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencyManagement>
  ...
</dependencyManagement>

It uses to work when there is just one POM. What is the problem of this?

Many thanks

Guillaume Polet
  • 47,259
  • 4
  • 83
  • 117
Kevin
  • 5,972
  • 17
  • 63
  • 87

1 Answers1

0

I would recommend to restructure your projects structure to represent the real layout of the project. I can recommend to reading this entry here on SO

Community
  • 1
  • 1
khmarbaise
  • 92,914
  • 28
  • 189
  • 235