使用带有maven-plugin-plugin的help-mojo阶段编译Maven插件

时间:2016-03-06 10:16:47

标签: java maven maven-plugin

我正在为Maven扩展MojoHaus plugin。 我的项目位于this GitHub repository

当我尝试运行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 个答案:

答案 0 :(得分:1)

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