[sonar-dev] Coding a plugin with gradle?

classic Classic list List threaded Threaded
19 messages Options
fge
Reply | Threaded
Open this post in threaded view
|

[sonar-dev] Coding a plugin with gradle?

fge
The plugin documentation at
http://docs.sonarqube.org/display/SONAR/Coding+a+Plugin only tells
about Maven; but I use gradle.

Is there a documentation somewhere on how to code a plugin with
gradle? I don't wish to use maven not only because I don't like it,
and that's personal, but also because I do things with gradle which
maven simply cannot do.

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

Simon Brandhof
You can use your own gradle build, but then it's up to you to implement the features of sonar-packaging-maven-plugin:
  • packages dependencies, except sonar-plugin-api and its dependencies, into META-INF/lib
  • sets the required metadata into JAR manifest
Regards
 


Simon BRANDHOF | SonarSource
Tech Lead & Co-Founder
http://twitter.com/SimonBrandhof

On 12 March 2015 at 19:11, Francis Galiegue <[hidden email]> wrote:
The plugin documentation at
http://docs.sonarqube.org/display/SONAR/Coding+a+Plugin only tells
about Maven; but I use gradle.

Is there a documentation somewhere on how to code a plugin with
gradle? I don't wish to use maven not only because I don't like it,
and that's personal, but also because I do things with gradle which
maven simply cannot do.

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



fge
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

fge
On Fri, Mar 13, 2015 at 7:35 AM, Simon Brandhof
<[hidden email]> wrote:
> You can use your own gradle build, but then it's up to you to implement the
> features of sonar-packaging-maven-plugin:
>
> packages dependencies, except sonar-plugin-api and its dependencies, into
> META-INF/lib
> sets the required metadata into JAR manifest
>
> Regards
>

Ah, thanks! I had started to read the source but I wasn't sure what it did...

Any chance that this will get documented in the code, with a README or
something?

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

RE: [sonar-dev] Coding a plugin with gradle?

KARR, DAVID
> -----Original Message-----
> From: Francis Galiegue [mailto:[hidden email]]
> Sent: Friday, March 13, 2015 12:52 AM
> To: [hidden email]
> Subject: Re: [sonar-dev] Coding a plugin with gradle?
>
> On Fri, Mar 13, 2015 at 7:35 AM, Simon Brandhof
> <[hidden email]> wrote:
> > You can use your own gradle build, but then it's up to you to implement
> the
> > features of sonar-packaging-maven-plugin:
> >
> > packages dependencies, except sonar-plugin-api and its dependencies,
> into
> > META-INF/lib
> > sets the required metadata into JAR manifest
> >
> > Regards
> >
>
> Ah, thanks! I had started to read the source but I wasn't sure what it
> did...
>
> Any chance that this will get documented in the code, with a README or
> something?

The last I looked at this (only yesterday), the Github project didn't even have any statement about what the project is for, much less the details of what it does.

Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

Simon Brandhof
Documentation is at http://docs.sonarqube.org/display/SONAR/Coding+a+Plugin and http://docs.sonarqube.org/display/SONAR/sonar-packaging-maven-plugin.
Documenting internal manifest properties and JAR structure was useless as long as only maven is supported. 


Simon BRANDHOF | SonarSource
Tech Lead & Co-Founder
http://twitter.com/SimonBrandhof

On 13 March 2015 at 18:36, KARR, DAVID <[hidden email]> wrote:
> -----Original Message-----
> From: Francis Galiegue [mailto:[hidden email]]
> Sent: Friday, March 13, 2015 12:52 AM
> To: [hidden email]
> Subject: Re: [sonar-dev] Coding a plugin with gradle?
>
> On Fri, Mar 13, 2015 at 7:35 AM, Simon Brandhof
> <[hidden email]> wrote:
> > You can use your own gradle build, but then it's up to you to implement
> the
> > features of sonar-packaging-maven-plugin:
> >
> > packages dependencies, except sonar-plugin-api and its dependencies,
> into
> > META-INF/lib
> > sets the required metadata into JAR manifest
> >
> > Regards
> >
>
> Ah, thanks! I had started to read the source but I wasn't sure what it
> did...
>
> Any chance that this will get documented in the code, with a README or
> something?

The last I looked at this (only yesterday), the Github project didn't even have any statement about what the project is for, much less the details of what it does.


fge
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

fge
On Fri, Mar 13, 2015 at 6:43 PM, Simon Brandhof
<[hidden email]> wrote:
> Documentation is at http://docs.sonarqube.org/display/SONAR/Coding+a+Plugin
> and http://docs.sonarqube.org/display/SONAR/sonar-packaging-maven-plugin.
> Documenting internal manifest properties and JAR structure was useless as
> long as only maven is supported.
>

Well, that's leaving out a lot of users who, like me, use gradle.

Any chance that SonarQube will support gradle one day or will this
have to be a community effort?

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

Simon Brandhof
No, supporting gradle for building a plugin is not planned. Documentation must be improved though. I get back to you when it's done.


Simon BRANDHOF | SonarSource
Tech Lead & Co-Founder
http://twitter.com/SimonBrandhof

On 14 March 2015 at 13:07, Francis Galiegue <[hidden email]> wrote:
On Fri, Mar 13, 2015 at 6:43 PM, Simon Brandhof
<[hidden email]> wrote:
> Documentation is at http://docs.sonarqube.org/display/SONAR/Coding+a+Plugin
> and http://docs.sonarqube.org/display/SONAR/sonar-packaging-maven-plugin.
> Documenting internal manifest properties and JAR structure was useless as
> long as only maven is supported.
>

Well, that's leaving out a lot of users who, like me, use gradle.

Any chance that SonarQube will support gradle one day or will this
have to be a community effort?

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

iwarapter
As simon mentioned building with gradle is relatively straight forward.

You need to package the dependencies and update the manifest, i do this by defining a configuration and use that to package all the dependencies:

jar {
  into('META-INF/lib') {
    from configurations.sonarqube
  }
  manifest {
    attributes( "Created-By": "Gradle",
                "Built-By": System.getProperty('user.name'),
                "Build-Jdk": System.getProperty('java.version'),
                "Build-Time": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
                "Plugin-BuildDate": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
                "Plugin-Class": 'org.group.SonarPlugin',
                "Plugin-Dependencies": configurations.sonarqube.collect{ "META-INF/lib/${it.name}" }.join(' '),
                "Plugin-Description": "Do some sonar plugin stuff!",
                "Plugin-Developers": 'Iain Adams',
                "Plugin-Key": 'example',
                "Plugin-Name": 'Example',
                "Plugin-Version": version,
                "Sonar-Version": 3.7)
  }
}

You can extend this to also deploy the plugin locally and trigger the restart of a server in demo mode.

If your interested i can write a plugin to wrap all this up.
fge
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

fge
On Tue, Mar 17, 2015 at 12:15 AM, iwarapter <[hidden email]> wrote:

> As simon mentioned building with gradle is relatively straight forward.
>
> You need to package the dependencies and update the manifest, i do this by
> defining a configuration and use that to package all the dependencies:
>
> jar {
>   into('META-INF/lib') {
>     from configurations.sonarqube
>   }
>   manifest {
>     attributes( "Created-By": "Gradle",
>                 "Built-By": System.getProperty('user.name'),
>                 "Build-Jdk": System.getProperty('java.version'),
>                 "Build-Time": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
>                 "Plugin-BuildDate": new
> Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
>                 "Plugin-Class": 'org.group.SonarPlugin',
>                 "Plugin-Dependencies": configurations.sonarqube.collect{
> "META-INF/lib/${it.name}" }.join(' '),
>                 "Plugin-Description": "Do some sonar plugin stuff!",
>                 "Plugin-Developers": 'Iain Adams',
>                 "Plugin-Key": 'example',
>                 "Plugin-Name": 'Example',
>                 "Plugin-Version": version,
>                 "Sonar-Version": 3.7)
>   }
> }
>
> You can extend this to also deploy the plugin locally and trigger the
> restart of a server in demo mode.
>
> If your interested i can write a plugin to wrap all this up.
>

You bet I am!

Well, I am not quite ready to build a full plugin yet (I'm completing
the parsing stage), but I have one question: what is the "sonarqube"
configuration here?

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

iwarapter
You define it and add the dependencies that need packaging inside the plugin, the maven plugin actually works out which need to be added but i haven't been able to replicate a similar implementation fully so i'm just defining them explicitly currently. e.g,

configurations {
    sonarqube
}

sonarqube group: 'org.codehaus.sonar.sslr', name: 'sslr-core', version: '1.20', transitive: false
sonarqube group: 'org.codehaus.sonar.sslr', name: 'sslr-toolkit', version: '1.20', transitive: false
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

Rene Groeschke
In reply to this post by iwarapter


17 Mar 2015 00:15
As simon mentioned building with gradle is relatively straight forward.

You need to package the dependencies and update the manifest, i do this by
defining a configuration and use that to package all the dependencies:

jar {
into('META-INF/lib') {
from configurations.sonarqube
}
manifest {
attributes( "Created-By": "Gradle",
"Built-By": System.getProperty('user.name'),
"Build-Jdk": System.getProperty('java.version'),
"Build-Time": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"Plugin-BuildDate": new
Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"Plugin-Class": 'org.group.SonarPlugin',
"Plugin-Dependencies": configurations.sonarqube.collect{
"META-INF/lib/${it.name}" }.join(' '),
"Plugin-Description": "Do some sonar plugin stuff!",
"Plugin-Developers": 'Iain Adams',
"Plugin-Key": 'example',
"Plugin-Name": 'Example',
"Plugin-Version": version,
"Sonar-Version": 3.7)
}
}

You can extend this to also deploy the plugin locally and trigger the
restart of a server in demo mode.

If your interested i can write a plugin to wrap all this up.
I would be happy to see this kind of plugin in the gradle plugin portal.

cheers!
René

--

Principal Engineer,
Gradleware Inc. - Gradle Training, Support, Consulting
[hidden email]
http://gradleware.com




--
View this message in context: http://sonarqube.15.x6.nabble.com/sonar-dev-Coding-a-plugin-with-gradle-tp5033268p5033371.html
Sent from the SonarQube Developers mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


16 Mar 2015 10:25
No, supporting gradle for building a plugin is not planned. Documentation must be improved though. I get back to you when it's done.


Simon BRANDHOF | SonarSource
Tech Lead & Co-Founder
http://twitter.com/SimonBrandhof


14 Mar 2015 13:07
On Fri, Mar 13, 2015 at 6:43 PM, Simon Brandhof

Well, that's leaving out a lot of users who, like me, use gradle.

Any chance that SonarQube will support gradle one day or will this
have to be a community effort?

13 Mar 2015 18:43
Documentation is at http://docs.sonarqube.org/display/SONAR/Coding+a+Plugin and http://docs.sonarqube.org/display/SONAR/sonar-packaging-maven-plugin.
Documenting internal manifest properties and JAR structure was useless as long as only maven is supported. 


Simon BRANDHOF | SonarSource
Tech Lead & Co-Founder
http://twitter.com/SimonBrandhof


13 Mar 2015 18:36

The last I looked at this (only yesterday), the Github project didn't even have any statement about what the project is for, much less the details of what it does.


Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

iwarapter
Hi Guys,

I'm hoping to release a early release candidate soon if anyone is interested in having a play :)

@Rene I might pick your brains on some of the cooler features i want to implement.
fge
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

fge
On Sun, Mar 22, 2015 at 1:55 AM, iwarapter <[hidden email]> wrote:
> Hi Guys,
>
> I'm hoping to release a early release candidate soon if anyone is interested
> in having a play :)
>

Me, me, me! :p

Also, if you have some hints as to how to get a full language plugin
started, I'm all ears...

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

iwarapter
I have completed the first (rough) draft of the plugin:
https://github.com/iwarapter/gradle-sonar-packaging-plugin

I haven't published the artifacts anywhere atm so you will need to build and install locally for the time being.

I have an example project using the plugin:
https://github.com/iwarapter/sonar-gradle-plugin-example

Which you can pickup and go with. I have a few more tasks todo before i'd release the plugin (see the issues on GitHub), but keen for any early feedback.
fge
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

fge
On Sun, Mar 22, 2015 at 10:12 PM, iwarapter <[hidden email]> wrote:

> I have completed the first (rough) draft of the plugin:
> https://github.com/iwarapter/gradle-sonar-packaging-plugin
>
> I haven't published the artifacts anywhere atm so you will need to build and
> install locally for the time being.
>
> I have an example project using the plugin:
> https://github.com/iwarapter/sonar-gradle-plugin-example
>
> Which you can pickup and go with. I have a few more tasks todo before i'd
> release the plugin (see the issues on GitHub), but keen for any early
> feedback.
>

Excellent! Thank you very much!

I'll play with it and let you know how I fared...

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


fge
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

fge
On Sun, Mar 22, 2015 at 11:47 PM, Francis Galiegue <[hidden email]> wrote:
[...]
>
> Excellent! Thank you very much!
>
> I'll play with it and let you know how I fared...
>

Well, since I now have a fully functional plugin for a dummy language,
I'll just try and convert it to use your plugin in the near future!
This way the full stack can be tested...

If you are interested in playing with it yourself, it's here:

https://github.com/litesolutions/sonar-dummylanguage

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

iwarapter
Cheers!

I'm just working through some issues with the dependency packaging currently and adding the remaining functionality.

I'll keep you updated!
fge
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

fge
On Wed, Apr 1, 2015 at 7:36 PM, iwarapter <[hidden email]> wrote:
[...]
>
> I'll keep you updated!
>

Success!

A full fledged Sonar language plugin has been successfully packaged
with the plugin:

https://github.com/iwarapter/gradle-sonar-packaging-plugin

One difficulty encountered was a problem with ':' vs '-' in
Plugin-Dependencies, OK, easily fixed; however another fix which had
to be made is more troublesome.

Namely: I depend in this plugin on a package of mine with a classifier:

    compile(group: "com.github.fge", name: "grappa",
        version: "2.0.0-beta.4", classifier: "all") {
        exclude(group: "com.google.guava", module: "guava");
    };

(imagine the equivalent with maven)

The Maven plugin will happily rename it; that is, in the jar we would see:

META-INF/lib/grappa-2.0.0-beta.4.jar

Whereas with gradle this same dependency is:

META-INF/lib/grappa-2.0.0-beta.4-all.jar

That is, the classifier is left intact.

Therefore, the workaround/fix here was to have the gradle plugin
change its dependency entry to include the classifier where the maven
plugin does not...

Not sure whether there is a recommended practice at all here; I
personally prefer the gradle way since we are explicitly told the
qualifier... And I am not skilled enough to understand where this
"name flattening" occurs in the maven plugin, or even whether this is
done on purpose?

--
Francis Galiegue, [hidden email], https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/fge/grappa

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] Coding a plugin with gradle?

iwarapter
In reply to this post by Rene Groeschke
An initial version has been released:
https://plugins.gradle.org/plugin/com.iadams.sonar-packaging