https://kotlinlang.org logo
Title
ł

Łukasz Patro

05/11/2020, 9:59 AM
Hi, I could not build Kotlin project using Maven and JDK 6:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.635s
[INFO] Finished at: Mon May 11 11:52:50 CEST 2020
[INFO] Final Memory: 7M/231M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.3.72:compile (compile) on project untitled: Execution compile of goal org.jetbrains.kotlin:kotlin-maven-plugin:1.3.72:compile failed: Unable to load the mojo 'compile' in the plugin 'org.jetbrains.kotlin:kotlin-maven-plugin:1.3.72' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/jetbrains/kotlin/maven/K2JVMCompileMojo : Unsupported major.minor version 52.0
It builds fine with JDK 8.
pom.xml
is very simple:
<?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/maven-v4_0_0.xsd>">

    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>untitled</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>org.example untitled</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <kotlin.version>1.3.72</kotlin.version>
        <kotlin.code.style>official</kotlin.code.style>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src/main/kotlin</sourceDirectory>
        <testSourceDirectory>src/test/kotlin</testSourceDirectory>

        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
It seems that
kotlin-maven-plugin
do not support Java before version 8...
a

alex j

05/11/2020, 4:05 PM
java 6 is quite old as you know. are you forced to use java 6?
ł

Łukasz Patro

05/11/2020, 7:36 PM
unfortunately I am 😞 the plan was to write system tests in a modern language and then start to migrate application. my teammates said that building application using newer Java/Maven cause code generators to generate slightly different SOAP WSLDs (which is unacceptable in this case). I think it can't be detected without testing. the project is not big, but there are almost no tests and the code is smelly 😄
a

alex j

05/13/2020, 5:20 AM
it seems like someone had a similar issue with 1.6 not working https://stackoverflow.com/questions/44042285/how-can-i-use-kotlin-maven-plugin-under-jdk1-7
it's worth verifying yourself that a newer java version will indeed break the code generators. possibly there's a flag or annotation you can pass to get the desired backwards compatibility. bump the java version to 8 write an integration test to verify your wsdl stuff is correct. and if not, figure out what's wrong and see if you can fix it from there
👍 1
ł

Łukasz Patro

05/13/2020, 8:01 AM
I'll try that. The only problem in this approach is time 😄 Thank you:)