--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<assembly>
+ <id>distribution</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>standard-plugin</directory>
+ <outputDirectory>standard-plugin</outputDirectory>
+ <includes>
+ <include>src/**/*</include>
+ <include>pom.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>gwt-plugin</directory>
+ <outputDirectory>gwt-plugin</outputDirectory>
+ <includes>
+ <include>src/**/*</include>
+ <include>pom.xml</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.mycompany.sonar</groupId>
+ <artifactId>sonar-gwt-plugin</artifactId>
+ <packaging>sonar-plugin</packaging>
+ <version>2.8-SNAPSHOT</version>
+ <name>Sonar :: Samples :: GWT plugin</name>
+ <description>Description of plugin with GWT extensions</description>
+
+ <properties>
+ <!-- To be replaced with the minimum required version of Sonar -->
+ <sonar.buildVersion>${project.version}</sonar.buildVersion>
+ </properties>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${sonar.buildVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-gwt-api</artifactId>
+ <version>${sonar.buildVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-user</artifactId>
+ <version>2.0.3</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-incubator</artifactId>
+ <version>2.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- unit tests -->
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-testing-harness</artifactId>
+ <version>${sonar.buildVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>com.mycompany.sonar.gwt.GwtPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>gwt-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <configuration>
+ <modules>
+ <module>com.mycompany.sonar.gwt.viewer.SampleViewer</module>
+ <module>com.mycompany.sonar.gwt.page.SamplePage</module>
+ </modules>
+ <webappDirectory>${project.build.directory}/classes</webappDirectory>
+ <extraJvmArgs>-Xmx512m</extraJvmArgs>
+ </configuration>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+package com.mycompany.sonar.gwt;
+
+import com.mycompany.sonar.gwt.page.SamplePage;
+import com.mycompany.sonar.gwt.viewer.SampleViewer;
+import org.sonar.api.SonarPlugin;
+
+import java.util.Arrays;
+import java.util.List;
+
+public final class GwtPlugin extends SonarPlugin {
+
+ public List getExtensions() {
+ return Arrays.asList(SampleViewer.class, SamplePage.class);
+ }
+
+ public String toString() {
+ return getKey();
+ }
+}
\ No newline at end of file
--- /dev/null
+package com.mycompany.sonar.gwt.page;
+
+import org.sonar.api.web.GwtPage;
+import org.sonar.api.web.NavigationSection;
+import org.sonar.api.web.UserRole;
+
+@NavigationSection(NavigationSection.RESOURCE)
+@UserRole(UserRole.USER)
+public class SamplePage extends GwtPage {
+
+ public String getGwtId() {
+ return "com.mycompany.sonar.gwt.page.SamplePage";
+ }
+
+ public String getTitle() {
+ return "Sample";
+ }
+}
--- /dev/null
+package com.mycompany.sonar.gwt.page.client;
+
+import com.google.gwt.core.client.GWT;
+
+public interface I18nConstants extends com.google.gwt.i18n.client.Constants {
+
+ static I18nConstants INSTANCE = GWT.create(I18nConstants.class);
+
+ @DefaultStringValue("This is a sample")
+ String sample();
+}
--- /dev/null
+package com.mycompany.sonar.gwt.page.client;
+
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+import org.sonar.gwt.ui.Page;
+import org.sonar.wsclient.services.Resource;
+
+public class SamplePagePanel extends Page {
+
+ @Override
+ protected Widget doOnResourceLoad(Resource resource) {
+ VerticalPanel panel = new VerticalPanel();
+ panel.add(new Label(resource.getName(true)));
+ panel.add(new Label(I18nConstants.INSTANCE.sample()));
+ return panel;
+ }
+}
--- /dev/null
+package com.mycompany.sonar.gwt.viewer;
+
+import org.sonar.api.web.GwtPage;
+import org.sonar.api.web.NavigationSection;
+import org.sonar.api.web.UserRole;
+
+@NavigationSection(NavigationSection.RESOURCE_TAB)
+@UserRole(UserRole.USER)
+public class SampleViewer extends GwtPage {
+ public String getTitle() {
+ return "Sample";
+ }
+
+ public String getGwtId() {
+ return "com.mycompany.sonar.gwt.viewer.SampleViewer";
+ }
+}
\ No newline at end of file
--- /dev/null
+package com.mycompany.sonar.gwt.viewer.client;
+
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.Widget;
+import org.sonar.gwt.ui.Page;
+import org.sonar.wsclient.services.Resource;
+
+public class SampleViewerPanel extends Page {
+
+ @Override
+ protected Widget doOnResourceLoad(Resource resource) {
+ return new Label("This is a sample");
+ }
+}
\ No newline at end of file
--- /dev/null
+<module>
+
+ <inherits name='com.google.gwt.user.User'/>
+ <inherits name="com.google.gwt.json.JSON"/>
+ <inherits name="com.google.gwt.http.HTTP"/>
+ <inherits name="org.sonar.Sonar"/>
+
+ <entry-point class='com.mycompany.sonar.gwt.page.client.SamplePagePanel'/>
+
+ <extend-property name="locale" values="en"/>
+ <extend-property name="locale" values="fr"/>
+
+</module>
--- /dev/null
+# This file must use UTF-8 encoding
+sample=Ceci est un exemple
\ No newline at end of file
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <title>GWT Smaple</title>
+ <link href="http://localhost:9000/dev/stylesheets/yui-2.6.0.css" media="all" rel="Stylesheet" type="text/css" />
+ <link href="http://localhost:9000/dev/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css" />
+ <script src="http://localhost:9000/dev/javascripts/application.js" type="text/javascript"></script>
+ <script src="http://localhost:9000/dev/javascripts/prototype.js" type="text/javascript"></script>
+ <script src="http://localhost:9000/dev/javascripts/scriptaculous.js" type="text/javascript"></script>
+</head>
+
+<body>
+<script type="text/javascript">
+var config = {
+ "sonar_url": "http://localhost:9000/dev",
+ "resource_key" : "org.codehaus.sonar:sonar",
+};
+</script>
+
+<div class="error" id="error" style="display:none"><span id="errormsg"></span> [<a href="#" onclick="javascript:$('error').hide();return false;">hide</a>]</div>
+<div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> [<a href="#" onclick="javascript:$('warning').hide();return false;">hide</a>]</div>
+<div class="notice" id="info" style="display:none"><span id="infomsg"></span> [<a href="#" onclick="javascript:$('info').hide();return false;">hide</a>]</div>
+
+<div id="gwtpage">
+</div>
+
+<script type="text/javascript" language="javascript" src="org.sonar.plugins.gwtsample.page.GwtSamplePage.nocache.js"></script>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+<module>
+
+ <inherits name='com.google.gwt.user.User'/>
+ <inherits name="com.google.gwt.json.JSON"/>
+ <inherits name="com.google.gwt.http.HTTP"/>
+ <inherits name="org.sonar.Sonar"/>
+
+ <entry-point class='com.mycompany.sonar.gwt.viewer.client.SampleViewerPanel'/>
+
+</module>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar</artifactId>
+ <version>2.8-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <groupId>org.codehaus.sonar.samples</groupId>
+ <artifactId>sonar-samples</artifactId>
+ <packaging>pom</packaging>
+ <name>Sonar :: Samples</name>
+
+ <modules>
+ <module>standard-plugin</module>
+ <module>gwt-plugin</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <finalName>sonar-samples-${project.version}</finalName>
+ <descriptors>
+ <descriptor>assembly.xml</descriptor>
+ </descriptors>
+ <archiverConfig>
+ <!-- Workaround for http://jira.codehaus.org/browse/MASSEMBLY-422 -->
+ <!-- 420(dec) = 644(oct) -->
+ <fileMode>420</fileMode>
+ <!-- 493(dec) = 755(oct) -->
+ <directoryMode>493</directoryMode>
+ <defaultDirectoryMode>493</defaultDirectoryMode>
+ </archiverConfig>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.mycompany.sonar</groupId>
+ <artifactId>sonar-standard-plugin</artifactId>
+ <packaging>sonar-plugin</packaging>
+ <version>2.8-SNAPSHOT</version>
+ <name>Sonar :: Samples :: Standard plugin</name>
+ <description>Description of standard plugin</description>
+
+ <properties>
+ <!-- To be replaced with the minimum required version of Sonar -->
+ <sonar.buildVersion>${project.version}</sonar.buildVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${sonar.buildVersion}</version>
+ </dependency>
+
+ <!-- unit tests -->
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-testing-harness</artifactId>
+ <version>${sonar.buildVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>com.mycompany.sonar.standard.SamplePlugin</pluginClass>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <encoding>UTF-8</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+package com.mycompany.sonar.standard;
+
+import org.sonar.api.web.Footer;
+
+public final class SampleFooter implements Footer {
+ public String getHtml() {
+ return "<p>Sample footer - <em>This is static HTML</em></p>";
+ }
+}
--- /dev/null
+package com.mycompany.sonar.standard;
+
+import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.measures.Metric;
+import org.sonar.api.measures.Metrics;
+
+import java.util.Arrays;
+import java.util.List;
+
+public final class SampleMetrics implements Metrics {
+
+ public static final Metric MESSAGE = new Metric.Builder("message_key", "Message", Metric.ValueType.STRING)
+ .setDescription("This is a metric to store a well known message")
+ .setDirection(Metric.DIRECTION_WORST)
+ .setQualitative(false)
+ .setDomain(CoreMetrics.DOMAIN_GENERAL)
+ .create();
+
+ public static final Metric RANDOM = new Metric.Builder("random", "Random", Metric.ValueType.FLOAT)
+ .setDescription("Random value")
+ .setDirection(Metric.DIRECTION_BETTER)
+ .setQualitative(false)
+ .setDomain(CoreMetrics.DOMAIN_GENERAL)
+ .create();
+
+ // getMetrics() method is defined in the Metrics interface and is used by
+ // Sonar to retrieve the list of new Metric
+ public List<Metric> getMetrics() {
+ return Arrays.asList(MESSAGE, RANDOM);
+ }
+}
--- /dev/null
+package com.mycompany.sonar.standard;
+
+import org.sonar.api.SonarPlugin;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This class is the entry point for all extensions
+ */
+public final class SamplePlugin extends SonarPlugin {
+
+ // This is where you're going to declare all your Sonar extensions
+ public List getExtensions() {
+ return Arrays.asList(
+ SampleMetrics.class, SampleSensor.class, SampleRubyWidget.class,
+
+ // UI
+ SampleFooter.class);
+ }
+}
\ No newline at end of file
--- /dev/null
+package com.mycompany.sonar.standard;
+
+import org.sonar.api.web.*;
+
+@UserRole(UserRole.USER)
+@Description("Show how to use Ruby Widget API")
+@WidgetProperties({
+ @WidgetProperty(key="param1",
+ description="This is a mandatory parameter",
+ optional=false
+ ),
+ @WidgetProperty(key="max",
+ description="max threshold",
+ type=WidgetPropertyType.INTEGER,
+ defaultValue="80"
+ ),
+ @WidgetProperty(key="param2",
+ description="This is an optional parameter"
+ ),
+ @WidgetProperty(key="floatprop",
+ description="test description"
+ )
+})
+public class SampleRubyWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+
+ public String getId() {
+ return "sample";
+ }
+
+ public String getTitle() {
+ return "Sample";
+ }
+
+ @Override
+ protected String getTemplatePath() {
+ return "/sample_ruby_widget.html.erb";
+ }
+}
\ No newline at end of file
--- /dev/null
+package com.mycompany.sonar.standard;
+
+import org.apache.commons.lang.math.RandomUtils;
+import org.sonar.api.batch.Sensor;
+import org.sonar.api.batch.SensorContext;
+import org.sonar.api.measures.Measure;
+import org.sonar.api.resources.Project;
+
+public class SampleSensor implements Sensor {
+
+ public boolean shouldExecuteOnProject(Project project) {
+ // this sensor is executed on any type of project
+ return true;
+ }
+
+ public void analyse(Project project, SensorContext sensorContext) {
+ saveLabelMeasure(sensorContext);
+ saveNumericMeasure(sensorContext);
+ }
+
+ private void saveNumericMeasure(SensorContext context) {
+ // Sonar API includes many libraries like commons-lang and google-collections
+ context.saveMeasure(SampleMetrics.RANDOM, RandomUtils.nextDouble());
+ }
+
+ private void saveLabelMeasure(SensorContext context) {
+ Measure measure = new Measure(SampleMetrics.MESSAGE, "Hello World!");
+ context.saveMeasure(measure);
+ }
+}
--- /dev/null
+<div class="dashbox">
+ <h3><span title="<%= metric('random').description -%>"></span></h3>
+ <p>
+ <span class="big">
+ <%= format_measure('random') -%> <%= trend_icon(measure('random')) %>
+ </span>
+ </p>
+ <p><%= format_measure('message') -%></p>
+ <p>
+ <%= format_measure('ncloc', :suffix => ' lines', :url => url_for_drilldown('ncloc')) -%>
+ </p>
+</div>
+<div class="dashbox">
+ <h3>Help</h3>
+ <p>
+ Read configuration : <%= configuration('sonar.jdbc.username') -%>
+ </p>
+
+ <p>
+ Sample of Jfree Eastwood chart : <br/>
+ <%= gchart('cht=bhs&chco=FF0000,00FF00,0000FF&chs=200x125&chd=s:FOE,THE,Bar&chxt=x,y&chxl=1:|Dec|Nov|Oct|0:||20K||60K||100K|') -%>
+ </p>
+ <p>
+ Widget properties:
+ <table>
+ <tr>
+ <td>max:</td>
+ <td><%= widget_properties['max'] -%></td>
+ </tr>
+ <tr>
+ <td>param1:</td>
+ <td><%= widget_properties['param1'] -%></td>
+ </tr>
+ <tr>
+ <td>param2:</td>
+ <td><%= widget_properties['param2'] -%></td>
+ </tr>
+ </table>
+ </p>
+</div>