Closed sergeykad closed 8 years ago
This isnt included as its part of the api:
$ gradle dependencyInsight --dependency xstream
:dependencyInsight
com.thoughtworks.xstream:xstream:1.4.8 (conflict resolution)
\--- compile
com.thoughtworks.xstream:xstream:1.3.1 -> 1.4.8
\--- org.codehaus.sonar:sonar-plugin-api:4.5.2
\--- compile
BUILD SUCCESSFUL
Total time: 2.789 secs
Have you tried this with the maven plugin, does the functionality differ?
I am compiling and running my plugin with SonarQube 5.2 (org.sonarsource.sonarqube:sonar-plugin-api:5.2). From what I see there is no xstream in this SonarQube version.
Plugins compiled with earlier SonarQube versions run in compatibility mode which I am guessing supposed to prevent such errors. From the SonarQube log: "API compatibility mode is enabled on plugin Java [java] `(built with API lower than 5.2)"
Edit: I tried it with the latest Maven plugin and it added xstream to the META-INF/lib folder
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.15</version>
Can you confirm which version of the plugin you are using, as i cant reproduce this:
Here is what im seeing:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.iadams.plugins:gradle-sonar-packaging-plugin:0.1.3"
}
}
apply plugin: "com.iadams.sonar-packaging"
repositories {
mavenCentral()
}
dependencies {
compile 'com.thoughtworks.xstream:xstream:1.4.8'
provided "org.sonarsource.sonarqube:sonar-plugin-api:5.2"
}
version = '1.0'
sonarPackaging {
pluginDir = "$buildDir/myServer"
serverUrl = 'http://localhost:9000'
pluginKey = 'sample'
pluginClass = 'com.example.HelloWorld'
pluginName 'Example'
pluginDescription = 'An Example Plugin!'
//pluginParent = 'java'
pluginLicense = 'MIT'
//requirePlugins = 'java'
pluginUrl = 'http://my-plugin.com'
pluginIssueTrackerUrl = 'http://my-plugin.com/issues'
pluginTermsConditionsUrl 'http://my-plugin.com/terms'
pluginSourceUrl = 'http://github.com'
pluginDevelopers = 'iain adams'
skipDependenciesPackaging = false
useChildFirstClassLoader = true
//basePlugin
organization {
name = 'iain-corp'
url = 'http://iain-corp.com'
}
}
$ gradle clean build
:clean
:compileJava
:processResources UP-TO-DATE
:classes
:jar
:pluginPackaging
Checking for sonar-plugin-api
-------------------------------------------------------
Plugin definition in update center
Created-By: Gradle
Built-By: iwarapter
Build-Jdk: 1.8.0_60
Build-Time: 2016-02-06T12:30:56+0000
Plugin-BuildDate: 2016-02-06T12:30:56+0000
Plugin-Class: com.example.HelloWorld
Plugin-Description: An Example Plugin!
Plugin-Developers: iain adams
Plugin-Homepage: http://my-plugin.com
Plugin-IssueTrackerUrl: http://my-plugin.com/issues
Plugin-Key: sample
Plugin-License: MIT
Plugin-Name: Example
Plugin-Organization: iain-corp
Plugin-OrganizationUrl: http://iain-corp.com
Plugin-SourcesUrl: http://github.com
Plugin-TermsConditionsUrl: http://my-plugin.com/terms
Plugin-Version: 1.0
Sonar-Version: 5.2
Plugin-ChildFirstClassLoader: true
-------------------------------------------------------
Following dependencies are packaged in the plugin:
com.thoughtworks.xstream:xstream:1.4.8
xmlpull:xmlpull:1.1.3.1
xpp3:xpp3_min:1.1.4c
See following page for more details about plugin dependencies:
http://docs.sonarqube.org/display/DEV/Coding+a+Plugin
Sonar Plugin Created.
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build
BUILD SUCCESSFUL
Total time: 3.77 secs
$ unzip -l build/libs/example-1.0.jar
Archive: build/libs/example-1.0.jar
Length Date Time Name
-------- ---- ---- ----
0 02-06-16 12:30 META-INF/
803 02-06-16 12:30 META-INF/MANIFEST.MF
0 02-06-16 12:30 com/
0 02-06-16 12:30 com/example/
492 02-06-16 12:30 com/example/HelloWorld.class
0 02-06-16 12:30 META-INF/lib/
538830 02-02-16 20:06 META-INF/lib/xstream-1.4.8.jar
7188 10-11-15 17:09 META-INF/lib/xmlpull-1.1.3.1.jar
24956 03-29-15 17:45 META-INF/lib/xpp3_min-1.1.4c.jar
-------- -------
572269 9 files
@sergeykad can you confirm if you still have this issue?
@iwarapter I still have the issue, but I did not have time to check it more thoroughly. I probably will have more information later this week.
The issue is still reproducible. Do you want me to check something specific?
I also noticed that testCompile 'junit:junit:4.12'
adds JUnit jar to the plugin packaging.
Can you send me a copy of the build script you are using?
plugins { id "com.iadams.sonar-packaging" version "0.1.3" }
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'project-report'
repositories {
jcenter()
}
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = 1.7
targetCompatibility = 1.7
sonarPackaging {
serverUrl = 'http://localhost:9000/'
pluginDir = 'c:/sonarqube-5.2/extensions/plugins'
pluginKey = 'myplugin'
pluginClass = 'com.myplugin.Plugin'
pluginName = 'myplugin'
pluginDescription = 'SonarQube plugin'
pluginParent = null
pluginLicense = 'Proprietary'
requirePlugins = null
pluginUrl = 'http://myplugin.com'
// pluginIssueTrackerUrl = 'http://mypluginwebsite.com/issues'
// pluginTermsConditionsUrl = 'http://mypluginwebsite.com/terms'
// pluginSourceUrl = 'http://github.com'
// pluginDevelopers = 'Bob Smith'
skipDependenciesPackaging = false
useChildFirstClassLoader = false
basePlugin = ''
}
dependencies {
compile 'org.apache.commons:commons-lang3:3.2.1'
// 'com.thoughtworks.xstream:xstream:1.4.8'
provided 'org.sonarsource.sonarqube:sonar-plugin-api:5.2',
'org.sonarsource.java:sonar-java-plugin:3.9',
'org.sonarsource.dotnet:sonar-csharp-plugin:4.4'
testCompile 'junit:junit:4.12'
}
thanks, for the build script, im getting the same output as you are, let me have a dig into this.
i should have a release candidate for this available shortly.
I was looking at the maven equivalent:
<?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>
<groupId>YOUR_GROUP_ID</groupId>
<!-- it's recommended to follow the pattern "sonar-{key}-plugin", for example "sonar-php-plugin" -->
<artifactId>YOUR_ARTIFACT_ID</artifactId>
<version>YOUR_VERSION</version>
<!-- this is important for sonar-packaging-maven-plugin -->
<packaging>sonar-plugin</packaging>
<dependencies>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api</artifactId>
<!-- minimal version of SonarQube to support. Note that the groupId is "org.codehaus.sonar" for versions lower than 5.2 -->
<version>5.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.java</groupId>
<artifactId>sonar-java-plugin</artifactId>
<version>3.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.dotnet</groupId>
<artifactId>sonar-csharp-plugin</artifactId>
<version>4.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.15</version>
<extensions>true</extensions>
<configuration>
<!-- the entry-point class that extends org.sonar.api.SonarPlugin -->
<pluginClass>com.example.HelloWorld</pluginClass>
<pluginDescription>Woot</pluginDescription>
<!-- advanced properties can be set here. See paragraph "Advanced Build Properties". -->
</configuration>
</plugin>
</plugins>
</build>
</project>
and it was not packaging the xtream dependency:
[WARNING] com.thoughtworks.xstream:xstream:jar:1.4.8:compile is provided by SonarQube plugin API and will not be packaged in your plugin
[INFO] Dependencies: META-INF/lib/xpp3_min-1.1.4c.jar META-INF/lib/xmlpull-1.1.3.1.jar META-INF/lib/commons-lang3-3.2.1.jar
That is interesting, since I got exception about missing xstream classes at runtime. Was you able to reproduce the problem with junit add to plugin package?
Yes i was able to reproduce the junit bit and have a fix for that.
@sergeykad i will publish a snapshot you can test with tomorrow.
This should be fixed in 0.1.4
I have Gradle compile dependency on 'com.thoughtworks.xstream:xstream:1.4.8', but it is not being added to the generated plugin jar.