java - 生命周期配置未涵盖插件执行 : com. mycila.maven-license-plugin

标签 java maven plugins sonarqube

我正在尝试使用 java 创建一个 Sonar 插件。为此,我创建了一个 java 项目,并按照本教程将其转换为 Maven 项目,并向其添加了一些功能 -

http://docs.sonarqube.org/display/DEV/Writing+Custom+Rules+using+Java

我的 pom.xml 现在看起来像这样 -

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
    <groupId>org.codehaus.sonar-plugins</groupId>
    <artifactId>parent</artifactId>
    <version>18</version>
</parent>


<groupId>org.sonar.samples</groupId>
<artifactId>java-custom-rules</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>sonar-plugin</packaging>

<properties>
    <java.plugin.version>3.8</java.plugin.version>
</properties>

<name>Java Custom Rules</name>
<description>Java Custom Rules</description>

<dependencies>
    <dependency>
        <groupId>org.codehaus.sonar</groupId>
        <artifactId>sonar-plugin-api</artifactId>
        <version>4.5.4</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.sonarsource.java</groupId>
        <artifactId>sonar-java-plugin</artifactId>
        <version>${java.plugin.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.sonarsource.java</groupId>
        <artifactId>java-squid</artifactId>
        <version>${java.plugin.version}</version>
    </dependency>

    <dependency>
        <groupId>org.sonarsource.sslr-squid-bridge</groupId>
        <artifactId>sslr-squid-bridge</artifactId>
        <version>2.6.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.codehaus.sonar.sslr</groupId>
                <artifactId>sslr-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.sonarsource.java</groupId>
        <artifactId>java-checks-testkit</artifactId>
        <version>${java.plugin.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.codehaus.sonar.sslr</groupId>
        <artifactId>sslr-testing-harness</artifactId>
        <version>1.19.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.easytesting</groupId>
        <artifactId>fest-assert</artifactId>
        <version>1.4</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>0.9.30</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.sonar</groupId>
                <artifactId>sonar-packaging-maven-plugin</artifactId>
                <version>1.13</version>
                <extensions>true</extensions>
                <configuration>
                    <pluginClass>org.sonar.samples.java.MyJavaRulesPlugin</pluginClass>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.apache.commons</groupId>
                                    <artifactId>commons-collections4</artifactId>
                                    <version>4.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/test-jars</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
            <!--
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        com.mycila.maven-license-plugin
                                    </groupId>
                                    <artifactId>
                                        maven-license-plugin
                                    </artifactId>
                                    <versionRange>
                                        [1.9.0,)
                                    </versionRange>
                                    <goals>
                                        <goal>check</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
            -->
        </plugins> 
    </pluginManagement>
</build>

但是,当我进行干净的打包或干净的编译时,它给出了错误:
生命周期配置未涵盖插件执行:com.mycila.maven-license-plugin:maven-license-plugin:1.9.0:check(执行:enforce-license-headers,阶段:validate)

而且,它显示了该行的错误 -

<parent>
        <groupId>org.codehaus.sonar-plugins</groupId>
        <artifactId>parent</artifactId>
        <version>18</version>
    </parent>

可以进行一些快速修复 -

  1. 发现新的 m2e 连接 - 不返回任何内容。
  2. 在 Eclipse 首选项中的 Eclipse 构建中将目标检查标记为忽略。
  3. 在 Eclipse 构建中将 pom.xml 中的目标检查永久标记为忽略。- 这解决了编译问题,但我不太确定它的后期效果。

知道在这种情况下该怎么办吗?

谢谢!

最佳答案

您可以通过运行 mvn license:format 向所有文件添加许可证 header 来消除错误。这就是错误告诉您的信息 - 预期的许可证 header 未就位。

但是,您可能应该更改您的父 pom(不确定这是否也会消除错误)。

<parent>
  <groupId>org.sonarsource.parent</groupId>
  <artifactId>parent</artifactId>
  <version>24</version>
</parent>

是当前使用的。

关于java - 生命周期配置未涵盖插件执行 : com. mycila.maven-license-plugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35453193/

相关文章:

java - 尝试在 Maven 发布准备和执行任务上运行并行构建时出现 Ger 错误?

sockets - 哪些浏览器插件支持跨域 TCP 套接字?

plugins - 在 Vim 中启动后如何手动加载 ftplugin?

plugins - 如何配置 jetty-maven-plugin 来记录 oejs、oejsh、oejsh 包

java - Mybatis - 关闭连接时发生错误

java - Eclipse 字符编码

java - 使用一个同步(this)而不是两个?

maven - 故障安全错误 : "Invalid signature file digest for Manifest main attributes" when using shade plugin

java - Maven -- maven安装报错: Exception in thread "main" java. lang.UnsupportedClassVersionError

java - Gradle + Intellij 想法 : run configuration