javamavencompiler-errorsmaven-plugin

Maven compiler plugin Unsupported class file major version 60


I am updating a Spigot (Minecraft) plugin and the newest version of Spigot requires Java 16. In my pom I changed the maven compiler plugin target to 16 and the source is still 1.8. Now I am getting the following errors:

Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade (default) on project Plugin: Error creating shaded jar: Problem shading JAR C:\Users\Trent\workspace\Stocks\Plugin\target\Plugin-1.0-SNAPSHOT.jar entry com/tchristofferson/stocks/commands/StockbrokerCommand.class: java.lang.IllegalArgumentException: Unsupported class file major version 60

pom:

<?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>com.tchristofferson</groupId>
  <artifactId>Stocks</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>

  <modules>
    <module>API</module>
    <module>Plugin</module>
  </modules>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <source>1.8</source>
          <target>16</target>
          <release>16</release>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

</project>

Solution

  • @wemu was correct that the maven shade plugin doesn't yet support Java 16. To solve the issue I had to use a snapshot version of the maven shade plugin (3.3.0-SNAPSHOT) since 3.2.4 doesn't support Java 16 yet.