[sonar-dev] plugin access to sonar.home as classpath

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

[sonar-dev] plugin access to sonar.home as classpath

aldana
Hi,

from plugin I need access to /extensions/plugins (where you can define
custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins
seemed to be wrong.

My next guess is, the only way to gain access is to define
RulesRepository implementation and pass back as extension. Inside
RulesRepository I then would have access to the sonar.home as classpath
entry. Am I correct or are there alternatives to get access to
sonar.home without any extensions points?

thanks for help.

--
  manuel aldana
  [hidden email]
  software-engineering blog: http://www.aldana-online.de


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

Freddy Mallet SonarSource
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

aldana
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.


On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

Simon Brandhof
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de

Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

Simon Brandhof
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 


My mistake, hard monday morning, this is not the case anymore since release 2.2.
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

aldana
In reply to this post by Simon Brandhof
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?


On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

Simon Brandhof
I forgot to ask you the version of sonar ?


On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana <[hidden email]> wrote:
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?



On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de

Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

aldana
see below in my 'pwd' command ;)  it is sonar 2.2.

On 14/09/10 22:17, Simon Brandhof wrote:
I forgot to ask you the version of sonar ?


On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana <[hidden email]> wrote:
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?



On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

Simon Brandhof
Ok I've done some tests. This issue relates to SONAR-1693, fixed in version 2.3.
You can test this (ugly) workaround : getResource("/extensions/.../<filename>")
I'm not sure but it should work.


On Tue, Sep 14, 2010 at 10:23 PM, manuel aldana <[hidden email]> wrote:
see below in my 'pwd' command ;)  it is sonar 2.2.


On 14/09/10 22:17, Simon Brandhof wrote:
I forgot to ask you the version of sonar ?


On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana <[hidden email]> wrote:
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?



On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de

Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

aldana
I tried out it with 2.3 current trunk (both server and maven plugin). Same problems here:
===
getClass().getResource("/extensions/rules/codesize/codesize-config.xml")
getClass().getResource("/codesize-config.xml")

Maybe I overlooked something. As last resort will debug the plugin classloading of sonar. I guess I have to look inside the sonar-maven-plugin code?


On 14/09/10 23:48, Simon Brandhof wrote:
Ok I've done some tests. This issue relates to SONAR-1693, fixed in version 2.3.
You can test this (ugly) workaround : getResource("/extensions/.../<filename>")
I'm not sure but it should work.


On Tue, Sep 14, 2010 at 10:23 PM, manuel aldana <[hidden email]> wrote:
see below in my 'pwd' command ;)  it is sonar 2.2.


On 14/09/10 22:17, Simon Brandhof wrote:
I forgot to ask you the version of sonar ?


On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana <[hidden email]> wrote:
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?



On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

Simon Brandhof
Your plugin must be built with the sonar-plugin packaging. It should fix your issue.
See http://docs.codehaus.org/display/SONAR/Upgrading+plugins+to+version+2.2


On Wed, Sep 15, 2010 at 9:55 PM, manuel aldana <[hidden email]> wrote:
I tried out it with 2.3 current trunk (both server and maven plugin). Same problems here:
===
getClass().getResource("/extensions/rules/codesize/codesize-config.xml")
getClass().getResource("/codesize-config.xml")

Maybe I overlooked something. As last resort will debug the plugin classloading of sonar. I guess I have to look inside the sonar-maven-plugin code?



On 14/09/10 23:48, Simon Brandhof wrote:
Ok I've done some tests. This issue relates to SONAR-1693, fixed in version 2.3.
You can test this (ugly) workaround : getResource("/extensions/.../<filename>")
I'm not sure but it should work.


On Tue, Sep 14, 2010 at 10:23 PM, manuel aldana <[hidden email]> wrote:
see below in my 'pwd' command ;)  it is sonar 2.2.


On 14/09/10 22:17, Simon Brandhof wrote:
I forgot to ask you the version of sonar ?


On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana <[hidden email]> wrote:
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?



On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de

Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

aldana
It is there https://svn.codehaus.org/sonar-plugins/trunk/codesize/pom.xml

On 09/15/2010 11:05 PM, Simon Brandhof wrote:
Your plugin must be built with the sonar-plugin packaging. It should fix your issue.
See http://docs.codehaus.org/display/SONAR/Upgrading+plugins+to+version+2.2


On Wed, Sep 15, 2010 at 9:55 PM, manuel aldana <[hidden email]> wrote:
I tried out it with 2.3 current trunk (both server and maven plugin). Same problems here:
===
getClass().getResource("/extensions/rules/codesize/codesize-config.xml")
getClass().getResource("/codesize-config.xml")

Maybe I overlooked something. As last resort will debug the plugin classloading of sonar. I guess I have to look inside the sonar-maven-plugin code?



On 14/09/10 23:48, Simon Brandhof wrote:
Ok I've done some tests. This issue relates to SONAR-1693, fixed in version 2.3.
You can test this (ugly) workaround : getResource("/extensions/.../<filename>")
I'm not sure but it should work.


On Tue, Sep 14, 2010 at 10:23 PM, manuel aldana <[hidden email]> wrote:
see below in my 'pwd' command ;)  it is sonar 2.2.


On 14/09/10 22:17, Simon Brandhof wrote:
I forgot to ask you the version of sonar ?


On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana <[hidden email]> wrote:
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?



On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 mail: [hidden email] | [hidden email]
 blog: www.aldana-online.de
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

Simon Brandhof
Ok, the plugin key is set to "sonar-codesize-plugin", so you have to put the files in /rules/extensions/sonar-codesize-plugin. 
The method Plugin.getKey() is not used anymore but unfortunately it can not be removed for backward-compatibility reasons.


On Thu, Sep 16, 2010 at 11:39 AM, manuel aldana <[hidden email]> wrote:
It is there https://svn.codehaus.org/sonar-plugins/trunk/codesize/pom.xml


On 09/15/2010 11:05 PM, Simon Brandhof wrote:
Your plugin must be built with the sonar-plugin packaging. It should fix your issue.
See http://docs.codehaus.org/display/SONAR/Upgrading+plugins+to+version+2.2


On Wed, Sep 15, 2010 at 9:55 PM, manuel aldana <[hidden email]> wrote:
I tried out it with 2.3 current trunk (both server and maven plugin). Same problems here:
===
getClass().getResource("/extensions/rules/codesize/codesize-config.xml")
getClass().getResource("/codesize-config.xml")

Maybe I overlooked something. As last resort will debug the plugin classloading of sonar. I guess I have to look inside the sonar-maven-plugin code?



On 14/09/10 23:48, Simon Brandhof wrote:
Ok I've done some tests. This issue relates to SONAR-1693, fixed in version 2.3.
You can test this (ugly) workaround : getResource("/extensions/.../<filename>")
I'm not sure but it should work.


On Tue, Sep 14, 2010 at 10:23 PM, manuel aldana <[hidden email]> wrote:
see below in my 'pwd' command ;)  it is sonar 2.2.


On 14/09/10 22:17, Simon Brandhof wrote:
I forgot to ask you the version of sonar ?


On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana <[hidden email]> wrote:
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?



On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 mail: [hidden email] | [hidden email]
 blog: www.aldana-online.de

Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

aldana
I see,

on my local working copy I renamed Plugin.getKey() to "codesize"
https://svn.codehaus.org/sonar-plugins/trunk/codesize/src/main/java/org/sonar/plugins/codesize/CodeSizePlugin.java.
Maybe this was the reason paths got ignored, because
<pluginKey>sonar-codesize-plugin</pluginKey> is the "real" plugin-key.

Maybe it would help to mark getKey() deprecated
(https://svn.codehaus.org/sonar/trunk/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java),
so api-users get better notified not to rely or use this method for new
plugins.

thanks for help (will confirm in next days that this was the issue.

On 09/16/2010 11:44 AM, Simon Brandhof wrote:

> Ok, the plugin key is set to "sonar-codesize-plugin", so you have to
> put the files in /rules/extensions/sonar-codesize-plugin.
> The method Plugin.getKey() is not used anymore but unfortunately it
> can not be removed for backward-compatibility reasons.
>
>
> On Thu, Sep 16, 2010 at 11:39 AM, manuel aldana <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     It is there
>     https://svn.codehaus.org/sonar-plugins/trunk/codesize/pom.xml
>
>
>     On 09/15/2010 11:05 PM, Simon Brandhof wrote:
>>     Your plugin must be built with the sonar-plugin packaging. It
>>     should fix your issue.
>>     See
>>     http://docs.codehaus.org/display/SONAR/Upgrading+plugins+to+version+2.2
>>
>>
>>
>>     On Wed, Sep 15, 2010 at 9:55 PM, manuel aldana <[hidden email]
>>     <mailto:[hidden email]>> wrote:
>>
>>         I tried out it with 2.3 current trunk (both server and maven
>>         plugin). Same problems here:
>>         ===
>>         getClass().getResource("/extensions/rules/codesize/codesize-config.xml")
>>         getClass().getResource("/codesize-config.xml")
>>
>>         Maybe I overlooked something. As last resort will debug the
>>         plugin classloading of sonar. I guess I have to look inside
>>         the sonar-maven-plugin code?
>>
>>
>>
>>         On 14/09/10 23:48, Simon Brandhof wrote:
>>>         Ok I've done some tests. This issue relates to SONAR-1693
>>>         <http://jira.codehaus.org/browse/SONAR-1693>, fixed in
>>>         version 2.3.
>>>         You can test this (ugly) workaround :
>>>         getResource("/extensions/.../<filename>")
>>>         I'm not sure but it should work.
>>>
>>>
>>>         On Tue, Sep 14, 2010 at 10:23 PM, manuel aldana
>>>         <[hidden email] <mailto:[hidden email]>> wrote:
>>>
>>>             see below in my 'pwd' command ;)  it is sonar 2.2.
>>>
>>>
>>>             On 14/09/10 22:17, Simon Brandhof wrote:
>>>>             I forgot to ask you the version of sonar ?
>>>>
>>>>
>>>>             On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana
>>>>             <[hidden email] <mailto:[hidden email]>> wrote:
>>>>
>>>>                 Hmm, I tried it out, but no success.
>>>>
>>>>                 plugin-def:
>>>>                 ===
>>>>                 class CodesizePlugin implements Plugin { ...
>>>>                  private static final String KEY = "codesize";
>>>>                  public String getKey() {
>>>>                     return KEY;
>>>>                  }
>>>>                 ...
>>>>
>>>>
>>>>                 config-file place:
>>>>                 ===
>>>>                 $ pwd
>>>>                 /home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
>>>>                 $ ls codesize
>>>>                 codesize-config.xml
>>>>
>>>>
>>>>                 config loading:
>>>>                 ===
>>>>                 class SizingMetrics implements Metrics {
>>>>                 ...
>>>>                  private String getConfigurationFromFile() {
>>>>                   InputStream customConfig =
>>>>                 getClass().getResourceAsStream(CUSTOM_CONFIG);
>>>>
>>>>                   if (customConfig == null) // <<< is always null
>>>>                 (i.e. cannot load stream)
>>>>                    return fallbackToDefaultConfig();
>>>>                 ...
>>>>
>>>>
>>>>                 Maybe I missed something?
>>>>
>>>>
>>>>
>>>>                 On 13/09/10 10:29, Simon Brandhof wrote:
>>>>>                 It's badly named, but the directory
>>>>>                 /extensions/rules/<plugin id> is available in the
>>>>>                 plugin classloader, so files in this directory can
>>>>>                 be loaded with getClass().getResource("/foo.xml").
>>>>>                 Just for information, the limitation with
>>>>>                 configuration files on disk is that they require
>>>>>                 the WAR to be rebuilt when not using the
>>>>>                 standalone mode.
>>>>>
>>>>>                 Regards
>>>>>                 Simon
>>>>>
>>>>>                 On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana
>>>>>                 <[hidden email] <mailto:[hidden email]>> wrote:
>>>>>
>>>>>                     Hey Freddy,
>>>>>
>>>>>                     I am currently extending the alpha-phase
>>>>>                     codesize plugin. It has a default config which
>>>>>                     should be possible to customized (e.g. type of
>>>>>                     file extensions + source-folders + delimiters
>>>>>                     for statement counting).
>>>>>
>>>>>                     Similar to the taglist plugin, where you can
>>>>>                     extend custom configuration inside
>>>>>                     /extension/plugins/taglist.properties.
>>>>>
>>>>>                     The use of simple properties doesn't suffice,
>>>>>                     because the config has nested structure.
>>>>>
>>>>>
>>>>>
>>>>>                     On 12/09/10 20:24, Freddy Mallet wrote:
>>>>>>                     Hi Manuel,
>>>>>>
>>>>>>                     Could you first explain what kind of
>>>>>>                     configuration you want to define in the xml
>>>>>>                     configuration file ? Indeed,
>>>>>>                     the straightforward solution is to define
>>>>>>                     some properties on your plugin with the
>>>>>>                     @Properties and @Property annotations (see
>>>>>>                     http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java
>>>>>>                     for an example). With those annotations, the
>>>>>>                     administration of your plugin will be
>>>>>>                     possible through the global settings page.
>>>>>>
>>>>>>                     regards,
>>>>>>                     Freddy
>>>>>>
>>>>>>                     ----------------------------------------
>>>>>>                     Freddy Mallet
>>>>>>                     www.SonarSource.org <http://www.SonarSource.org>
>>>>>>                     www.SonarSource.com <http://www.SonarSource.com>
>>>>>>                     ----------------------------------------
>>>>>>
>>>>>>
>>>>>>                     On Sat, Sep 11, 2010 at 6:27 PM, manuel
>>>>>>                     aldana <[hidden email] <mailto:[hidden email]>>
>>>>>>                     wrote:
>>>>>>
>>>>>>                         Hi,
>>>>>>
>>>>>>                         from plugin I need access to
>>>>>>                         /extensions/plugins (where you can define
>>>>>>                         custom config file). But doing following
>>>>>>                         wouldn't find the file:
>>>>>>                         ===
>>>>>>                         getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")
>>>>>>
>>>>>>                         My first guess that sonar.home would be
>>>>>>                         inside classpath for all plugins seemed
>>>>>>                         to be wrong.
>>>>>>
>>>>>>                         My next guess is, the only way to gain
>>>>>>                         access is to define RulesRepository
>>>>>>                         implementation and pass back as
>>>>>>                         extension. Inside RulesRepository I then
>>>>>>                         would have access to the sonar.home as
>>>>>>                         classpath entry. Am I correct or are
>>>>>>                         there alternatives to get access to
>>>>>>                         sonar.home without any extensions points?
>>>>>>
>>>>>>                         thanks for help.
>>>>>>
>>>>>>                         --
>>>>>>                          manuel aldana
>>>>>>                         [hidden email] <mailto:[hidden email]>
>>>>>>                          software-engineering blog:
>>>>>>                         http://www.aldana-online.de
>>>>>>
>>>>>>
>>>>>>                         ---------------------------------------------------------------------
>>>>>>                         To unsubscribe from this list, please visit:
>>>>>>
>>>>>>                         http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>                     --
>>>>>                       manuel aldana
>>>>>                       [hidden email]  <mailto:[hidden email]>
>>>>>                       software-engineering blog:http://www.aldana-online.de
>>>>>                          
>>>>>
>>>>>
>>>>
>>>>
>>>>                 --
>>>>                   manuel aldana
>>>>                   [hidden email]  <mailto:[hidden email]>
>>>>                   software-engineering blog:http://www.aldana-online.de
>>>>                      
>>>>
>>>>
>>>
>>>
>>>             --
>>>               manuel aldana
>>>               [hidden email]  <mailto:[hidden email]>
>>>               software-engineering blog:http://www.aldana-online.de
>>>                  
>>>
>>>
>>
>>
>>         --
>>           manuel aldana
>>           [hidden email]  <mailto:[hidden email]>
>>           software-engineering blog:http://www.aldana-online.de
>>              
>>
>>
>
>
>     --
>       manuel aldana
>       mail:[hidden email]  <mailto:[hidden email]>  |[hidden email]  <mailto:[hidden email]>
>       blog:www.aldana-online.de  <http://www.aldana-online.de>
>
>


--
  manuel aldana
  mail: [hidden email] | [hidden email]
  blog: www.aldana-online.de


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

aldana
In reply to this post by Simon Brandhof
Hmm, still not working...

I debugged through code, especially http://svn.codehaus.org/sonar/trunk/sonar-batch/src/main/java/org/sonar/batch/BatchPluginRepository.java, where RemoteClassLoader is intialized for each plugin (you seem to propagate all relevant classpath entries as HTTP resources).

It only adds URL an entries referred by table sonar.plugin_files, but it never passes the /rules to the RemoteClassLoader. Also the rules folder doesn't seem to be added as a HTTP resources (e.g. http://localhost:9000/deploy/rules/pmd/README.txt is giving 404).

- Is there another place where classpath is extended?
- Maybe the /rules/<pluingKey> classpath part is a missing feature (not added as HTTP resource and not added RemoteClassLoader)?
- Maybe I am going wrong approach to load file from /rules folder and should go "more backend". But I like the approach to configure a plugin from a file, it is simple and /rules/<pluginKey> folder makes sense for that.


On 16/09/10 11:44, Simon Brandhof wrote:
Ok, the plugin key is set to "sonar-codesize-plugin", so you have to put the files in /rules/extensions/sonar-codesize-plugin. 
The method Plugin.getKey() is not used anymore but unfortunately it can not be removed for backward-compatibility reasons.


On Thu, Sep 16, 2010 at 11:39 AM, manuel aldana <[hidden email]> wrote:
It is there https://svn.codehaus.org/sonar-plugins/trunk/codesize/pom.xml


On 09/15/2010 11:05 PM, Simon Brandhof wrote:
Your plugin must be built with the sonar-plugin packaging. It should fix your issue.
See http://docs.codehaus.org/display/SONAR/Upgrading+plugins+to+version+2.2


On Wed, Sep 15, 2010 at 9:55 PM, manuel aldana <[hidden email]> wrote:
I tried out it with 2.3 current trunk (both server and maven plugin). Same problems here:
===
getClass().getResource("/extensions/rules/codesize/codesize-config.xml")
getClass().getResource("/codesize-config.xml")

Maybe I overlooked something. As last resort will debug the plugin classloading of sonar. I guess I have to look inside the sonar-maven-plugin code?



On 14/09/10 23:48, Simon Brandhof wrote:
Ok I've done some tests. This issue relates to SONAR-1693, fixed in version 2.3.
You can test this (ugly) workaround : getResource("/extensions/.../<filename>")
I'm not sure but it should work.


On Tue, Sep 14, 2010 at 10:23 PM, manuel aldana <[hidden email]> wrote:
see below in my 'pwd' command ;)  it is sonar 2.2.


On 14/09/10 22:17, Simon Brandhof wrote:
I forgot to ask you the version of sonar ?


On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana <[hidden email]> wrote:
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?



On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 mail: [hidden email] | [hidden email]
 blog: www.aldana-online.de



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

aldana
On 02/10/10 16:38, manuel aldana wrote:
Hmm, still not working...

I debugged through code, especially http://svn.codehaus.org/sonar/trunk/sonar-batch/src/main/java/org/sonar/batch/BatchPluginRepository.java, where RemoteClassLoader is intialized for each plugin (you seem to propagate all relevant classpath entries as HTTP resources).

It only adds URL an entries referred by table sonar.plugin_files, but it never passes the /rules to the RemoteClassLoader. Also the rules folder doesn't seem to be added as a HTTP resources (e.g. http://localhost:9000/deploy/rules/pmd/README.txt is giving 404).

- Is there another place where classpath is extended?
- Maybe the /rules/<pluingKey> classpath part is a missing feature (not added as HTTP resource and not added RemoteClassLoader)?
I can now confirm this: Folder on file-system ${sonar.web.deployDir} does not contain the /rules folder (only /gwt + /maven + /plugins). The same counts for the classpaths (only /plugins resources are loaded). Am I correct that this is worth a jira ticket or did I overlook something?


- Maybe I am going wrong approach to load file from /rules folder and should go "more backend". But I like the approach to configure a plugin from a file, it is simple and /rules/<pluginKey> folder makes sense for that.


On 16/09/10 11:44, Simon Brandhof wrote:
Ok, the plugin key is set to "sonar-codesize-plugin", so you have to put the files in /rules/extensions/sonar-codesize-plugin. 
The method Plugin.getKey() is not used anymore but unfortunately it can not be removed for backward-compatibility reasons.


On Thu, Sep 16, 2010 at 11:39 AM, manuel aldana <[hidden email]> wrote:
It is there https://svn.codehaus.org/sonar-plugins/trunk/codesize/pom.xml


On 09/15/2010 11:05 PM, Simon Brandhof wrote:
Your plugin must be built with the sonar-plugin packaging. It should fix your issue.
See http://docs.codehaus.org/display/SONAR/Upgrading+plugins+to+version+2.2


On Wed, Sep 15, 2010 at 9:55 PM, manuel aldana <[hidden email]> wrote:
I tried out it with 2.3 current trunk (both server and maven plugin). Same problems here:
===
getClass().getResource("/extensions/rules/codesize/codesize-config.xml")
getClass().getResource("/codesize-config.xml")

Maybe I overlooked something. As last resort will debug the plugin classloading of sonar. I guess I have to look inside the sonar-maven-plugin code?



On 14/09/10 23:48, Simon Brandhof wrote:
Ok I've done some tests. This issue relates to SONAR-1693, fixed in version 2.3.
You can test this (ugly) workaround : getResource("/extensions/.../<filename>")
I'm not sure but it should work.


On Tue, Sep 14, 2010 at 10:23 PM, manuel aldana <[hidden email]> wrote:
see below in my 'pwd' command ;)  it is sonar 2.2.


On 14/09/10 22:17, Simon Brandhof wrote:
I forgot to ask you the version of sonar ?


On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana <[hidden email]> wrote:
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?



On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 mail: [hidden email] | [hidden email]
 blog: www.aldana-online.de



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
  


-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

Simon
Administrator
You're right Manuel. The files stored in extensions/rules/ are available in server-side extensions, but not in batch extensions. Can you file an issue in JIRA please ?


On Sat, Oct 2, 2010 at 4:58 PM, manuel aldana <[hidden email]> wrote:
On 02/10/10 16:38, manuel aldana wrote:
Hmm, still not working...

I debugged through code, especially http://svn.codehaus.org/sonar/trunk/sonar-batch/src/main/java/org/sonar/batch/BatchPluginRepository.java, where RemoteClassLoader is intialized for each plugin (you seem to propagate all relevant classpath entries as HTTP resources).

It only adds URL an entries referred by table sonar.plugin_files, but it never passes the /rules to the RemoteClassLoader. Also the rules folder doesn't seem to be added as a HTTP resources (e.g. http://localhost:9000/deploy/rules/pmd/README.txt is giving 404).

- Is there another place where classpath is extended?
- Maybe the /rules/<pluingKey> classpath part is a missing feature (not added as HTTP resource and not added RemoteClassLoader)?
I can now confirm this: Folder on file-system ${sonar.web.deployDir} does not contain the /rules folder (only /gwt + /maven + /plugins). The same counts for the classpaths (only /plugins resources are loaded). Am I correct that this is worth a jira ticket or did I overlook something?



- Maybe I am going wrong approach to load file from /rules folder and should go "more backend". But I like the approach to configure a plugin from a file, it is simple and /rules/<pluginKey> folder makes sense for that.


On 16/09/10 11:44, Simon Brandhof wrote:
Ok, the plugin key is set to "sonar-codesize-plugin", so you have to put the files in /rules/extensions/sonar-codesize-plugin. 
The method Plugin.getKey() is not used anymore but unfortunately it can not be removed for backward-compatibility reasons.


On Thu, Sep 16, 2010 at 11:39 AM, manuel aldana <[hidden email]> wrote:
It is there https://svn.codehaus.org/sonar-plugins/trunk/codesize/pom.xml


On 09/15/2010 11:05 PM, Simon Brandhof wrote:
Your plugin must be built with the sonar-plugin packaging. It should fix your issue.
See http://docs.codehaus.org/display/SONAR/Upgrading+plugins+to+version+2.2


On Wed, Sep 15, 2010 at 9:55 PM, manuel aldana <[hidden email]> wrote:
I tried out it with 2.3 current trunk (both server and maven plugin). Same problems here:
===
getClass().getResource("/extensions/rules/codesize/codesize-config.xml")
getClass().getResource("/codesize-config.xml")

Maybe I overlooked something. As last resort will debug the plugin classloading of sonar. I guess I have to look inside the sonar-maven-plugin code?



On 14/09/10 23:48, Simon Brandhof wrote:
Ok I've done some tests. This issue relates to SONAR-1693, fixed in version 2.3.
You can test this (ugly) workaround : getResource("/extensions/.../<filename>")
I'm not sure but it should work.


On Tue, Sep 14, 2010 at 10:23 PM, manuel aldana <[hidden email]> wrote:
see below in my 'pwd' command ;)  it is sonar 2.2.


On 14/09/10 22:17, Simon Brandhof wrote:
I forgot to ask you the version of sonar ?


On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana <[hidden email]> wrote:
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?



On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 mail: [hidden email] | [hidden email]
 blog: www.aldana-online.de



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
  


-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de

Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

aldana
I created patch http://jira.codehaus.org/browse/SONAR-1861 including test-case. Please review.

Would be cool to have it part of 2.3.1 release :)

On 11/10/10 23:08, Simon Brandhof wrote:
You're right Manuel. The files stored in extensions/rules/ are available in server-side extensions, but not in batch extensions. Can you file an issue in JIRA please ?


On Sat, Oct 2, 2010 at 4:58 PM, manuel aldana <[hidden email]> wrote:
On 02/10/10 16:38, manuel aldana wrote:
Hmm, still not working...

I debugged through code, especially http://svn.codehaus.org/sonar/trunk/sonar-batch/src/main/java/org/sonar/batch/BatchPluginRepository.java, where RemoteClassLoader is intialized for each plugin (you seem to propagate all relevant classpath entries as HTTP resources).

It only adds URL an entries referred by table sonar.plugin_files, but it never passes the /rules to the RemoteClassLoader. Also the rules folder doesn't seem to be added as a HTTP resources (e.g. http://localhost:9000/deploy/rules/pmd/README.txt is giving 404).

- Is there another place where classpath is extended?
- Maybe the /rules/<pluingKey> classpath part is a missing feature (not added as HTTP resource and not added RemoteClassLoader)?
I can now confirm this: Folder on file-system ${sonar.web.deployDir} does not contain the /rules folder (only /gwt + /maven + /plugins). The same counts for the classpaths (only /plugins resources are loaded). Am I correct that this is worth a jira ticket or did I overlook something?



- Maybe I am going wrong approach to load file from /rules folder and should go "more backend". But I like the approach to configure a plugin from a file, it is simple and /rules/<pluginKey> folder makes sense for that.


On 16/09/10 11:44, Simon Brandhof wrote:
Ok, the plugin key is set to "sonar-codesize-plugin", so you have to put the files in /rules/extensions/sonar-codesize-plugin. 
The method Plugin.getKey() is not used anymore but unfortunately it can not be removed for backward-compatibility reasons.


On Thu, Sep 16, 2010 at 11:39 AM, manuel aldana <[hidden email]> wrote:
It is there https://svn.codehaus.org/sonar-plugins/trunk/codesize/pom.xml


On 09/15/2010 11:05 PM, Simon Brandhof wrote:
Your plugin must be built with the sonar-plugin packaging. It should fix your issue.
See http://docs.codehaus.org/display/SONAR/Upgrading+plugins+to+version+2.2


On Wed, Sep 15, 2010 at 9:55 PM, manuel aldana <[hidden email]> wrote:
I tried out it with 2.3 current trunk (both server and maven plugin). Same problems here:
===
getClass().getResource("/extensions/rules/codesize/codesize-config.xml")
getClass().getResource("/codesize-config.xml")

Maybe I overlooked something. As last resort will debug the plugin classloading of sonar. I guess I have to look inside the sonar-maven-plugin code?



On 14/09/10 23:48, Simon Brandhof wrote:
Ok I've done some tests. This issue relates to SONAR-1693, fixed in version 2.3.
You can test this (ugly) workaround : getResource("/extensions/.../<filename>")
I'm not sure but it should work.


On Tue, Sep 14, 2010 at 10:23 PM, manuel aldana <[hidden email]> wrote:
see below in my 'pwd' command ;)  it is sonar 2.2.


On 14/09/10 22:17, Simon Brandhof wrote:
I forgot to ask you the version of sonar ?


On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana <[hidden email]> wrote:
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?



On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 mail: [hidden email] | [hidden email]
 blog: www.aldana-online.de



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
  


-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
Reply | Threaded
Open this post in threaded view
|

Re: [sonar-dev] plugin access to sonar.home as classpath

Evgeny Mandrikov
Hi,

First of all - thanks for your contribution. But I'm not sure that there would be 2.3.1 release.

On Thu, Oct 14, 2010 at 23:20, manuel aldana <[hidden email]> wrote:
I created patch http://jira.codehaus.org/browse/SONAR-1861 including test-case. Please review.

Would be cool to have it part of 2.3.1 release :)


On 11/10/10 23:08, Simon Brandhof wrote:
You're right Manuel. The files stored in extensions/rules/ are available in server-side extensions, but not in batch extensions. Can you file an issue in JIRA please ?


On Sat, Oct 2, 2010 at 4:58 PM, manuel aldana <[hidden email]> wrote:
On 02/10/10 16:38, manuel aldana wrote:
Hmm, still not working...

I debugged through code, especially http://svn.codehaus.org/sonar/trunk/sonar-batch/src/main/java/org/sonar/batch/BatchPluginRepository.java, where RemoteClassLoader is intialized for each plugin (you seem to propagate all relevant classpath entries as HTTP resources).

It only adds URL an entries referred by table sonar.plugin_files, but it never passes the /rules to the RemoteClassLoader. Also the rules folder doesn't seem to be added as a HTTP resources (e.g. http://localhost:9000/deploy/rules/pmd/README.txt is giving 404).

- Is there another place where classpath is extended?
- Maybe the /rules/<pluingKey> classpath part is a missing feature (not added as HTTP resource and not added RemoteClassLoader)?
I can now confirm this: Folder on file-system ${sonar.web.deployDir} does not contain the /rules folder (only /gwt + /maven + /plugins). The same counts for the classpaths (only /plugins resources are loaded). Am I correct that this is worth a jira ticket or did I overlook something?



- Maybe I am going wrong approach to load file from /rules folder and should go "more backend". But I like the approach to configure a plugin from a file, it is simple and /rules/<pluginKey> folder makes sense for that.


On 16/09/10 11:44, Simon Brandhof wrote:
Ok, the plugin key is set to "sonar-codesize-plugin", so you have to put the files in /rules/extensions/sonar-codesize-plugin. 
The method Plugin.getKey() is not used anymore but unfortunately it can not be removed for backward-compatibility reasons.


On Thu, Sep 16, 2010 at 11:39 AM, manuel aldana <[hidden email]> wrote:
It is there https://svn.codehaus.org/sonar-plugins/trunk/codesize/pom.xml


On 09/15/2010 11:05 PM, Simon Brandhof wrote:
Your plugin must be built with the sonar-plugin packaging. It should fix your issue.
See http://docs.codehaus.org/display/SONAR/Upgrading+plugins+to+version+2.2


On Wed, Sep 15, 2010 at 9:55 PM, manuel aldana <[hidden email]> wrote:
I tried out it with 2.3 current trunk (both server and maven plugin). Same problems here:
===
getClass().getResource("/extensions/rules/codesize/codesize-config.xml")
getClass().getResource("/codesize-config.xml")

Maybe I overlooked something. As last resort will debug the plugin classloading of sonar. I guess I have to look inside the sonar-maven-plugin code?



On 14/09/10 23:48, Simon Brandhof wrote:
Ok I've done some tests. This issue relates to SONAR-1693, fixed in version 2.3.
You can test this (ugly) workaround : getResource("/extensions/.../<filename>")
I'm not sure but it should work.


On Tue, Sep 14, 2010 at 10:23 PM, manuel aldana <[hidden email]> wrote:
see below in my 'pwd' command ;)  it is sonar 2.2.


On 14/09/10 22:17, Simon Brandhof wrote:
I forgot to ask you the version of sonar ?


On Tue, Sep 14, 2010 at 10:03 PM, manuel aldana <[hidden email]> wrote:
Hmm, I tried it out, but no success.

plugin-def:
===
class CodesizePlugin implements Plugin { ...
 private static final String KEY = "codesize";
 public String getKey() {
    return KEY;
 }
...


config-file place:
===
$ pwd
/home/manuel/devel/sonar/sonar-builds/sonar-2.2/extensions/rules
$ ls codesize
codesize-config.xml


config loading:
===
class SizingMetrics implements Metrics {
...
 private String getConfigurationFromFile() {
  InputStream customConfig = getClass().getResourceAsStream(CUSTOM_CONFIG);

  if (customConfig == null) //     <<< is always null (i.e. cannot load stream)
   return fallbackToDefaultConfig();
...


Maybe I missed something?



On 13/09/10 10:29, Simon Brandhof wrote:
It's badly named, but the directory /extensions/rules/<plugin id> is available in the plugin classloader, so files in this directory can be loaded with getClass().getResource("/foo.xml"). 
Just for information, the limitation with configuration files on disk is that they require the WAR to be rebuilt when not using the standalone mode. 

Regards
Simon

On Sun, Sep 12, 2010 at 9:22 PM, manuel aldana <[hidden email]> wrote:
Hey Freddy,

I am currently extending the alpha-phase codesize plugin. It has a default config which should be possible to customized (e.g. type of file extensions + source-folders + delimiters for statement counting).

Similar to the taglist plugin, where you can extend custom configuration inside /extension/plugins/taglist.properties.

The use of simple properties doesn't suffice, because the config has nested structure.



On 12/09/10 20:24, Freddy Mallet wrote:
Hi Manuel,

Could you first explain what kind of configuration you want to define in the xml configuration file ? Indeed, the straightforward solution is to define some properties on your plugin with the @Properties and @Property annotations (see http://svn.codehaus.org/sonar/trunk/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java for an example). With those annotations, the administration of your plugin will be possible through the global settings page.

regards,
Freddy

----------------------------------------
Freddy Mallet
www.SonarSource.org
www.SonarSource.com
----------------------------------------


On Sat, Sep 11, 2010 at 6:27 PM, manuel aldana <[hidden email]> wrote:
Hi,

from plugin I need access to /extensions/plugins (where you can define custom config file). But doing following wouldn't find the file:
===
getClass().getResourceAsStream("/extensions/plugins/config-xxx.xml")

My first guess that sonar.home would be inside classpath for all plugins seemed to be wrong.

My next guess is, the only way to gain access is to define RulesRepository implementation and pass back as extension. Inside RulesRepository I then would have access to the sonar.home as classpath entry. Am I correct or are there alternatives to get access to sonar.home without any extensions points?

thanks for help.

--
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de


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

  http://xircles.codehaus.org/manage_email





-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 mail: [hidden email] | [hidden email]
 blog: www.aldana-online.de



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
  


-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de
    



-- 
 manuel aldana
 [hidden email]
 software-engineering blog: http://www.aldana-online.de



--
Best regards,
Evgeny Mandrikov aka Godin <http://godin.net.ru>
http://twitter.com/_godin_