Home > Software engineering >  Maven compile, CircleCI build failing because of invalid target release 17
Maven compile, CircleCI build failing because of invalid target release 17

Time:03-25

Locally Maven builds everything fine but the CircleCI pipeline constantly fails. Here is my pom.xml:

<?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>at.jku</groupId>
    <artifactId>SmartRoom</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.3.3</version>
        </dependency>
    </dependencies>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

</project>

And my config.yml:

version: 2.1

orbs:
  maven: circleci/[email protected]

workflows:
  maven_test:
    jobs:
      - maven/test:
          command: '-X compile'

The error message I am getting in CircleCI:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project SmartRoom: Fatal error compiling: invalid target release: 17 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I already looked at the suggested article but it doesn't really tell me anything. I already tried switching target versions and also completely deleting the properties from the pom.xml.

CodePudding user response:

As pointed out in the comments, there were a few problems with my config.yml. First of all I was using an old version (0.0.12 instead of 1.3.0) and additionally I had to define the docker Java 17 image as an external executor to get everything working. My current and working config.yml:

version: 2.1
executors:
  java17:
    docker:
      - image: 'cimg/openjdk:17.0'
orbs:
  maven: circleci/[email protected]
workflows:
  maven_test:
    jobs:
      - maven/test:
          command: '-X compile'
          executor: java17
  • Related