我很难为我的公司开发一个插件,后来被称为"myPlugin“。
背景:I正在读曼宁公司的“行动中的SonarQube”一书。有一个开发自己的插件的小指南(他们以红插件为例进行开发)。它告诉我使用声纳插件原型来创建基本框架。
重构前的情况:--我编写了这个插件,它运行得很好。当我做了一些重构时,我遇到了这个问题。在重构我树中src文件夹中的每个包之前(使用ecplise)被称为"main.java.org.sonar.plugins.myplugin“,但是每个类中的包解密都是"org.sonar.plugins.myplugin”。这是使用声纳插件原型创建的默认设置。
声纳打包-maven-插件的pom.xml中的设置如下一次。
Pom-snippet before any changes were done:
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.9</version>
<extensions>true</extensions>
<configuration>
<pluginClass>org.sonar.plugins.myplugin.myPlugin</pluginClass>
</configuration>
</plugin>到目前为止一切都很顺利。现在我们来谈谈我的问题。
重构后的情况:由于我的公司对类和包有一些命名条件,我将树中的包名更改为"com.mycompany.sonar.plugins.myplugin“,每个类中的包解密也更改为"com.mycompany.sonar.plugins.myplugin”。然后,我将声纳打包maven-plugin的classPath选项更改为"com.mycompany.sonar.plugins.myplugin.myPlugin".。我这么做只是想说改变“org”。转换成“com.mycompany”。
Pom-snippet after changes were done:
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.9</version>
<extensions>true</extensions>
<configuration>
<pluginClass>com.mycompany.sonar.plugins.myplugin.myPlugin</pluginClass>
</configuration>
</plugin>当我运行“编译”命令时,一切都成功了。使用"package“不起作用,因为声纳打包maven-plugin无法找到给定的类(请参阅下面的控制台输出)。当我重新开始每件事的时候,它又起作用了。
[...]
[INFO] --- sonar-packaging-maven-plugin:1.9:sonar-plugin (default-sonar-plugin) @ sonar-projectkeychecker-plugin ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.649 s
[INFO] Finished at: 2014-04-02T11:42:01+01:00
[INFO] Final Memory: 13M/67M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.sonar:sonar-packaging-maven-plugin:1.9:sonar-plugin (default-sonar-plugin) on project sonar-myplugin-plugin: Plugin class not found: 'com.mycompany.sonar.plugins.myplugin.myPlugin-> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException我的问题:为什么我的新名字不起作用?是否有任何内部传达的声纳封装-maven-插件(就像包装名称必须以"org.sonar“开始类似这样的事情)?
谢谢你阅读了这篇长文,并试图帮助我:)
发布于 2014-04-03 07:50:39
pluginClass是插件的入口点。值必须是现有类。在您的示例中,我假设有一个错误,应该是com.mycompany.sonar.plugins.myplugin.MyPlugin (大写M)。
发布于 2020-03-04 13:40:14
在<plugin>下,我丢失了<extensions>true</extensions>标记
https://stackoverflow.com/questions/22808462
复制相似问题