Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pluginPackaging failed in gradle multiproject #16

Closed
goprayogo opened this issue Mar 14, 2017 · 5 comments
Closed

pluginPackaging failed in gradle multiproject #16

goprayogo opened this issue Mar 14, 2017 · 5 comments

Comments

@goprayogo
Copy link

goprayogo commented Mar 14, 2017

I set-up a gradle multi project for sonar plugin, and every time i do ./gradlew clean build, the build failed on pluginPackaging task.

I need to have the sonar plugin as part of a gradle multiproject set up, and i have the following gradle.build

buildscript {
    ext {
        versions = [
                gradleSonar         : "0.1.4"
        ]
        sonar_example_plugin = "0.0.1"
    }

    dependencies {
        classpath "gradle.plugin.com.iadams.plugins:gradle-sonar-packaging-plugin:${versions.gradleSonar}"
    }
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
        mavenCentral()
        jcenter()
    }
}

allprojects {
    repositories {
        maven { url "https://plugins.gradle.org/m2/" }
        mavenCentral()
        jcenter()
    }
}

subprojects {
    apply plugin: 'java'
}

project (":sonar-example-plugin"){
    apply plugin: 'com.iadams.sonar-packaging'

    dependencies {
        provided 'org.sonarsource.sonarqube:sonar-plugin-api:5.6'
    }

    pluginPackaging.dependsOn "compileJava"

    sonarPackaging {
        serverUrl = 'http://localhost:9000'
        pluginDir = '/tmp/sonarqube-5.1/extensions/plugins'
        pluginKey = 'example'
        pluginClass = 'org.sonarsource.plugins.example.ExamplePlugin'
        pluginName = 'Example'
        pluginDescription = 'Exmaple'
        pluginParent = null
        pluginLicense = 'MIT'
        requirePlugins = null
        pluginDevelopers = 'Gama Ogi Prayogo'
        skipDependenciesPackaging = false
        useChildFirstClassLoader = false
    }
   
}

The error that I've got when executing build

* What went wrong:
Execution failed for task ':sonar-example-plugin:pluginPackaging'.
> Plugin class not found: org.sonarsource.plugins.example.ExamplePlugin

If I execute gradle build in the child directory with the build.gradle as suggested in README.md, all is good.

@iwarapter
Copy link
Owner

In my plugin i setup the dependency on the plugin in the actual module using it - see https://github.com/iwarapter/sonar-puppet/blob/master/sonar-puppet-plugin/build.gradle

I'm assuming your setup is like this:

root
| - module A
| - module B 
| - sonar-example-plugin 

In which case i would of thought the section in the root build.gradle :

project (":sonar-example-plugin"){
    apply plugin: 'com.iadams.sonar-packaging'

Would of worked as expected, i'll setup some tests for this when I get back from work.

@iwarapter
Copy link
Owner

This works fine for me can you just confirm you have a class here:
cat sonar-example-plugin/src/main/java/org/sonarsource/plugins/example/ExamplePlugin.java

package org.sonarsource.plugins.example;

import java.util.Arrays;
import java.util.List;

import org.sonar.api.SonarPlugin;

public class ExamplePlugin extends SonarPlugin {

  @Override
  public List getExtensions() {
    return Arrays.asList();
  }
}

@goprayogo
Copy link
Author

Hi, I think this issue can be closed.

The issue is solved by adding the following statement in the build.gradle of the sub-module.

pluginPackaging.dependsOn 'compileJava'

Full sample project can be viewed here

@otrosien
Copy link

well, if there's such a dependency the plugin should register it by itself...

@iwarapter
Copy link
Owner

@otrosien @goprayogo you don't need to add that as its done automatically.

There is an example project here: https://github.com/iwarapter/gradle-sonar-packaging-plugin-issue-16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants