From eee7fbd2a7c80ee6f0647e67b197bf832dae96cb Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Thu, 5 May 2011 13:53:52 +0200 Subject: [PATCH] SONAR-2357 Add samples to build + improve samples for rules --- pom.xml | 16 +++++++++++++--- .../standard/rules/SampleQualityProfile.java | 4 +++- .../standard/rules/SampleRuleRepository.java | 3 +++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 63566a08a17..0b1ecbd6d0f 100644 --- a/pom.xml +++ b/pom.xml @@ -13,6 +13,7 @@ archetypes/sonar-basic-plugin archetypes/sonar-gwt-plugin + sonar-application sonar-batch sonar-batch-bootstrapper sonar-batch-maven-compat @@ -20,6 +21,7 @@ sonar-check-api sonar-colorizer sonar-core + sonar-core-maven-plugin sonar-deprecated sonar-duplications sonar-graph @@ -29,6 +31,7 @@ sonar-maven-plugin sonar-maven3-plugin sonar-plugin-api + sonar-server sonar-squid sonar-testing-harness sonar-ws-client @@ -920,11 +923,18 @@ true - sonar-core-maven-plugin - sonar-server - sonar-application + samples + + + dev + + + dev + + + release diff --git a/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleQualityProfile.java b/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleQualityProfile.java index 65ba4d9c26d..ac6e981085b 100644 --- a/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleQualityProfile.java +++ b/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleQualityProfile.java @@ -3,6 +3,7 @@ package com.mycompany.sonar.standard.rules; import org.sonar.api.profiles.ProfileDefinition; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Java; +import org.sonar.api.rules.Rule; import org.sonar.api.rules.RulePriority; import org.sonar.api.utils.ValidationMessages; @@ -19,7 +20,8 @@ public class SampleQualityProfile extends ProfileDefinition { public RulesProfile createProfile(ValidationMessages validation) { RulesProfile profile = RulesProfile.create("Sample profile", Java.KEY); profile.activateRule(ruleRepository.getRule1(), RulePriority.MAJOR); - profile.activateRule(ruleRepository.getRule1(), null); + profile.activateRule(ruleRepository.getRule2(), null); + profile.activateRule(Rule.create("checkstyle", "com.puppycrawl.tools.checkstyle.checks.coding.CovariantEqualsCheck", null), null); return profile; } } diff --git a/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleRuleRepository.java b/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleRuleRepository.java index 964a2e8ed79..4bd909a3b11 100644 --- a/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleRuleRepository.java +++ b/samples/standard-plugin/src/main/java/com/mycompany/sonar/standard/rules/SampleRuleRepository.java @@ -8,6 +8,9 @@ import org.sonar.api.rules.RuleRepository; import java.util.Arrays; import java.util.List; +/** + * This class declares rules. It is not the engine used to execute rules during project analysis. + */ public class SampleRuleRepository extends RuleRepository { public static final String REPOSITORY_KEY = "sample"; -- 2.39.5