2

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"?>

4.0.0

<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>
tchristofferson
  • 183
  • 1
  • 1
  • 14

5 Answers5

8

I had to use this before I could use 3.3.0-SNAPSHOT

<pluginRepositories>
    <pluginRepository>
        <id>maven-snapshots</id>
        <url>https://repository.apache.org/content/repositories/snapshots/</url>
    </pluginRepository>
</pluginRepositories>
Rocologo
  • 574
  • 5
  • 11
7

@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.

tchristofferson
  • 183
  • 1
  • 1
  • 14
1

To elaborate on the answer @tchristofferson has given, I got it working by setting snapshots to true in my pluginRepository:

<pluginRepositories>
    <pluginRepository>
        <releases>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>central</id>
        <name>Maven Plugin Repository</name>
        <url>http://repo1.maven.org/maven2</url>
    </pluginRepository>
</pluginRepositories>

If you don't have the above in your pom.xml, just add it somewhere within <project></project>. And then change the version of the maven-shade-plugin to this:

<version>3.3.0-SNAPSHOT</version>
Noniq
  • 369
  • 1
  • 5
  • 13
0

In my case, the latest version of maven was installed on my machine, and code was intended for the java 11 version. So I have used an older version of maven and the error didn't appear.

Sarvar Nishonboyev
  • 12,262
  • 10
  • 69
  • 70
0

FWIW...

You could also override the version of ASM, in order to make this work with maven-shade-plugin 3.2.x, like so:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>3.2.4</version>
  <dependencies>
    <dependency>
      <groupId>org.ow2.asm</groupId>
      <artifactId>asm</artifactId>
      <version>9.2</version>
    </dependency>
    <dependency>
      <groupId>org.ow2.asm</groupId>
      <artifactId>asm-commons</artifactId>
      <version>9.2</version>
    </dependency>
  </dependencies>
  ...
</plugin>

References: https://issues.apache.org/jira/browse/MSHADE-407

Kenneth
  • 98
  • 1
  • 2