Code Monkey home page Code Monkey logo

Comments (12)

iwarapter avatar iwarapter commented on July 21, 2024 1

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.

iwarapter avatar iwarapter commented on July 21, 2024

Im just thinking about the best way to support this, will need to refactor a little.

from gradle-sonar-packaging-plugin.

otrosien avatar otrosien commented on July 21, 2024

Are still on this? I could as well try to provide a PR.

from gradle-sonar-packaging-plugin.

iwarapter avatar iwarapter commented on July 21, 2024

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.

otrosien avatar otrosien commented on July 21, 2024

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.

iwarapter avatar iwarapter commented on July 21, 2024

I have released 1.0-RC1 this supports compileOnly, can you give it a go please :)

from gradle-sonar-packaging-plugin.

arturbosch avatar arturbosch commented on July 21, 2024

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.

iwarapter avatar iwarapter commented on July 21, 2024

@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.

arturbosch avatar arturbosch commented on July 21, 2024

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.

otrosien avatar otrosien commented on July 21, 2024

@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.

iwarapter avatar iwarapter commented on July 21, 2024

@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.

otrosien avatar otrosien commented on July 21, 2024

@iwarapter isn't that what compileOnly is for? No need to reinvent the wheel..

from gradle-sonar-packaging-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.