2016-03-06 80 views
0

我正在为Maven编写一个MojoHaus plugin的扩展。 我的项目是this GitHub repository使用maven-plugin-plugin使用help-mojo阶段编译Maven插件

当我尝试运行mvn clean install,编译失败,出现以下错误信息:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.4:helpmojo 
(help-mojo) on project yaml-properties-maven-plugin: Execution help-mojo of goal 
org.apache.maven.plugins:maven-plugin-plugin:3.4:helpmojo failed: syntax error @[11,22] in 
file:/home/user/workspace/yaml-properties-maven-plugin/src/main/java/org/codehaus/mojo/properties/ResourceType.java -> [Help 1] 

ResourceType样子:

package org.codehaus.mojo.properties; 


import java.util.HashSet; 
import java.util.Set; 

public enum ResourceType { 

    PROPERTIES(".properties"), 
    YAML(new String[]{".yml", ".yaml"}); 

    private final Set<String> fileExtensions; 

    ResourceType(final String... fileExtensions) { 
     this.fileExtensions = new HashSet<String>(); 
     for(final String fileExtension: fileExtensions){ 
      this.fileExtensions.add(fileExtension); 
     } 
    } 

    public static Set<String> allFileExtensions(final ResourceType... resourceTypes) { 
     final Set<String> extensions = new HashSet<String>(); 
     for (final ResourceType resourceType : resourceTypes) { 
      extensions.addAll(resourceType.fileExtensions()); 
     } 

     return extensions; 
    } 

    public static ResourceType getByFileName(final String fileName) { 
     for (final ResourceType resourceType : ResourceType.values()) { 
      for (final String extension : resourceType.fileExtensions()) { 
       if (fileName.endsWith(extension)) { 
        return resourceType; 
       } 
      } 
     } 

     return null; 
    } 

    public Set<String> fileExtensions() { 
     return new HashSet<String>(fileExtensions); 
    } 

} 

可能是什么问题?

回答

1

我认为你遇到了QDox的问题,这可能与解析YAML(new String[]{".yml", ".yaml"});行有关系。堆栈跟踪可以确认。 该解决方案实际上很简单,因为您正在使用varArgs:将行更改为YAML(".yml", ".yaml");

+0

我没有考虑它!非常感谢 – JeanValjean