diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-06 14:08:06 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-09-06 14:08:06 +0000 |
commit | aeadc1f9129274949daaa57738c7c4550bdfbc7b (patch) | |
tree | 08dadf5ef7474fc41d1d48f74648f1ba8b55f34d /archetypes | |
download | sonarqube-aeadc1f9129274949daaa57738c7c4550bdfbc7b.tar.gz sonarqube-aeadc1f9129274949daaa57738c7c4550bdfbc7b.zip |
SONAR-236 remove deprecated code from checkstyle plugin + display default value of rule parameters in Q profile console
Diffstat (limited to 'archetypes')
41 files changed, 1237 insertions, 0 deletions
diff --git a/archetypes/sonar-basic-plugin/README.txt b/archetypes/sonar-basic-plugin/README.txt new file mode 100644 index 00000000000..6f0d0d9c557 --- /dev/null +++ b/archetypes/sonar-basic-plugin/README.txt @@ -0,0 +1,5 @@ +To update the archetype project : + +1. update sources of the initial project (/project directory) +2. /project$ mvn install -DsonarTargetVersion=<version> +3. copy the content of /project/target/generated-sources/archetype/src/main/resources to src/main/resources. Be careful with .svn files ! diff --git a/archetypes/sonar-basic-plugin/pom.xml b/archetypes/sonar-basic-plugin/pom.xml new file mode 100644 index 00000000000..8cb2ddc9305 --- /dev/null +++ b/archetypes/sonar-basic-plugin/pom.xml @@ -0,0 +1,58 @@ +<?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> + + <parent> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar</artifactId> + <version>2.3-SNAPSHOT</version> + <relativePath>../..</relativePath> + </parent> + + <groupId>org.codehaus.sonar.archetypes</groupId> + <artifactId>sonar-basic-plugin-archetype</artifactId> + <packaging>maven-archetype</packaging> + <name>Sonar :: Archetypes :: Basic</name> + <description>Maven archetype to create a basic Sonar plugin</description> + + <properties> + <sonarTargetVersion>${project.version}</sonarTargetVersion> + </properties> + + <dependencies> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-plugin-api</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <resources> + <resource> + <filtering>true</filtering> + <directory>${basedir}/src/main/resources</directory> + </resource> + </resources> + <extensions> + <extension> + <groupId>org.apache.maven.archetype</groupId> + <artifactId>archetype-packaging</artifactId> + <version>2.0-alpha-4</version> + </extension> + </extensions> + <plugins> + <plugin> + <artifactId>maven-archetype-plugin</artifactId> + <version>2.0-alpha-4</version> + <extensions>true</extensions> + </plugin> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>false</skip> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/archetypes/sonar-basic-plugin/project/pom.xml b/archetypes/sonar-basic-plugin/project/pom.xml new file mode 100644 index 00000000000..4750508d1de --- /dev/null +++ b/archetypes/sonar-basic-plugin/project/pom.xml @@ -0,0 +1,60 @@ +<?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>org.codehaus.sonar.archetypes</groupId> + <artifactId>sonar-basic-plugin</artifactId> + <packaging>sonar-plugin</packaging> + <version>1.0-SNAPSHOT</version> + <name>My Sonar plugin</name> + <description>plugin description</description> + + <!-- optional --> + <organization> + <name>My company</name> + <url>http://www.mycompany.com</url> + </organization> + + <dependencies> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-plugin-api</artifactId> + <version>${sonarTargetVersion}</version> + </dependency> + + <!-- add your dependencies here --> + + <!-- unit tests --> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-testing-harness</artifactId> + <version>${sonarTargetVersion}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-packaging-maven-plugin</artifactId> + <version>0.1</version> + <extensions>true</extensions> + <configuration> + <pluginKey>sample</pluginKey> + <pluginClass>${package}.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> diff --git a/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleDashboardWidget.java b/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleDashboardWidget.java new file mode 100644 index 00000000000..1ce3680f5b6 --- /dev/null +++ b/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleDashboardWidget.java @@ -0,0 +1,25 @@ +package org.sonar.plugins.sample; + +import org.sonar.api.web.AbstractRubyTemplate; +import org.sonar.api.web.NavigationSection; +import org.sonar.api.web.RubyRailsWidget; +import org.sonar.api.web.UserRole; + +@NavigationSection(NavigationSection.RESOURCE) +@UserRole(UserRole.USER) +public class SampleDashboardWidget extends AbstractRubyTemplate implements RubyRailsWidget { + + public String getId() { + return "sample"; + } + + public String getTitle() { + // not used for the moment by widgets. + return "Sample"; + } + + @Override + protected String getTemplatePath() { + return "/sample_dashboard_widget.html.erb"; + } +}
\ No newline at end of file diff --git a/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleMetrics.java b/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleMetrics.java new file mode 100644 index 00000000000..294bc5c8548 --- /dev/null +++ b/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleMetrics.java @@ -0,0 +1,26 @@ +package org.sonar.plugins.sample; + +import org.sonar.api.measures.Metrics; +import org.sonar.api.measures.Metric; +import org.sonar.api.measures.CoreMetrics; + +import java.util.List; +import java.util.Arrays; + +public class SampleMetrics implements Metrics { + + public static final Metric MESSAGE = new Metric("message_key", "Message", + "This is a metric to store a well known message", Metric.ValueType.STRING, -1, false, + CoreMetrics.DOMAIN_GENERAL); + + + public static final Metric RANDOM = new Metric("random", "Random", + "Random value", Metric.ValueType.FLOAT, Metric.DIRECTION_BETTER, false, + CoreMetrics.DOMAIN_GENERAL); + + // 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); + } +} diff --git a/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SamplePlugin.java b/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SamplePlugin.java new file mode 100644 index 00000000000..5856d414c97 --- /dev/null +++ b/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SamplePlugin.java @@ -0,0 +1,43 @@ +package org.sonar.plugins.sample;
+
+import org.sonar.api.Plugin;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class is the entry point for all extensions
+ */
+public class SamplePlugin implements Plugin {
+
+ /**
+ * @deprecated this is not used anymore
+ */
+ public String getKey() {
+ return "sample";
+ }
+
+ /**
+ * @deprecated this is not used anymore
+ */
+ public String getName() {
+ return "My Sonar plugin";
+ }
+
+ /**
+ * @deprecated this is not used anymore
+ */
+ public String getDescription() {
+ return "You shouldn't expect too much from this plugin except displaying the Hello World message.";
+ }
+
+ // This is where you're going to declare all your Sonar extensions
+ public List getExtensions() {
+ return Arrays.asList(SampleMetrics.class, SampleSensor.class, SampleDashboardWidget.class);
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
+}
\ No newline at end of file diff --git a/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleSensor.java b/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleSensor.java new file mode 100644 index 00000000000..6e0deb74656 --- /dev/null +++ b/archetypes/sonar-basic-plugin/project/src/main/java/org/sonar/plugins/sample/SampleSensor.java @@ -0,0 +1,30 @@ +package org.sonar.plugins.sample; + +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); + } +} diff --git a/archetypes/sonar-basic-plugin/project/src/main/resources/sample_dashboard_widget.html.erb b/archetypes/sonar-basic-plugin/project/src/main/resources/sample_dashboard_widget.html.erb new file mode 100644 index 00000000000..34b80a937e7 --- /dev/null +++ b/archetypes/sonar-basic-plugin/project/src/main/resources/sample_dashboard_widget.html.erb @@ -0,0 +1,23 @@ +<div class="dashbox"> + <h3><span title="<%= metric('random').description -%>"></span></h3> + <p> + <span class="big"> + <%= format_measure('random') -%> <%= tendency_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> +</div>
\ No newline at end of file diff --git a/archetypes/sonar-basic-plugin/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetypes/sonar-basic-plugin/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 00000000000..4333c924715 --- /dev/null +++ b/archetypes/sonar-basic-plugin/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?><archetype-descriptor name="sonar-basic-plugin"> + <fileSets> + <fileSet filtered="true" packaged="true" encoding="UTF-8"> + <directory>src/main/java</directory> + <includes> + <include>**/*.java</include> + </includes> + </fileSet> + <fileSet encoding="UTF-8"> + <directory>src/main/resources</directory> + <includes> + <include>**/*.erb</include> + </includes> + </fileSet> + </fileSets> +</archetype-descriptor>
\ No newline at end of file diff --git a/archetypes/sonar-basic-plugin/src/main/resources/META-INF/maven/archetype.xml b/archetypes/sonar-basic-plugin/src/main/resources/META-INF/maven/archetype.xml new file mode 100644 index 00000000000..4c51c1ced5f --- /dev/null +++ b/archetypes/sonar-basic-plugin/src/main/resources/META-INF/maven/archetype.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?><archetype> + <id>sonar-basic-plugin</id> + <sources> + <source>src/main/java/SampleDashboardWidget.java</source> + <source>src/main/java/SampleMetrics.java</source> + <source>src/main/java/SamplePlugin.java</source> + <source>src/main/java/SampleSensor.java</source> + </sources> + <resources> + <resource>src/main/resources/sample_dashboard_widget.html.erb</resource> + </resources> +</archetype>
\ No newline at end of file diff --git a/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/pom.xml b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 00000000000..56f75bea7ea --- /dev/null +++ b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,59 @@ +<?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>$groupId</groupId>
+ <artifactId>$artifactId</artifactId>
+ <packaging>sonar-plugin</packaging>
+ <version>$version</version>
+ <name>My Sonar plugin</name>
+ <description>plugin description</description>
+
+ <!-- optional -->
+ <organization>
+ <name>My company</name>
+ <url>http://www.mycompany.com</url>
+ </organization>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${sonarTargetVersion}</version>
+ </dependency>
+
+ <!-- add your dependencies here -->
+
+ <!-- unit tests -->
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-testing-harness</artifactId>
+ <version>${sonarTargetVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>0.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginKey>sample</pluginKey>
+ <pluginClass>${package}.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>
diff --git a/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleDashboardWidget.java b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleDashboardWidget.java new file mode 100644 index 00000000000..e545be14157 --- /dev/null +++ b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleDashboardWidget.java @@ -0,0 +1,28 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import org.sonar.api.web.AbstractRubyTemplate; +import org.sonar.api.web.NavigationSection; +import org.sonar.api.web.RubyRailsWidget; +import org.sonar.api.web.UserRole; + +@NavigationSection(NavigationSection.RESOURCE) +@UserRole(UserRole.USER) +public class SampleDashboardWidget extends AbstractRubyTemplate implements RubyRailsWidget { + + public String getId() { + return "sample"; + } + + public String getTitle() { + // not used for the moment by widgets. + return "Sample"; + } + + @Override + protected String getTemplatePath() { + return "/sample_dashboard_widget.html.erb"; + } +}
\ No newline at end of file diff --git a/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleMetrics.java b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleMetrics.java new file mode 100644 index 00000000000..0f675d66db3 --- /dev/null +++ b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleMetrics.java @@ -0,0 +1,29 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import org.sonar.api.measures.Metrics; +import org.sonar.api.measures.Metric; +import org.sonar.api.measures.CoreMetrics; + +import java.util.List; +import java.util.Arrays; + +public class SampleMetrics implements Metrics { + + public static final Metric MESSAGE = new Metric("message_key", "Message", + "This is a metric to store a well known message", Metric.ValueType.STRING, -1, false, + CoreMetrics.DOMAIN_GENERAL); + + + public static final Metric RANDOM = new Metric("random", "Random", + "Random value", Metric.ValueType.FLOAT, Metric.DIRECTION_BETTER, false, + CoreMetrics.DOMAIN_GENERAL); + + // 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); + } +} diff --git a/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SamplePlugin.java b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SamplePlugin.java new file mode 100644 index 00000000000..79c4b32b0aa --- /dev/null +++ b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SamplePlugin.java @@ -0,0 +1,46 @@ +#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+package ${package};
+
+import org.sonar.api.Plugin;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * This class is the entry point for all extensions
+ */
+public class SamplePlugin implements Plugin {
+
+ /**
+ * @deprecated this is not used anymore
+ */
+ public String getKey() {
+ return "sample";
+ }
+
+ /**
+ * @deprecated this is not used anymore
+ */
+ public String getName() {
+ return "My Sonar plugin";
+ }
+
+ /**
+ * @deprecated this is not used anymore
+ */
+ public String getDescription() {
+ return "You shouldn't expect too much from this plugin except displaying the Hello World message.";
+ }
+
+ // This is where you're going to declare all your Sonar extensions
+ public List getExtensions() {
+ return Arrays.asList(SampleMetrics.class, SampleSensor.class, SampleDashboardWidget.class);
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName();
+ }
+}
diff --git a/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleSensor.java b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleSensor.java new file mode 100644 index 00000000000..d28f80c8a2e --- /dev/null +++ b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/java/SampleSensor.java @@ -0,0 +1,33 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +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); + } +} diff --git a/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/resources/sample_dashboard_widget.html.erb b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/resources/sample_dashboard_widget.html.erb new file mode 100644 index 00000000000..34b80a937e7 --- /dev/null +++ b/archetypes/sonar-basic-plugin/src/main/resources/archetype-resources/src/main/resources/sample_dashboard_widget.html.erb @@ -0,0 +1,23 @@ +<div class="dashbox"> + <h3><span title="<%= metric('random').description -%>"></span></h3> + <p> + <span class="big"> + <%= format_measure('random') -%> <%= tendency_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> +</div>
\ No newline at end of file diff --git a/archetypes/sonar-gwt-plugin/pom.xml b/archetypes/sonar-gwt-plugin/pom.xml new file mode 100644 index 00000000000..377bfde4d1a --- /dev/null +++ b/archetypes/sonar-gwt-plugin/pom.xml @@ -0,0 +1,65 @@ +<?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> + + <parent> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar</artifactId> + <version>2.3-SNAPSHOT</version> + <relativePath>../..</relativePath> + </parent> + + <groupId>org.codehaus.sonar.archetypes</groupId> + <artifactId>sonar-gwt-plugin-archetype</artifactId> + <packaging>maven-archetype</packaging> + <name>Sonar :: Archetypes :: GWT</name> + <description>Maven archetype to create a Sonar plugin including GWT pages</description> + + <properties> + <sonarTargetVersion>${project.version}</sonarTargetVersion> + <dollar>$</dollar> + </properties> + + <dependencies> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-plugin-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-gwt-api</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <resources> + <resource> + <filtering>true</filtering> + <directory>${basedir}/src/main/resources</directory> + </resource> + </resources> + + <extensions> + <extension> + <groupId>org.apache.maven.archetype</groupId> + <artifactId>archetype-packaging</artifactId> + <version>2.0-alpha-4</version> + </extension> + </extensions> + <plugins> + <plugin> + <artifactId>maven-archetype-plugin</artifactId> + <version>2.0-alpha-4</version> + <extensions>true</extensions> + </plugin> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>false</skip> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/archetypes/sonar-gwt-plugin/project/pom.xml b/archetypes/sonar-gwt-plugin/project/pom.xml new file mode 100644 index 00000000000..b8a293f87bf --- /dev/null +++ b/archetypes/sonar-gwt-plugin/project/pom.xml @@ -0,0 +1,125 @@ +<?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>org.codehaus.sonar.archetypes</groupId> + <artifactId>sonar-gwt-plugin</artifactId> + <packaging>sonar-plugin</packaging> + <version>1.0-SNAPSHOT</version> + <name>My Sonar GWT plugin</name> + <description>GWT Sample description</description> + + <!-- optional --> + <organization> + <name>My company</name> + <url>http://www.mycompany.com</url> + </organization> + + <repositories> + <repository> + <!-- for gwt-incubator --> + <id>sonar</id> + <name>Sonar</name> + <url>http://repository.sonarsource.org/content/repositories/sonar</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + + <dependencies> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-plugin-api</artifactId> + <version>${sonarTargetVersion}</version> + </dependency> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-gwt-api</artifactId> + <version>${sonarTargetVersion}</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>20100204-r1747</version> + <scope>provided</scope> + </dependency> + + <!-- unit tests --> + <dependency> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-testing-harness</artifactId> + <version>${sonarTargetVersion}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.7</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <resources> + <resource> + <directory>src/main/java</directory> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-packaging-maven-plugin</artifactId> + <version>0.1</version> + <extensions>true</extensions> + <configuration> + <pluginKey>gwt-sample</pluginKey> + <pluginName>GWT Sample</pluginName> + <pluginClass>${package}.GwtSamplePlugin</pluginClass> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>gwt-maven-plugin</artifactId> + <version>1.2</version> + <executions> + <execution> + <configuration> + <modules> + <module>${package}.resourcetab.SampleResourceTab</module> + <module>${package}.page.SamplePage</module> + </modules> + <webappDirectory>${project.build.directory}/classes</webappDirectory> + <!-- do not break the following property on two lines --> + <extraJvmArgs>-Xmx512m -Dgwt.jjs.permutationWorkerFactory=com.google.gwt.dev.ThreadedPermutationWorkerFactory</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> diff --git a/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/GwtSamplePlugin.java b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/GwtSamplePlugin.java new file mode 100644 index 00000000000..6bb19504428 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/GwtSamplePlugin.java @@ -0,0 +1,40 @@ +package org.sonar.plugins.gwtsample;
+
+import org.sonar.api.Plugin;
+import org.sonar.plugins.gwtsample.page.GwtSamplePage;
+import org.sonar.plugins.gwtsample.resourcetab.GwtSampleResourceTab;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class GwtSamplePlugin implements Plugin {
+
+ /**
+ * @deprecated this is not used anymore
+ */
+ public String getKey() {
+ return "gwt-sample";
+ }
+
+ /**
+ * @deprecated this is not used anymore
+ */
+ public String getName() {
+ return "GWT Sample";
+ }
+
+ /**
+ * @deprecated this is not used anymore
+ */
+ public String getDescription() {
+ return "GWT Sample description";
+ }
+
+ public List getExtensions() {
+ return Arrays.asList(GwtSampleResourceTab.class, GwtSamplePage.class);
+ }
+
+ public String toString() {
+ return getKey();
+ }
+}
diff --git a/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/GwtSamplePage.java b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/GwtSamplePage.java new file mode 100644 index 00000000000..1313737551a --- /dev/null +++ b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/GwtSamplePage.java @@ -0,0 +1,18 @@ +package org.sonar.plugins.gwtsample.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 GwtSamplePage extends GwtPage { + + public String getGwtId() { + return "org.sonar.plugins.gwtsample.page.SamplePage"; + } + + public String getTitle() { + return "Sample"; + } +} diff --git a/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/SamplePage.gwt.xml b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/SamplePage.gwt.xml new file mode 100644 index 00000000000..5fcbdcdc538 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/SamplePage.gwt.xml @@ -0,0 +1,13 @@ +<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='org.sonar.plugins.gwtsample.page.client.SamplePage'/> + + <extend-property name="locale" values="en"/> + <extend-property name="locale" values="fr"/> + +</module> diff --git a/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/client/I18nConstants.java b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/client/I18nConstants.java new file mode 100644 index 00000000000..d4b387946de --- /dev/null +++ b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/client/I18nConstants.java @@ -0,0 +1,11 @@ +package org.sonar.plugins.gwtsample.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(); +} diff --git a/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/client/I18nConstants_fr.properties b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/client/I18nConstants_fr.properties new file mode 100644 index 00000000000..aa92d17b38b --- /dev/null +++ b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/client/I18nConstants_fr.properties @@ -0,0 +1,2 @@ +# This file must use UTF-8 encoding +sample=Ceci est un exemple
\ No newline at end of file diff --git a/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/client/SamplePage.java b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/client/SamplePage.java new file mode 100644 index 00000000000..c7a2235ae4f --- /dev/null +++ b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/client/SamplePage.java @@ -0,0 +1,18 @@ +package org.sonar.plugins.gwtsample.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 SamplePage 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; + } +} diff --git a/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/public/test.html b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/public/test.html new file mode 100644 index 00000000000..04371e3acb1 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/page/public/test.html @@ -0,0 +1,32 @@ +<!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 diff --git a/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/resourcetab/GwtSampleResourceTab.java b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/resourcetab/GwtSampleResourceTab.java new file mode 100644 index 00000000000..34c84b8eb79 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/resourcetab/GwtSampleResourceTab.java @@ -0,0 +1,17 @@ +package org.sonar.plugins.gwtsample.resourcetab; + +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 GwtSampleResourceTab extends GwtPage { + public String getTitle() { + return "Sample"; + } + + public String getGwtId() { + return "org.sonar.plugins.gwtsample.resourcetab.SampleResourceTab"; + } +}
\ No newline at end of file diff --git a/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/resourcetab/SampleResourceTab.gwt.xml b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/resourcetab/SampleResourceTab.gwt.xml new file mode 100644 index 00000000000..cf665cdabf3 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/resourcetab/SampleResourceTab.gwt.xml @@ -0,0 +1,10 @@ +<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='org.sonar.plugins.gwtsample.resourcetab.client.SampleResourceTab'/> + +</module> diff --git a/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/resourcetab/client/SampleResourceTab.java b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/resourcetab/client/SampleResourceTab.java new file mode 100644 index 00000000000..9315b835b60 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/project/src/main/java/org/sonar/plugins/gwtsample/resourcetab/client/SampleResourceTab.java @@ -0,0 +1,14 @@ +package org.sonar.plugins.gwtsample.resourcetab.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 SampleResourceTab extends Page { + + @Override + protected Widget doOnResourceLoad(Resource resource) { + return new Label("This is a sample"); + } +}
\ No newline at end of file diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetypes/sonar-gwt-plugin/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 00000000000..f0aa4ec4676 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?><archetype-descriptor name="sonar-gwt-plugin-archetype"> + <fileSets> + <fileSet filtered="true" packaged="true" encoding="UTF-8"> + <directory>src/main/java</directory> + <includes> + <include>**/*.xml</include> + <include>**/*.html</include> + <include>**/*.java</include> + <include>**/*.properties</include> + </includes> + </fileSet> + </fileSets> +</archetype-descriptor>
\ No newline at end of file diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/META-INF/maven/archetype.xml b/archetypes/sonar-gwt-plugin/src/main/resources/META-INF/maven/archetype.xml new file mode 100644 index 00000000000..e60be8b35fd --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/META-INF/maven/archetype.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?><archetype> + <id>sonar-gwt-plugin</id> + <sources> + <source>src/main/java/GwtSamplePlugin.java</source> + <source>src/main/java/page/client/I18nConstants.java</source> + <source>src/main/java/page/client/I18nConstants_fr.properties</source> + <source>src/main/java/page/client/SamplePage.java</source> + <source>src/main/java/page/GwtSamplePage.java</source> + <source>src/main/java/page/public/test.html</source> + <source>src/main/java/page/SamplePage.gwt.xml</source> + <source>src/main/java/resourcetab/client/SampleResourceTab.java</source> + <source>src/main/java/resourcetab/GwtSampleResourceTab.java</source> + <source>src/main/java/resourcetab/SampleResourceTab.gwt.xml</source> + </sources> +</archetype>
\ No newline at end of file diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/pom.xml b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 00000000000..058efb9b07f --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,123 @@ +<?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>$groupId</groupId>
+ <artifactId>$artifactId</artifactId>
+ <packaging>sonar-plugin</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>My Sonar GWT plugin</name>
+ <description>GWT Sample description</description>
+
+ <!-- optional -->
+ <organization>
+ <name>My company</name>
+ <url>http://www.mycompany.com</url>
+ </organization>
+
+ <repositories>
+ <repository>
+ <!-- for gwt-incubator -->
+ <id>sonar</id>
+ <name>Sonar</name>
+ <url>http://repository.sonarsource.org/content/repositories/sonar</url>
+ <releases>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${sonarTargetVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-gwt-api</artifactId>
+ <version>${sonarTargetVersion}</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>20100204-r1747</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- unit tests -->
+ <dependency>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-testing-harness</artifactId>
+ <version>${sonarTargetVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>0.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginKey>gwt-sample</pluginKey>
+ <pluginName>GWT Sample</pluginName>
+ <pluginClass>${package}.GwtSamplePlugin</pluginClass>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>gwt-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <configuration>
+ <modules>
+ <module>${package}.resourcetab.SampleResourceTab</module>
+ <module>${package}.page.SamplePage</module>
+ </modules>
+ <webappDirectory>target/classes</webappDirectory>
+ <!-- do not break the following property on two lines -->
+ <extraJvmArgs>-Xmx512m -Dgwt.jjs.permutationWorkerFactory=com.google.gwt.dev.ThreadedPermutationWorkerFactory</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>
diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/GwtSamplePlugin.java b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/GwtSamplePlugin.java new file mode 100644 index 00000000000..deab27bb70d --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/GwtSamplePlugin.java @@ -0,0 +1,43 @@ +#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+package ${package};
+
+import org.sonar.api.Plugin;
+import ${package}.page.GwtSamplePage;
+import ${package}.resourcetab.GwtSampleResourceTab;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class GwtSamplePlugin implements Plugin {
+
+ /**
+ * @deprecated this is not used anymore
+ */
+ public String getKey() {
+ return "gwt-sample";
+ }
+
+ /**
+ * @deprecated this is not used anymore
+ */
+ public String getName() {
+ return "GWT Sample";
+ }
+
+ /**
+ * @deprecated this is not used anymore
+ */
+ public String getDescription() {
+ return "GWT Sample description";
+ }
+
+ public List getExtensions() {
+ return Arrays.asList(GwtSampleResourceTab.class, GwtSamplePage.class);
+ }
+
+ public String toString() {
+ return getKey();
+ }
+}
diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/GwtSamplePage.java b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/GwtSamplePage.java new file mode 100644 index 00000000000..3dea837efdf --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/GwtSamplePage.java @@ -0,0 +1,21 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}.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 GwtSamplePage extends GwtPage { + + public String getGwtId() { + return "${package}.page.SamplePage"; + } + + public String getTitle() { + return "Sample"; + } +} diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/SamplePage.gwt.xml b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/SamplePage.gwt.xml new file mode 100644 index 00000000000..89a0800f0c5 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/SamplePage.gwt.xml @@ -0,0 +1,16 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +<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='${package}.page.client.SamplePage'/> + + <extend-property name="locale" values="en"/> + <extend-property name="locale" values="fr"/> + +</module> diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/client/I18nConstants.java b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/client/I18nConstants.java new file mode 100644 index 00000000000..1c34bd10240 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/client/I18nConstants.java @@ -0,0 +1,14 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}.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(); +} diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/client/I18nConstants_fr.properties b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/client/I18nConstants_fr.properties new file mode 100644 index 00000000000..89a9d6fe129 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/client/I18nConstants_fr.properties @@ -0,0 +1,5 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +${symbol_pound} This file must use UTF-8 encoding +sample=Ceci est un exemple
\ No newline at end of file diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/client/SamplePage.java b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/client/SamplePage.java new file mode 100644 index 00000000000..bb9b716f634 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/client/SamplePage.java @@ -0,0 +1,21 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}.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 SamplePage 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; + } +} diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/public/test.html b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/public/test.html new file mode 100644 index 00000000000..5d26e9ab834 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/page/public/test.html @@ -0,0 +1,35 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +<!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="${symbol_pound}" onclick="javascript:${symbol_dollar}('error').hide();return false;">hide</a>]</div> +<div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> [<a href="${symbol_pound}" onclick="javascript:${symbol_dollar}('warning').hide();return false;">hide</a>]</div> +<div class="notice" id="info" style="display:none"><span id="infomsg"></span> [<a href="${symbol_pound}" onclick="javascript:${symbol_dollar}('info').hide();return false;">hide</a>]</div> + +<div id="gwtpage"> +</div> + +<script type="text/javascript" language="javascript" src="${package}.page.GwtSamplePage.nocache.js"></script> +</body> +</html>
\ No newline at end of file diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/resourcetab/GwtSampleResourceTab.java b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/resourcetab/GwtSampleResourceTab.java new file mode 100644 index 00000000000..a5253b46940 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/resourcetab/GwtSampleResourceTab.java @@ -0,0 +1,20 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}.resourcetab; + +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 GwtSampleResourceTab extends GwtPage { + public String getTitle() { + return "Sample"; + } + + public String getGwtId() { + return "${package}.resourcetab.SampleResourceTab"; + } +}
\ No newline at end of file diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/resourcetab/SampleResourceTab.gwt.xml b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/resourcetab/SampleResourceTab.gwt.xml new file mode 100644 index 00000000000..079fb36bdaa --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/resourcetab/SampleResourceTab.gwt.xml @@ -0,0 +1,13 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +<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='${package}.resourcetab.client.SampleResourceTab'/> + +</module> diff --git a/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/resourcetab/client/SampleResourceTab.java b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/resourcetab/client/SampleResourceTab.java new file mode 100644 index 00000000000..c75748daed6 --- /dev/null +++ b/archetypes/sonar-gwt-plugin/src/main/resources/archetype-resources/src/main/java/resourcetab/client/SampleResourceTab.java @@ -0,0 +1,17 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}.resourcetab.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 SampleResourceTab extends Page { + + @Override + protected Widget doOnResourceLoad(Resource resource) { + return new Label("This is a sample"); + } +}
\ No newline at end of file |