日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

手动写sonar plugin 一直File is not a plugin.

發布時間:2023/12/19 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 手动写sonar plugin 一直File is not a plugin. 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

原因:打包的時候有問題

標準sonar plugin 包里面的META-INF 下面的MANIFEST.MF文件如下

anifest-Version: 1.0 Plugin-Description: Enables analysis of Java Properties files.Plugin-BuildDate: 2019-04-30T16:41:44+0800 Plugin-Display-Version: 2.7-SNAPSHOT Archiver-Version: Plexus Archiver SonarLint-Supported: false Plugin-Version: 2.7-SNAPSHOT Plugin-ChildFirstClassLoader: false Implementation-Build: 0 Plugin-OrganizationUrl: mailto:david.racodon@gmail.com Build-Time: 2019-04-30T08:40:46+0000 Plugin-Key: javaProperties Plugin-Class: org.sonar.plugins.jproperties.JavaPropertiesPlugin Created-By: Apache Maven 3.5.3 Build-Jdk: 1.8.0_131 Plugin-Name: Java Properties

而我打出來的jar 包如下:

Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Built-By: wanyi Created-By: Apache Maven 3.5.3 Build-Jdk: 1.8.0_131

上面是問題的本質體現,導致原因是sonar插件是在主pom 中添加了

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

而自己開發的插件在主pom中添加:

<plugin><groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId><artifactId>sonar-packaging-maven-plugin</artifactId><version>1.17</version><extensions>true</extensions><configuration><pluginDescription>Scanner configuration files</pluginDescription><pluginKey>config-files</pluginKey><pluginName>configfiles</pluginName><pluginClass>com.lingtian.sonar.plugin.ConfigFileScanPlugin</pluginClass><sonarLintSupported>true</sonarLintSupported><sonarQubeMinVersion>5.6</sonarQubeMinVersion> <!-- allow to depend on API 6.x but run on LTS --></configuration> </plugin>

使用eclipse的maven install 上面配置的sonar-packaging-maven-plugin 沒有生效,但是在自寫

插件中添加sonar parent,會有maven-lisence和maven-enforce 校驗,主pom 報錯!

解決方式:1.要么直接修改打出來的jar 中MANIFEST.MF文件

2.在主pom中添加sonar-packaging-maven-plugin, 執行maven 指令:

mvn clean package?sonar-packaging:sonar-plugin,但是打出來的jar 包里面只有編譯的工程代碼

的class文件,并沒有依賴各種的包,所以在sonar 加載運行插件的時候,報各種class not fount.

在主pom 中添加:

<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><version>3.0.1</version><executions><execution><id>copy-dependencies</id><phase>package</phase><goals><goal>copy-dependencies</goal></goals><configuration><outputDirectory>target/lib</outputDirectory><overWriteSnapshots>true</overWriteSnapshots></configuration></execution></executions> </plugin>

此時需要在主pom 中添加?<packaging>sonar-plugin</packaging> !? ? ? ?官方演示實例:

下載地址:https://github.com/SonarSource/sonar-custom-rules-examples

?

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的手动写sonar plugin 一直File is not a plugin.的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。