17

Jdk : JAVA 11

Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.2:descriptor (default-descriptor) on project buildtools: Execution default-descriptor of goal org.apache.maven.plugins:maven-plugin-plugin:3.2:descriptor failed: Index 22273 out of bounds for length 88 -> [Help 1]

<artifactId>buildtools</artifactId>
<packaging>maven-plugin</packaging>
<name>MYPojo</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<executions>
<execution>
<id>mojo-descriptor</id>
<phase>process-classes</phase>
<goals>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>


<!-- for maven plugin -->
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.6.3</version>
</dependency>
<!-- dependencies to annotations -->
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>3.0-alpha-2</version>
</dependency>
Gurjar Manahar
  • 181
  • 1
  • 4
  • Keep the maven-plugin-annotation and maven-plugin-plugin with the same version furthermore which Maven version do you use? Furthermore you you keep maven-artifact, maven-project, maven-core and maven-plugin-api having the same version. Do you have an example project on Github? – khmarbaise Mar 26 '20 at 20:10

3 Answers3

16

On my side, I solved it in java 11 by adding:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-plugin-plugin</artifactId>
    <version>3.6.0</version>
    <executions>
      <execution>
        <id>default-descriptor</id>
        <phase>process-classes</phase>
      </execution>
      <!-- if you want to generate help goal -->
      <execution>
        <id>help-goal</id>
        <goals>
          <goal>helpmojo</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
Silleto
  • 161
  • 3
9

For JDK11 (JDK8 respectively) support there is a bug in version 3.0,3.1,3.2. You must use 3.3 or later:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-plugin-plugin</artifactId>
                <version>3.3</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
Grim
  • 1,938
  • 10
  • 56
  • 123
  • 2
    This solved the issue for me when using JDK 8 and using lambdas in my code - just adding this plugin. I followed tutorials for a "hello world" plugin, none mentioned this plugin at all... – Comnir Aug 06 '22 at 13:24
  • As of 2022, version **3.6.4** is working like a charm – ATorras Nov 13 '22 at 01:26
  • version *3.6.4* works with JDK 8 and JDK 11. Tested with Kotlin 1.7.21 – user3599894 Dec 20 '22 at 12:19
2

I got the same problem and fixed it by not definig a newer Java Release but using Java 8:

<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Itchy
  • 2,263
  • 28
  • 41