Kotlin Multi-Module Project Dependency not resolved in test life cycle

Project structure: Pure Kotlin as an application for several maven modules

kotlinspringboot (root module)

  • api

  • integration tests

Problem: When I started

$ cd ./kotlingspringboot/integration-tests/
$ mvn test

or

$ cd ./kotlingspringboot/integration-tests/
$ mvn kotlin:test-compile

I get the following compilation error regarding an unresolved reference for a class from the api module:

[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.2.21:test-compile (test-compile) on project hello-integration-tests: Compilation failure: Compilation failure:
[ERROR] C:\workspace\kotlinspringboot\integration-tests\src\test\kotlin\org\ildar\hello\integration\HelloEndpointTests.kt:[6,18] Unresolved reference: SpringKotlinHelloWorldApplication

Note. I ran mvn clean install earlier and verified that the .m2 cache contains a valid api jar module.

api (submodule) pom.xml

    ....
    <parent>
        <artifactId>kotlin-spring-boot</artifactId>
        <groupId>org.ildar</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>hello-api</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
  ....

integration tests (submodule) pom.xml

<parent>
    <artifactId>kotlin-spring-boot</artifactId>
    <groupId>org.ildar</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>hello-integration-tests</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
    <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
    <plugins>
        <plugin>
            <artifactId>kotlin-maven-plugin</artifactId>
            <groupId>org.jetbrains.kotlin</groupId>
            <version>${kotlin.version}</version>
            <executions>
                <execution>
                    <id>compile</id>
                    <goals> <goal>compile</goal> </goals>
                </execution>

                <execution>
                    <id>test-compile</id>
                    <goals> <goal>test-compile</goal> </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Link to the project on github: https://github.com/IldarGalikov/kotlinspringboot

+6
source share
2

Spring API-. jar BOOT-INF/classes . kotlin jar BOOT-INF. API.

Damien , Spring , . api/pom.xml, , :

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <layout>MODULE</layout>
    </configuration>
</plugin>
+2

Spring "MODULE" Spring Boot 2.0, maven ENUM LayoutType Christophs.

: https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/repackage-classifier.html.

, spring-boot-maven-plugin:

<executions>
  <execution>
    <id>repackage</id>
    <configuration>
      <classifier>exec</classifier>
    </configuration>
  </execution>
</executions>
0

All Articles