Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6930

Cannot use lambda as argument in a method in Mojo

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 3.6.0
    • None
    • Plugin API
    • None

    Description

      I have a plugin with uses a component that receives a lambda as argument.

      When passing any lamba, for example the following empty one

       

       
      Optional<File> sourceDir = new SourceDirectoryLocator(sourceDirectory, project.getBasedir(), file -> {})
       .find();
      

       

       `maven-plugin-plugin` fails with the error:

       

       
      [ERROR] Failed to execute goal org.codehaus.plexus:plexus-component-metadata:1.5.5:generate-metadata (default) on project asciidoctor-maven-plugin: Error generating metadata: : Failed to extract descriptors: Index 9578 out of bounds for length 999 -> [Help 1]
      
      org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.plexus:plexus-component-metadata:1.5.5:generate-metadata (default) on project asciidoctor-maven-plugin: Error generating metadata: 
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
       
      

       

       

      Passing `null` or an anonymous class like shown below works however.

       

       
      Optional<File> sourceDir = new SourceDirectoryLocator(sourceDirectory, project.getBasedir(),
      
       new Consumer<File>() {
       @Override
       public void accept(File file) {
       getLog().info("sourceDirectory " + file + " does not exist");
       }
       })
       .find();
       
      

       

       

      Also tested with the current SNAPSHOT and the issue still happens

      Here is the code to reprodude: https://github.com/abelsromero/asciidoctor-maven-plugin/tree/maven-plugin-plugin-lambda-issue . Just run `mvn clean test-compile` to see the error.

      Attachments

        Activity

          People

            Unassigned Unassigned
            Abel S.Romero Abel Salgado Romero
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: