首页 > 解决方案 > Detekt 插件无法从 Maven 中心下载

问题描述

我正在使用 Kotlin 并希望使用 Detekt 插件进行静态分析。我的问题是,当我想从 Maven 中央存储库下载它时,它给了我以下错误。但是当我使用公司的存储库(Nexus)时,它不会给我任何错误并且可以顺利下载。我不明白这一点。

有人能告诉我为什么会这样吗?我想使用这个插件,还没有找到任何其他选择。

以下是我的错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (detekt) on project agathe: Execution detekt of goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run failed: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.8 or one of its dependencies could not be resolved: Could not find artifact com.beust:jcommander:jar:1.74 in central (https://repo.maven.apache.org/maven2) -> [Help 1]

请在下面找到我的 POM 文件。

<properties>
    .. 
    <sonar.kotlin.detekt.reportPaths>${project.build.directory}/detekt.xml</sonar.kotlin.detekt.reportPaths>
    ..
</properties>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <executions>
                <execution>
                    <!-- This can be run separately with mvn antrun:run@detekt -->
                    <id>detekt</id>
                    <phase>verify</phase>
                    <configuration>
                        <target name="detekt">
                            <java taskname="detekt" dir="${basedir}"
                                  fork="true"
                                  failonerror="false"
                                  classname="io.gitlab.arturbosch.detekt.cli.Main"
                                  classpathref="maven.plugin.classpath">
                                <arg value="--input"/>
                                <arg value="${basedir}/src"/>
                                <arg value="--filters"/>
                                <arg value=".*/target/.*,.*/resources/.*"/>
                                <arg value="--report"/>
                                <arg value="xml:${project.build.directory}/detekt.xml"/>
                            </java>
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>io.gitlab.arturbosch.detekt</groupId>
                    <artifactId>detekt-cli</artifactId>
                    <version>1.0.0-RC14</version>
                </dependency>
            </dependencies>
        </plugin>

标签: mavenkotlinmaven-pluginstatic-analysisdetekt

解决方案


推荐阅读