jeudi 17 novembre 2016

Maven integration-test doesn't find my class in same package structure

Here are my files:


Pom parent:

<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU"
    xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/HBk9RF">
    <modelVersion>4.0.0</modelVersion>
    <groupId>my.group</groupId>
    <artifactId>my.artifact.pom</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>my.artifact.ws</module>
    </modules>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.2.RELEASE</version>
    </parent>

    <properties>
        <!-- test -->
        <maven.test.failure.ignore>false</maven.test.failure.ignore>
    </properties>

    //lot of dependencies...

    <!-- PROFILES -->
    <profiles>
        <profile>
            <id>local</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
                <unit-tests.skip>false</unit-tests.skip>
                <integration-tests.skip>true</integration-tests.skip>
            </properties>
        </profile>
        <profile>
            <id>integration</id>
            <modules>
                <module>my-module-integration-test</module>
            </modules>
            <properties>
                <unit-tests.skip>true</unit-tests.skip>
                <integration-tests.skip>false</integration-tests.skip>
            </properties>
        </profile>
    </profiles>

    <!-- PLUGIN -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <configuration>
                    <encoding>${encoding}</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


Module-ws pom:

<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU" xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/HBk9RF">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>my.artifact.ws</artifactId>
    <packaging>jar</packaging>
    <parent>
        <groupId>my.group</groupId>
        <artifactId>my.artifact.pom</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    //lot of dependencies...

</project>


Integration-test pom:

<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU" xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/HBk9RF">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>my.artifact.integration.test</artifactId>
    <packaging>jar</packaging>

    <parent>
        <groupId>my.group</groupId>
        <artifactId>my.artifact.pom</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <properties>
        <unit-tests.skip>false</unit-tests.skip>
        <integration-tests.skip>true</integration-tests.skip>
    </properties>

    <dependencies>
        <dependency>
            <groupId>my.group</groupId>
            <artifactId>my.artifact.ws</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>


My folder structure:

my-module
|-- my-module-integration-test
|   `-- src
|       `-- test
|           `-- java
|               `-- my
|                   `-- module
|                       `-- ws
|                           `-- rest
|                               `-- MyTest
`-- my-module-ws
    `-- src
        `-- main
            `-- java
                `-- my
                    `-- module
                        `-- Application


When I run mvn clean install -P integration I receive the message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project mp-schedule-integration-test: Compilation failure: Compilation failure:
[ERROR] /Users/me/dev/my-module/my-module-integration-test/src/test/java/my/module/ws/rest/MyTest.java:[3,28] cannot find symbol
[ERROR] symbol:   class Application
[ERROR] location: package my.module

If I put the Application class inside test structure in my-module-integration-test it works (Go Horse)

Could someone help me?

Ps.: The name os modules and projects could be wrong just for hide the original names.

Aucun commentaire:

Enregistrer un commentaire