Home > Mobile >  Fatal error occurs when building library with jitpack
Fatal error occurs when building library with jitpack

Time:06-21

I'm trying to publish a library to jitpack and I'm repeatedly encountering this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project SimpleSQL: Fatal error compiling: invalid target release: 14

The the project uses maven, here is the 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>group.id</groupId>
    <artifactId>artifactId</artifactId>
    <version>0.1.7-ALPHA</version>
    <packaging>jar</packaging>

    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration> 
                    <source>14</source>
                    <target>14</target>
                </configuration>
            </plugin>

            <plugin>  <!-- Create sources.jar -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.29</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
        <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.36.0.3</version>
        </dependency>
        <!-- @Nonnull and @Nullable dependency -->
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <version>3.0.2</version>
        </dependency>
    </dependencies>

</project>

I've tried to use java 7 through 17 as the source and target and get the same error for all of them despite being able to build the library in my IDE, if you have any ideas about how I can fix this problem please reply.

CodePudding user response:

I found the answer, jitpack only uses java 8 so to fix the issue you need to add a file in the projects root called jitpack.yml and this file contains this:

jdk:
  - openjdk9
before_install:
  - sdk install java 18.0.1.1-open
  - sdk use java 18.0.1.1-open

This changes the java version, to see a full list of the versions available add the line: sdk list java to the before_install section.

  • Related