Quantcast

[sonar-dev] I hope there's a less ugly way

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[sonar-dev] I hope there's a less ugly way

Ann Campbell
To do what I've come up with (in my Ruby-newbie-tude)...

I'm working on my plugin to use the extension point for reviews. While I wait for the web service method on the other side that will allow the insert to actually take place, I thought I'd do a full replication of the Jira plugin functionality, & grab request counts too. (That read-only web service method was pretty easy to get :-)

I've created classes for my local request type and request status. Since we have 6 request types (that I know of) and 6 request statuses (that I'm interested in) I've got a matrix of 36 metrics, and I need knowledge of them on both the Java and Ruby sides. The easiest (& most efficient) thing to do seemed to be to set up some static lists:

  public static final CpStatus[] statii = {
    new CpStatus("isValidation", "IS Validation", Metric.DIRECTION_NONE,"FFCC33"),
    new CpStatus("backlog", "In Backlog", Metric.DIRECTION_NONE, "E0E0E0"),
// and so on

  public static final CpRequestType [] requestTypes = {
    new CpRequestType("dataAssistance", "Data Assistance", "Data Asst"),
    new CpRequestType("enhancement", "Enhancement / Maintenance", "Ehnanc / Maint"),
//&etc

I use these to generate my list of metrics and on the Ruby side, for my widgets, I use these lists to know how to abbreviate things, how to color them & so on.

I have been getting to them from the erb's like so:

<%
require 'java'
require 'C:/sonar/sonar-3.1/extensions/plugins/sonar-changepoint-plugin-0.1-SNAPSHOT.jar'
include_class "com.shawinc.sonar.metric.CpMetrics"


But clearly the fact that the version number is in the jar name is going to be a pain for every subsequent revision, because I'll have to remember to modify my erb's. (And I'm not likely to actually remember.)

I started to do some research on Maven-based, build-time token replacement, but it's ... unattractive.

And it occurred to me that maybe I should first verify that I'm going about this the right way...?


Any insight appreciated,
Ann


--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] I hope there's a less ugly way

Carlos Fillol
Hi Ann,

You can do something like this to include your plugin java classes:

<%
require 'java'

Dir["../deploy/plugins/yourpluginid/\*.jar"].each { |jar| require jar }
Dir["../deploy/plugins/yourpluginid/META-INF/lib/\*.jar"].each { |jar| require jar }

include_class "com.shawinc.sonar.metric.CpMetrics"
%>

But be careful! This is not recomended because ruby classloader is shared among all the plugins. That means that if you have two plugins deployed in Sonar, one of them using sonar-changepoint-plugin-1.0.jar classes and the other one using sonar-changepoint-plugin-2.0.jar you don't know which classes will be used at the end.

There will be no problem if you are sure that there will be only one deployed plugin using sonar-changepoint-plugin-X.jar.

______________________________________
Carlos Fillol Sendra (Linkedin)
t: 96 629 13 41 - t: 96 325 48 08



2012/6/18 Ann Campbell <[hidden email]>
To do what I've come up with (in my Ruby-newbie-tude)...

I'm working on my plugin to use the extension point for reviews. While I wait for the web service method on the other side that will allow the insert to actually take place, I thought I'd do a full replication of the Jira plugin functionality, & grab request counts too. (That read-only web service method was pretty easy to get :-)

I've created classes for my local request type and request status. Since we have 6 request types (that I know of) and 6 request statuses (that I'm interested in) I've got a matrix of 36 metrics, and I need knowledge of them on both the Java and Ruby sides. The easiest (& most efficient) thing to do seemed to be to set up some static lists:

  public static final CpStatus[] statii = {
    new CpStatus("isValidation", "IS Validation", Metric.DIRECTION_NONE,"FFCC33"),
    new CpStatus("backlog", "In Backlog", Metric.DIRECTION_NONE, "E0E0E0"),
// and so on

  public static final CpRequestType [] requestTypes = {
    new CpRequestType("dataAssistance", "Data Assistance", "Data Asst"),
    new CpRequestType("enhancement", "Enhancement / Maintenance", "Ehnanc / Maint"),
//&etc

I use these to generate my list of metrics and on the Ruby side, for my widgets, I use these lists to know how to abbreviate things, how to color them & so on.

I have been getting to them from the erb's like so:

<%
require 'java'
require 'C:/sonar/sonar-3.1/extensions/plugins/sonar-changepoint-plugin-0.1-SNAPSHOT.jar'
include_class "com.shawinc.sonar.metric.CpMetrics"


But clearly the fact that the version number is in the jar name is going to be a pain for every subsequent revision, because I'll have to remember to modify my erb's. (And I'm not likely to actually remember.)

I started to do some research on Maven-based, build-time token replacement, but it's ... unattractive.

And it occurred to me that maybe I should first verify that I'm going about this the right way...?


Any insight appreciated,
Ann


--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] I hope there's a less ugly way

Ann Campbell
Thanks Carlos!


On Tue, Jun 19, 2012 at 2:43 AM, Carlos Fillol <[hidden email]> wrote:
Hi Ann,

You can do something like this to include your plugin java classes:

<%
require 'java'

Dir["../deploy/plugins/yourpluginid/\*.jar"].each { |jar| require jar }
Dir["../deploy/plugins/yourpluginid/META-INF/lib/\*.jar"].each { |jar| require jar }

include_class "com.shawinc.sonar.metric.CpMetrics"
%>

But be careful! This is not recomended because ruby classloader is shared among all the plugins. That means that if you have two plugins deployed in Sonar, one of them using sonar-changepoint-plugin-1.0.jar classes and the other one using sonar-changepoint-plugin-2.0.jar you don't know which classes will be used at the end.

There will be no problem if you are sure that there will be only one deployed plugin using sonar-changepoint-plugin-X.jar.

______________________________________
Carlos Fillol Sendra (Linkedin)
t: 96 629 13 41 - t: 96 325 48 08



2012/6/18 Ann Campbell <[hidden email]>
To do what I've come up with (in my Ruby-newbie-tude)...

I'm working on my plugin to use the extension point for reviews. While I wait for the web service method on the other side that will allow the insert to actually take place, I thought I'd do a full replication of the Jira plugin functionality, & grab request counts too. (That read-only web service method was pretty easy to get :-)

I've created classes for my local request type and request status. Since we have 6 request types (that I know of) and 6 request statuses (that I'm interested in) I've got a matrix of 36 metrics, and I need knowledge of them on both the Java and Ruby sides. The easiest (& most efficient) thing to do seemed to be to set up some static lists:

  public static final CpStatus[] statii = {
    new CpStatus("isValidation", "IS Validation", Metric.DIRECTION_NONE,"FFCC33"),
    new CpStatus("backlog", "In Backlog", Metric.DIRECTION_NONE, "E0E0E0"),
// and so on

  public static final CpRequestType [] requestTypes = {
    new CpRequestType("dataAssistance", "Data Assistance", "Data Asst"),
    new CpRequestType("enhancement", "Enhancement / Maintenance", "Ehnanc / Maint"),
//&etc

I use these to generate my list of metrics and on the Ruby side, for my widgets, I use these lists to know how to abbreviate things, how to color them & so on.

I have been getting to them from the erb's like so:

<%
require 'java'
require 'C:/sonar/sonar-3.1/extensions/plugins/sonar-changepoint-plugin-0.1-SNAPSHOT.jar'
include_class "com.shawinc.sonar.metric.CpMetrics"


But clearly the fact that the version number is in the jar name is going to be a pain for every subsequent revision, because I'll have to remember to modify my erb's. (And I'm not likely to actually remember.)

I started to do some research on Maven-based, build-time token replacement, but it's ... unattractive.

And it occurred to me that maybe I should first verify that I'm going about this the right way...?


Any insight appreciated,
Ann


--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************





--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] I hope there's a less ugly way

Ann Campbell
Thought I'd share what I ended up with. It probably still counts as a hack, but at least it's not a hack I'll have to update for every release. Carlos, with your warning in mind, I tossed in a break after the first regex match, so it'll only pull in one version of the plugin. And shame on me if I have multiple copies in there!

require 'java'
Dir["../**/sonar-changepoint\*.jar"].each { |jar|
  require jar
  break
}
include_class "com.shawinc.sonar.metric.CpMetrics"


:-)
Ann


On Tue, Jun 19, 2012 at 8:04 AM, Ann Campbell <[hidden email]> wrote:
Thanks Carlos!


On Tue, Jun 19, 2012 at 2:43 AM, Carlos Fillol <[hidden email]> wrote:
Hi Ann,

You can do something like this to include your plugin java classes:

<%
require 'java'

Dir["../deploy/plugins/yourpluginid/\*.jar"].each { |jar| require jar }
Dir["../deploy/plugins/yourpluginid/META-INF/lib/\*.jar"].each { |jar| require jar }

include_class "com.shawinc.sonar.metric.CpMetrics"
%>

But be careful! This is not recomended because ruby classloader is shared among all the plugins. That means that if you have two plugins deployed in Sonar, one of them using sonar-changepoint-plugin-1.0.jar classes and the other one using sonar-changepoint-plugin-2.0.jar you don't know which classes will be used at the end.

There will be no problem if you are sure that there will be only one deployed plugin using sonar-changepoint-plugin-X.jar.

______________________________________
Carlos Fillol Sendra (Linkedin)
t: 96 629 13 41 - t: 96 325 48 08



2012/6/18 Ann Campbell <[hidden email]>
To do what I've come up with (in my Ruby-newbie-tude)...

I'm working on my plugin to use the extension point for reviews. While I wait for the web service method on the other side that will allow the insert to actually take place, I thought I'd do a full replication of the Jira plugin functionality, & grab request counts too. (That read-only web service method was pretty easy to get :-)

I've created classes for my local request type and request status. Since we have 6 request types (that I know of) and 6 request statuses (that I'm interested in) I've got a matrix of 36 metrics, and I need knowledge of them on both the Java and Ruby sides. The easiest (& most efficient) thing to do seemed to be to set up some static lists:

  public static final CpStatus[] statii = {
    new CpStatus("isValidation", "IS Validation", Metric.DIRECTION_NONE,"FFCC33"),
    new CpStatus("backlog", "In Backlog", Metric.DIRECTION_NONE, "E0E0E0"),
// and so on

  public static final CpRequestType [] requestTypes = {
    new CpRequestType("dataAssistance", "Data Assistance", "Data Asst"),
    new CpRequestType("enhancement", "Enhancement / Maintenance", "Ehnanc / Maint"),
//&etc

I use these to generate my list of metrics and on the Ruby side, for my widgets, I use these lists to know how to abbreviate things, how to color them & so on.

I have been getting to them from the erb's like so:

<%
require 'java'
require 'C:/sonar/sonar-3.1/extensions/plugins/sonar-changepoint-plugin-0.1-SNAPSHOT.jar'
include_class "com.shawinc.sonar.metric.CpMetrics"


But clearly the fact that the version number is in the jar name is going to be a pain for every subsequent revision, because I'll have to remember to modify my erb's. (And I'm not likely to actually remember.)

I started to do some research on Maven-based, build-time token replacement, but it's ... unattractive.

And it occurred to me that maybe I should first verify that I'm going about this the right way...?


Any insight appreciated,
Ann


--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************





--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720




--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] I hope there's a less ugly way

Simon Brandhof
I'm back from holidays, so sorry for the late answer. Reloading the JAR files is definitely not a good idea. You could give a try to the following :
  • Java::ComShawincSonarMetric::CpMetrics::statii
  • or if CppMetrics implements ServerExtension, controllers can get a reference with : java_facade.getCoreComponentByClassname('com.shawinc.sonar.metric.CpMetrics')


On 21 June 2012 18:33, Ann Campbell <[hidden email]> wrote:
Thought I'd share what I ended up with. It probably still counts as a hack, but at least it's not a hack I'll have to update for every release. Carlos, with your warning in mind, I tossed in a break after the first regex match, so it'll only pull in one version of the plugin. And shame on me if I have multiple copies in there!

require 'java'
Dir["../**/sonar-changepoint\*.jar"].each { |jar|
  require jar
  break
}
include_class "com.shawinc.sonar.metric.CpMetrics"


:-)
Ann


On Tue, Jun 19, 2012 at 8:04 AM, Ann Campbell <[hidden email]> wrote:
Thanks Carlos!


On Tue, Jun 19, 2012 at 2:43 AM, Carlos Fillol <[hidden email]> wrote:
Hi Ann,

You can do something like this to include your plugin java classes:

<%
require 'java'

Dir["../deploy/plugins/yourpluginid/\*.jar"].each { |jar| require jar }
Dir["../deploy/plugins/yourpluginid/META-INF/lib/\*.jar"].each { |jar| require jar }

include_class "com.shawinc.sonar.metric.CpMetrics"
%>

But be careful! This is not recomended because ruby classloader is shared among all the plugins. That means that if you have two plugins deployed in Sonar, one of them using sonar-changepoint-plugin-1.0.jar classes and the other one using sonar-changepoint-plugin-2.0.jar you don't know which classes will be used at the end.

There will be no problem if you are sure that there will be only one deployed plugin using sonar-changepoint-plugin-X.jar.

______________________________________
Carlos Fillol Sendra (Linkedin)
t: 96 629 13 41 - t: 96 325 48 08



2012/6/18 Ann Campbell <[hidden email]>
To do what I've come up with (in my Ruby-newbie-tude)...

I'm working on my plugin to use the extension point for reviews. While I wait for the web service method on the other side that will allow the insert to actually take place, I thought I'd do a full replication of the Jira plugin functionality, & grab request counts too. (That read-only web service method was pretty easy to get :-)

I've created classes for my local request type and request status. Since we have 6 request types (that I know of) and 6 request statuses (that I'm interested in) I've got a matrix of 36 metrics, and I need knowledge of them on both the Java and Ruby sides. The easiest (& most efficient) thing to do seemed to be to set up some static lists:

  public static final CpStatus[] statii = {
    new CpStatus("isValidation", "IS Validation", Metric.DIRECTION_NONE,"FFCC33"),
    new CpStatus("backlog", "In Backlog", Metric.DIRECTION_NONE, "E0E0E0"),
// and so on

  public static final CpRequestType [] requestTypes = {
    new CpRequestType("dataAssistance", "Data Assistance", "Data Asst"),
    new CpRequestType("enhancement", "Enhancement / Maintenance", "Ehnanc / Maint"),
//&etc

I use these to generate my list of metrics and on the Ruby side, for my widgets, I use these lists to know how to abbreviate things, how to color them & so on.

I have been getting to them from the erb's like so:

<%
require 'java'
require 'C:/sonar/sonar-3.1/extensions/plugins/sonar-changepoint-plugin-0.1-SNAPSHOT.jar'
include_class "com.shawinc.sonar.metric.CpMetrics"


But clearly the fact that the version number is in the jar name is going to be a pain for every subsequent revision, because I'll have to remember to modify my erb's. (And I'm not likely to actually remember.)

I started to do some research on Maven-based, build-time token replacement, but it's ... unattractive.

And it occurred to me that maybe I should first verify that I'm going about this the right way...?


Any insight appreciated,
Ann


--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************





--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720




--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] I hope there's a less ugly way

Ann Campbell
Thanks Simon! I'll give this a go. Simply using the class without including the jar didn't seem to work at all. 

On Thu, Jun 28, 2012 at 9:47 AM, Simon Brandhof <[hidden email]> wrote:
I'm back from holidays, so sorry for the late answer. Reloading the JAR files is definitely not a good idea. You could give a try to the following :
  • Java::ComShawincSonarMetric::CpMetrics::statii
  • or if CppMetrics implements ServerExtension, controllers can get a reference with : java_facade.getCoreComponentByClassname('com.shawinc.sonar.metric.CpMetrics')


On 21 June 2012 18:33, Ann Campbell <[hidden email]> wrote:
Thought I'd share what I ended up with. It probably still counts as a hack, but at least it's not a hack I'll have to update for every release. Carlos, with your warning in mind, I tossed in a break after the first regex match, so it'll only pull in one version of the plugin. And shame on me if I have multiple copies in there!

require 'java'
Dir["../**/sonar-changepoint\*.jar"].each { |jar|
  require jar
  break
}
include_class "com.shawinc.sonar.metric.CpMetrics"


:-)
Ann


On Tue, Jun 19, 2012 at 8:04 AM, Ann Campbell <[hidden email]> wrote:
Thanks Carlos!


On Tue, Jun 19, 2012 at 2:43 AM, Carlos Fillol <[hidden email]> wrote:
Hi Ann,

You can do something like this to include your plugin java classes:

<%
require 'java'

Dir["../deploy/plugins/yourpluginid/\*.jar"].each { |jar| require jar }
Dir["../deploy/plugins/yourpluginid/META-INF/lib/\*.jar"].each { |jar| require jar }

include_class "com.shawinc.sonar.metric.CpMetrics"
%>

But be careful! This is not recomended because ruby classloader is shared among all the plugins. That means that if you have two plugins deployed in Sonar, one of them using sonar-changepoint-plugin-1.0.jar classes and the other one using sonar-changepoint-plugin-2.0.jar you don't know which classes will be used at the end.

There will be no problem if you are sure that there will be only one deployed plugin using sonar-changepoint-plugin-X.jar.

______________________________________
Carlos Fillol Sendra (Linkedin)
t: 96 629 13 41 - t: 96 325 48 08



2012/6/18 Ann Campbell <[hidden email]>
To do what I've come up with (in my Ruby-newbie-tude)...

I'm working on my plugin to use the extension point for reviews. While I wait for the web service method on the other side that will allow the insert to actually take place, I thought I'd do a full replication of the Jira plugin functionality, & grab request counts too. (That read-only web service method was pretty easy to get :-)

I've created classes for my local request type and request status. Since we have 6 request types (that I know of) and 6 request statuses (that I'm interested in) I've got a matrix of 36 metrics, and I need knowledge of them on both the Java and Ruby sides. The easiest (& most efficient) thing to do seemed to be to set up some static lists:

  public static final CpStatus[] statii = {
    new CpStatus("isValidation", "IS Validation", Metric.DIRECTION_NONE,"FFCC33"),
    new CpStatus("backlog", "In Backlog", Metric.DIRECTION_NONE, "E0E0E0"),
// and so on

  public static final CpRequestType [] requestTypes = {
    new CpRequestType("dataAssistance", "Data Assistance", "Data Asst"),
    new CpRequestType("enhancement", "Enhancement / Maintenance", "Ehnanc / Maint"),
//&etc

I use these to generate my list of metrics and on the Ruby side, for my widgets, I use these lists to know how to abbreviate things, how to color them & so on.

I have been getting to them from the erb's like so:

<%
require 'java'
require 'C:/sonar/sonar-3.1/extensions/plugins/sonar-changepoint-plugin-0.1-SNAPSHOT.jar'
include_class "com.shawinc.sonar.metric.CpMetrics"


But clearly the fact that the version number is in the jar name is going to be a pain for every subsequent revision, because I'll have to remember to modify my erb's. (And I'm not likely to actually remember.)

I started to do some research on Maven-based, build-time token replacement, but it's ... unattractive.

And it occurred to me that maybe I should first verify that I'm going about this the right way...?


Any insight appreciated,
Ann


--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************





--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720




--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************





--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [sonar-dev] I hope there's a less ugly way

Ann Campbell
Simon, is this method truly available to non-core widgets/erb templates?

I ask because this code (in my widget's erb file):
<%= controller.java_facade.getCoreComponentByClassname('com.shawinc.sonar.metric.CpMetrics').statii.length -%>

gets me this in sonar.log:
2012.07.05 09:43:08 ERROR o.s.s.ui.JRubyFacade  Component not found: com.shawinc.sonar.metric.CpMetrics
java.lang.ClassNotFoundException: com.shawinc.sonar.metric.CpMetrics
< very long stack trace omitted >

and this in profiling.log:
ERROR rails  Can not render widget cpRequestLinkedReviewsWidget: undefined method `statii' for nil:NilClass
< much omitted >

statii is a static array in the class, BTW.

Could the fact that I'm still explicitly including the jar in my other widgets be interfering - even though they're not being rendered? (And I don't believe they've been rendered / executed since the last time I restarted my server. Although I could easily be wrong on that.)

Also, this reference I'm supposed to be getting... Is that a reference to the uninstantiated class definition (my assumption from my other reading online) or might it be (hope of hopes!) a reference to the instance that's "up" in Sonar? 


Thx!
Ann


On Thu, Jun 28, 2012 at 11:30 AM, Ann Campbell <[hidden email]> wrote:
Thanks Simon! I'll give this a go. Simply using the class without including the jar didn't seem to work at all. 


On Thu, Jun 28, 2012 at 9:47 AM, Simon Brandhof <[hidden email]> wrote:
I'm back from holidays, so sorry for the late answer. Reloading the JAR files is definitely not a good idea. You could give a try to the following :
  • Java::ComShawincSonarMetric::CpMetrics::statii
  • or if CppMetrics implements ServerExtension, controllers can get a reference with : java_facade.getCoreComponentByClassname('com.shawinc.sonar.metric.CpMetrics')


On 21 June 2012 18:33, Ann Campbell <[hidden email]> wrote:
Thought I'd share what I ended up with. It probably still counts as a hack, but at least it's not a hack I'll have to update for every release. Carlos, with your warning in mind, I tossed in a break after the first regex match, so it'll only pull in one version of the plugin. And shame on me if I have multiple copies in there!

require 'java'
Dir["../**/sonar-changepoint\*.jar"].each { |jar|
  require jar
  break
}
include_class "com.shawinc.sonar.metric.CpMetrics"


:-)
Ann


On Tue, Jun 19, 2012 at 8:04 AM, Ann Campbell <[hidden email]> wrote:
Thanks Carlos!


On Tue, Jun 19, 2012 at 2:43 AM, Carlos Fillol <[hidden email]> wrote:
Hi Ann,

You can do something like this to include your plugin java classes:

<%
require 'java'

Dir["../deploy/plugins/yourpluginid/\*.jar"].each { |jar| require jar }
Dir["../deploy/plugins/yourpluginid/META-INF/lib/\*.jar"].each { |jar| require jar }

include_class "com.shawinc.sonar.metric.CpMetrics"
%>

But be careful! This is not recomended because ruby classloader is shared among all the plugins. That means that if you have two plugins deployed in Sonar, one of them using sonar-changepoint-plugin-1.0.jar classes and the other one using sonar-changepoint-plugin-2.0.jar you don't know which classes will be used at the end.

There will be no problem if you are sure that there will be only one deployed plugin using sonar-changepoint-plugin-X.jar.

______________________________________
Carlos Fillol Sendra (Linkedin)
t: 96 629 13 41 - t: 96 325 48 08



2012/6/18 Ann Campbell <[hidden email]>
To do what I've come up with (in my Ruby-newbie-tude)...

I'm working on my plugin to use the extension point for reviews. While I wait for the web service method on the other side that will allow the insert to actually take place, I thought I'd do a full replication of the Jira plugin functionality, & grab request counts too. (That read-only web service method was pretty easy to get :-)

I've created classes for my local request type and request status. Since we have 6 request types (that I know of) and 6 request statuses (that I'm interested in) I've got a matrix of 36 metrics, and I need knowledge of them on both the Java and Ruby sides. The easiest (& most efficient) thing to do seemed to be to set up some static lists:

  public static final CpStatus[] statii = {
    new CpStatus("isValidation", "IS Validation", Metric.DIRECTION_NONE,"FFCC33"),
    new CpStatus("backlog", "In Backlog", Metric.DIRECTION_NONE, "E0E0E0"),
// and so on

  public static final CpRequestType [] requestTypes = {
    new CpRequestType("dataAssistance", "Data Assistance", "Data Asst"),
    new CpRequestType("enhancement", "Enhancement / Maintenance", "Ehnanc / Maint"),
//&etc

I use these to generate my list of metrics and on the Ruby side, for my widgets, I use these lists to know how to abbreviate things, how to color them & so on.

I have been getting to them from the erb's like so:

<%
require 'java'
require 'C:/sonar/sonar-3.1/extensions/plugins/sonar-changepoint-plugin-0.1-SNAPSHOT.jar'
include_class "com.shawinc.sonar.metric.CpMetrics"


But clearly the fact that the version number is in the jar name is going to be a pain for every subsequent revision, because I'll have to remember to modify my erb's. (And I'm not likely to actually remember.)

I started to do some research on Maven-based, build-time token replacement, but it's ... unattractive.

And it occurred to me that maybe I should first verify that I'm going about this the right way...?


Any insight appreciated,
Ann


--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************





--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720




--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************





--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720




--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[sonar-dev] Re: I hope there's a less ugly way

Ann Campbell
In reply to this post by Ann Campbell
It might be relevant to add that CpMetrics initially implemented only Metrics, but now it implements ServerExtension as well. 

My current actual target is a different class entirely, but I thought I would simplify tests by working against a class with public static members.

On Mon, Jun 18, 2012 at 5:18 PM, Ann Campbell <[hidden email]> wrote:
To do what I've come up with (in my Ruby-newbie-tude)...

I'm working on my plugin to use the extension point for reviews. While I wait for the web service method on the other side that will allow the insert to actually take place, I thought I'd do a full replication of the Jira plugin functionality, & grab request counts too. (That read-only web service method was pretty easy to get :-)

I've created classes for my local request type and request status. Since we have 6 request types (that I know of) and 6 request statuses (that I'm interested in) I've got a matrix of 36 metrics, and I need knowledge of them on both the Java and Ruby sides. The easiest (& most efficient) thing to do seemed to be to set up some static lists:

  public static final CpStatus[] statii = {
    new CpStatus("isValidation", "IS Validation", Metric.DIRECTION_NONE,"FFCC33"),
    new CpStatus("backlog", "In Backlog", Metric.DIRECTION_NONE, "E0E0E0"),
// and so on

  public static final CpRequestType [] requestTypes = {
    new CpRequestType("dataAssistance", "Data Assistance", "Data Asst"),
    new CpRequestType("enhancement", "Enhancement / Maintenance", "Ehnanc / Maint"),
//&etc

I use these to generate my list of metrics and on the Ruby side, for my widgets, I use these lists to know how to abbreviate things, how to color them & so on.

I have been getting to them from the erb's like so:

<%
require 'java'
require 'C:/sonar/sonar-3.1/extensions/plugins/sonar-changepoint-plugin-0.1-SNAPSHOT.jar'
include_class "com.shawinc.sonar.metric.CpMetrics"


But clearly the fact that the version number is in the jar name is going to be a pain for every subsequent revision, because I'll have to remember to modify my erb's. (And I'm not likely to actually remember.)

I started to do some research on Maven-based, build-time token replacement, but it's ... unattractive.

And it occurred to me that maybe I should first verify that I'm going about this the right way...?


Any insight appreciated,
Ann


--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720




--
G. Ann Campbell
Sr. Systems Engineer, IS Production Systems - Shop Floor Systems
Shaw Industries Inc,
201 S. Hamilton St.
Dalton Ga 30720


**********************************************************
Privileged and/or confidential information may be contained in this message. If you are not the addressee indicated in this message (or are not responsible for delivery of this message to that person) , you may not copy or deliver this message to anyone. In such case, you should destroy this message and notify the sender by reply e-mail.
If you or your employer do not consent to Internet e-mail for messages of this kind, please advise the sender.
Shaw Industries does not provide or endorse any opinions, conclusions or other information in this message that do not relate to the official business of the company  or its subsidiaries.
**********************************************************

Loading...