Comments (12)
OK so the plugin extends compile with the provided configuration, as such when its provided your tests are also getting the class in the classpath. However when using compileOnly this wasnt happening for your tests (the plugin still works as expected creating the jar). Since they have started seperating out the various configurations (especially with kotlin) i'll have a think and see if there is a better way to handle this.
from gradle-sonar-packaging-plugin.
Im just thinking about the best way to support this, will need to refactor a little.
from gradle-sonar-packaging-plugin.
Are still on this? I could as well try to provide a PR.
from gradle-sonar-packaging-plugin.
Hi @otrosien, I had a little play with this awhile back and it wasnt quite as clear cut. Will did it back up and have another go!
from gradle-sonar-packaging-plugin.
Nowadays compileOnly
should just be taken as granted. or do you plan to support gradle versions older than 2.12?
from gradle-sonar-packaging-plugin.
I have released 1.0-RC1 this supports compileOnly, can you give it a go please :)
from gradle-sonar-packaging-plugin.
As mentioned in #19 provided
works for me now but compileOnly
fails with:
Jun 27, 2017 10:25:54 AM org.junit.platform.commons.util.ClasspathScanner logWarning
WARNING: Failed to load java.lang.Class for path [/home/artur/Repos/detekt/detekt-sonar-kotlin/build/classes/java/main/io/gitlab/arturbosch/detekt/sonar/DetektSensor.class] during classpath scanning.
java.lang.NoClassDefFoundError: org/sonar/api/batch/sensor/Sensor
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.junit.platform.commons.util.ReflectionUtils.loadClass(ReflectionUtils.java:357)
at org.junit.platform.commons.util.ClasspathScanner.processClassFileSafely(ClasspathScanner.java:156)
at org.junit.platform.commons.util.ClasspathScanner.lambda$findClassesForPath$3(ClasspathScanner.java:141)
at org.junit.platform.commons.util.ClassFileVisitor.visitFile(ClassFileVisitor.java:41)
at org.junit.platform.commons.util.ClassFileVisitor.visitFile(ClassFileVisitor.java:24)
at java.nio.file.Files.walkFileTree(Files.java:2670)
at java.nio.file.Files.walkFileTree(Files.java:2742)
at org.junit.platform.commons.util.ClasspathScanner.findClassesForPath(ClasspathScanner.java:141)
at org.junit.platform.commons.util.ClasspathScanner.findClassesForUri(ClasspathScanner.java:125)
at org.junit.platform.commons.util.ClasspathScanner.scanForClassesInClasspathRoot(ClasspathScanner.java:103)
at org.junit.platform.commons.util.ReflectionUtils.findAllClassesInClasspathRoot(ReflectionUtils.java:514)
at org.junit.platform.commons.util.ReflectionUtils.findAllClassesInClasspathRoot(ReflectionUtils.java:504)
at org.jetbrains.spek.engine.SpekTestEngine.resolveSpecs(SpekTestEngine.kt:66)
at org.jetbrains.spek.engine.SpekTestEngine.discover(SpekTestEngine.kt:50)
at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:115)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:87)
at org.junit.platform.console.tasks.ConsoleTestExecutor.executeTests(ConsoleTestExecutor.java:65)
at org.junit.platform.console.tasks.ConsoleTestExecutor.lambda$execute$0(ConsoleTestExecutor.java:57)
at org.junit.platform.console.tasks.CustomContextClassLoaderExecutor.invoke(CustomContextClassLoaderExecutor.java:33)
at org.junit.platform.console.tasks.ConsoleTestExecutor.execute(ConsoleTestExecutor.java:57)
at org.junit.platform.console.ConsoleLauncher.executeTests(ConsoleLauncher.java:79)
at org.junit.platform.console.ConsoleLauncher.execute(ConsoleLauncher.java:69)
at org.junit.platform.console.ConsoleLauncher.main(ConsoleLauncher.java:41)
Caused by: java.lang.ClassNotFoundException: org.sonar.api.batch.sensor.Sensor
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 35 more
I'm using Junit5
and Spek
as their callstack is mentioned.
from gradle-sonar-packaging-plugin.
@arturbosch i cant reproduce this on your project, here is my diff:
diff --git a/detekt-sonar-kotlin/build.gradle b/detekt-sonar-kotlin/build.gradle
index 355455c..9ded9b6 100644
--- a/detekt-sonar-kotlin/build.gradle
+++ b/detekt-sonar-kotlin/build.gradle
@@ -12,7 +12,7 @@ dependencies {
compile project(':detekt-core')
compile project(':detekt-formatting')
compile project(':detekt-rules')
- provided "org.sonarsource.sonarqube:sonar-plugin-api:$sonarVersion"
+ compileOnly "org.sonarsource.sonarqube:sonar-plugin-api:$sonarVersion"
testCompile "org.sonarsource.sonarqube:sonar-testing-harness:$sonarVersion"
testRuntime "org.junit.platform:junit-platform-launcher:$junitPlatformVersion"
testRuntime "org.junit.platform:junit-platform-console:$junitPlatformVersion"
@@ -39,4 +39,4 @@ sonarPackaging {
skipDependenciesPackaging = false
useChildFirstClassLoader = false
basePlugin = ''
-}
\ No newline at end of file
+}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index adad9d2..c0a2144 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
from gradle-sonar-packaging-plugin.
Ok I analyzed the behaviour again: I get the exceptions but they do not make the build fail. I can localDeploy and restartServer
and everything works (just the stacktraces). Idk what is wrong, I will just use provided ^^
from gradle-sonar-packaging-plugin.
@iwarapter maybe it's a case of trying to do too much.. Inside build.gradle you usually have the sonarqube version, maybe even as an ext-parameter. So why infer the version from the dependencies if the user can just pass it as string property?
from gradle-sonar-packaging-plugin.
@otrosien it's not just a case of knowing the version unfortunately, its used to identify all the jars that are part of it and hence don't need to be packaged in the plugin. I just need to check with the recent split of configurations whats the best approach.
from gradle-sonar-packaging-plugin.
@iwarapter isn't that what compileOnly is for? No need to reinvent the wheel..
from gradle-sonar-packaging-plugin.
Related Issues (20)
- The plugin fails with Gradle 2.11 HOT 1
- Refactor out internal api calls HOT 1
- localDeploy does not work
- LoggingManager.setLevel(LogLevel) has been deprecated HOT 1
- Build failed if using sonar-plugin-api ver-5.5 and above HOT 3
- `pluginPackaging` failed in gradle multiproject HOT 5
- Support `sonarQubeMinVersion` property HOT 2
- Deprecation warning with gradle 3.5 / support for gradle 4.0 HOT 11
- org.sonarsource.sonarqube:sonar-plugin-api should be declared in dependencies problem HOT 8
- Package dependencies better
- Plugin class not found after just updating kotlin dependencies HOT 4
- Plugin not compatible with Gradle 5.0 HOT 5
- `implementation` dependencies not resolved
- Could not get unknown property 'compile' HOT 3
- Plugin packaging: nearly there, except Sonar does not accept it... HOT 15
- Change packaging finalizedBy dependency
- Build goes into endless loop and craches HOT 10
- org.codehaus.sonar:sonar-plugin-api or org.sonarsource.sonarqube:sonar-plugin-api should be declared in dependencies HOT 1
- xstream not added to the output plugin jar HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gradle-sonar-packaging-plugin.