diff options
20 files changed, 223 insertions, 84 deletions
diff --git a/server/sonar-process-monitor/pom.xml b/server/sonar-process-monitor/pom.xml index 81b6d12dbad..3821fcd21ca 100644 --- a/server/sonar-process-monitor/pom.xml +++ b/server/sonar-process-monitor/pom.xml @@ -79,4 +79,21 @@ </plugin> </plugins> </build> + + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> + </project> diff --git a/server/sonar-process/pom.xml b/server/sonar-process/pom.xml index 193ef735f13..c104542554e 100644 --- a/server/sonar-process/pom.xml +++ b/server/sonar-process/pom.xml @@ -96,4 +96,21 @@ </plugins> </build> + + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> + </project> diff --git a/server/sonar-search/pom.xml b/server/sonar-search/pom.xml index 9f15d8a8125..80a1259ad41 100644 --- a/server/sonar-search/pom.xml +++ b/server/sonar-search/pom.xml @@ -67,4 +67,21 @@ </plugin> </plugins> </build> + + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> + </project> diff --git a/server/sonar-server-benchmarks/pom.xml b/server/sonar-server-benchmarks/pom.xml index ea9d4615f23..e297807cad8 100644 --- a/server/sonar-server-benchmarks/pom.xml +++ b/server/sonar-server-benchmarks/pom.xml @@ -99,34 +99,13 @@ </profile> <profile> <id>release</id> - <activation><activeByDefault>false</activeByDefault></activation> <build> <plugins> <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <id>empty-javadoc-jar</id> - <phase>package</phase> - <goals> - <goal>jar</goal> - </goals> - <configuration> - <classifier>javadoc</classifier> - </configuration> - </execution> - <execution> - <id>empty-sources-jar</id> - <phase>package</phase> - <goals> - <goal>jar</goal> - </goals> - <configuration> - <classifier>sources</classifier> - </configuration> - </execution> - </executions> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> </plugin> </plugins> </build> diff --git a/server/sonar-server/pom.xml b/server/sonar-server/pom.xml index b0ed4d4e4fd..7fb49bddfb1 100644 --- a/server/sonar-server/pom.xml +++ b/server/sonar-server/pom.xml @@ -337,6 +337,19 @@ </dependency> </dependencies> </profile> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + </profile> </profiles> diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputeQProfileMeasureStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputeQProfileMeasureStep.java index 3495abce8e4..bd22aeb4d6d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputeQProfileMeasureStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ComputeQProfileMeasureStep.java @@ -24,7 +24,6 @@ import com.google.common.base.Optional; import java.util.HashMap; import java.util.Map; import org.sonar.api.measures.CoreMetrics; -import org.sonar.api.utils.MessageException; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.CrawlerDepthLimit; import org.sonar.server.computation.component.PathAwareCrawler; @@ -78,11 +77,6 @@ public class ComputeQProfileMeasureStep implements ComputationStep { @Override public void visitProject(Component project, Path<QProfiles> path) { addMeasure(project, path.current()); - Optional<Measure> qProfileMeasure = measureRepository.getRawMeasure(project, qProfilesMetric); - if (!qProfileMeasure.isPresent() || QPMeasureData.fromJson(qProfileMeasure.get().getData()).getProfiles().isEmpty()) { - throw MessageException.of(String.format("No quality profiles has been found on project '%s', you probably don't have any language plugin suitable for this analysis.", - project.getKey())); - } } @Override diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityProfileEventsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityProfileEventsStep.java index 6a8bd53a219..1967ec3eb92 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityProfileEventsStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/QualityProfileEventsStep.java @@ -89,7 +89,8 @@ public class QualityProfileEventsStep implements ComputationStep { // Load base profiles Optional<Measure> rawMeasure = measureRepository.getRawMeasure(projectComponent, metricRepository.getByKey(CoreMetrics.QUALITY_PROFILES_KEY)); if (!rawMeasure.isPresent()) { - throw new IllegalStateException("Missing measure " + CoreMetrics.QUALITY_PROFILES + " for component " + projectComponent.getReportAttributes().getRef()); + // No qualify profile computed on the project + return; } Map<String, QualityProfile> rawProfiles = QPMeasureData.fromJson(rawMeasure.get().getStringValue()).getProfilesByKey(); diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java index 47ba77634fb..d1e003aadc4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java @@ -63,6 +63,23 @@ public class QProfileExporters { this.importers = importers; } + /** + * Used by Pico if no {@link ProfileImporter} is found + */ + public QProfileExporters(QProfileLoader loader, RuleFinder ruleFinder, RuleActivator ruleActivator, ProfileExporter[] exporters) { + this(loader, ruleFinder, ruleActivator, exporters, new ProfileImporter[0]); + } + + /** + * Used by Pico if no {@link ProfileExporter} is found + */ + public QProfileExporters(QProfileLoader loader, RuleFinder ruleFinder, RuleActivator ruleActivator, ProfileImporter[] importers) { + this(loader, ruleFinder, ruleActivator, new ProfileExporter[0], importers); + } + + /** + * Used by Pico if no {@link ProfileImporter} nor {@link ProfileExporter} is found + */ public QProfileExporters(QProfileLoader loader, RuleFinder ruleFinder, RuleActivator ruleActivator) { this(loader, ruleFinder, ruleActivator, new ProfileExporter[0], new ProfileImporter[0]); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ExportersAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ExportersAction.java index 0196729e592..5dc2d180d40 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ExportersAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/ExportersAction.java @@ -33,6 +33,9 @@ public class ExportersAction implements QProfileWsAction { this.exporters = exporters; } + /** + * Used by Pico is no {@link ProfileExporter} is found + */ public ExportersAction() { this(new ProfileExporter[0]); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputeQProfileMeasureStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputeQProfileMeasureStepTest.java index 354c4e8b2ad..45acfd592ee 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputeQProfileMeasureStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ComputeQProfileMeasureStepTest.java @@ -27,7 +27,6 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.api.utils.MessageException; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.ReportComponent; @@ -136,10 +135,7 @@ public class ComputeQProfileMeasureStepTest { } @Test - public void fail_with_message_exception_when_no_qprofile_computed_on_project() throws Exception { - thrown.expect(MessageException.class); - thrown.expectMessage("No quality profiles has been found on project 'PROJECT KEY'"); - + public void nothing_to_add_when_no_qprofile_computed_on_project() throws Exception { treeRootHolder.setRoot(MULTI_MODULE_PROJECT); underTest.execute(); @@ -148,10 +144,7 @@ public class ComputeQProfileMeasureStepTest { } @Test - public void fail_with_message_exception_when_qprofiles_computed_on_project_are_empty() throws Exception { - thrown.expect(MessageException.class); - thrown.expectMessage("No quality profiles has been found on project 'PROJECT KEY', you probably don't have any language plugin suitable for this analysis."); - + public void nothing_to_add_when_qprofiles_computed_on_project_are_empty() throws Exception { treeRootHolder.setRoot(MULTI_MODULE_PROJECT); measureRepository.addRawMeasure(PROJECT_REF, QUALITY_PROFILES_KEY, newMeasureBuilder().create(toJson())); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/QualityProfileEventsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/QualityProfileEventsStepTest.java index ac4b52ea09c..7bcf0e0a658 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/QualityProfileEventsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/QualityProfileEventsStepTest.java @@ -89,7 +89,7 @@ public class QualityProfileEventsStepTest { } @Test - public void no_effect_if_no_base_measure() { + public void no_event_if_no_base_measure() { when(measureRepository.getBaseMeasure(treeRootHolder.getRoot(), qualityProfileMetric)).thenReturn(Optional.<Measure>absent()); underTest.execute(); @@ -97,16 +97,18 @@ public class QualityProfileEventsStepTest { verifyNoMoreInteractions(eventRepository); } - @Test(expected = IllegalStateException.class) - public void ISE_if_no_raw_measure() { + @Test + public void no_event_if_no_raw_measure() { when(measureRepository.getBaseMeasure(treeRootHolder.getRoot(), qualityProfileMetric)).thenReturn(Optional.of(newMeasure())); when(measureRepository.getRawMeasure(treeRootHolder.getRoot(), qualityProfileMetric)).thenReturn(Optional.<Measure>absent()); underTest.execute(); + + verifyNoMoreInteractions(eventRepository); } @Test - public void no_event_if_no_base_nor_row_QualityProfile_measure() { + public void no_event_if_no_base_and_quality_profile_measure_is_empty() { mockMeasures(treeRootHolder.getRoot(), null, null); underTest.execute(); diff --git a/server/sonar-web/pom.xml b/server/sonar-web/pom.xml index 092da6be892..6c74b1db15e 100644 --- a/server/sonar-web/pom.xml +++ b/server/sonar-web/pom.xml @@ -229,6 +229,12 @@ </execution> </executions> </plugin> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> </plugins> </build> <dependencies> diff --git a/sonar-batch-protocol/pom.xml b/sonar-batch-protocol/pom.xml index ef276512cd4..add1b341cc5 100644 --- a/sonar-batch-protocol/pom.xml +++ b/sonar-batch-protocol/pom.xml @@ -64,4 +64,19 @@ </plugins> </build> + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> diff --git a/sonar-batch/pom.xml b/sonar-batch/pom.xml index d955694912e..2230fb4b180 100644 --- a/sonar-batch/pom.xml +++ b/sonar-batch/pom.xml @@ -175,5 +175,18 @@ <enableBenchmarkAssertions>true</enableBenchmarkAssertions> </properties> </profile> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + </profile> </profiles> </project> diff --git a/sonar-core/pom.xml b/sonar-core/pom.xml index 944bd226ea9..44f4a814249 100644 --- a/sonar-core/pom.xml +++ b/sonar-core/pom.xml @@ -128,4 +128,20 @@ </plugin> </plugins> </build> + + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> diff --git a/sonar-db/pom.xml b/sonar-db/pom.xml index d265a790c6c..1fc42a30ecf 100644 --- a/sonar-db/pom.xml +++ b/sonar-db/pom.xml @@ -175,5 +175,18 @@ </dependency> </dependencies> </profile> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + </profile> </profiles> </project> diff --git a/sonar-plugin-api-deps/pom.xml b/sonar-plugin-api-deps/pom.xml index d4347e78963..44b1809cdba 100644 --- a/sonar-plugin-api-deps/pom.xml +++ b/sonar-plugin-api-deps/pom.xml @@ -152,32 +152,22 @@ </execution> </executions> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <id>empty-javadoc-jar</id> - <phase>package</phase> - <goals> - <goal>jar</goal> - </goals> - <configuration> - <classifier>javadoc</classifier> - </configuration> - </execution> - <execution> - <id>empty-sources-jar</id> - <phase>package</phase> - <goals> - <goal>jar</goal> - </goals> - <configuration> - <classifier>sources</classifier> - </configuration> - </execution> - </executions> - </plugin> </plugins> </build> + + <profiles> + <profile> + <id>release</id> + <build> + <plugins> + <plugin> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> </project> diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleTagFormat.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleTagFormat.java index 3885bede912..89776d6050a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleTagFormat.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RuleTagFormat.java @@ -22,12 +22,13 @@ package org.sonar.api.server.rule; import org.apache.commons.lang.StringUtils; /** + * The characters allowed in rule tags are the same as those on StackOverflow, basically lower-case + * letters, digits, plus (+), sharp (#), dash (-) and dot (.) + * See http://meta.stackoverflow.com/questions/22624/what-symbols-characters-are-not-allowed-in-tags * @since 4.2 */ public class RuleTagFormat { - // Allowed characters are the same as those on StackOverflow - // see http://meta.stackoverflow.com/questions/22624/what-symbols-characters-are-not-allowed-in-tags private static final String VALID_CHARACTERS_REGEX = "^[a-z0-9\\+#\\-\\.]+$"; private RuleTagFormat() { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java index 20c85db7444..6e0bfeda433 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java @@ -40,39 +40,70 @@ import java.util.ArrayList; import java.util.List; /** - * Loads definitions of rules from a XML file. + * Helper class to load {@link RulesDefinition} extension point from a XML file. + * + * <h3>Example</h3> + * <pre> + * public class MyRules implements RulesDefinition { + * + * private final RulesDefinitionXmlLoader xmlLoader; + * + * public MyRules(RulesDefinitionXmlLoader xmlLoader) { + * this.xmlLoader = xmlLoader; + * } + * + * {@literal @}Override + * public void define(Context context) { + * NewRepository repository = context.createRepository("my-repo", "my-lang"); + * xmlLoader.load(repository, getClass().getResourceAsStream("/my-rules.xml"), StandardCharsets.UTF_8.name()); + * repository.done(); + * } + * } + * </pre> * * <h3>XML Format</h3> * <pre> * <rules> * <rule> - * <!-- required fields --> - * <key>the-rule-key</key> - * <name>The purpose of the rule</name> - * - * <!-- optional fields --> - * <description> - * <![CDATA[The description]]> + * <key>the-required-rule-key</key>* + * <name>The required purpose of the rule</name> + ** <description> + * <![CDATA[Required HTML description]]> * </description> + * + * <!-- Optional key for configuration of some rule engines --> * <internalKey>Checker/TreeWalker/LocalVariableName</internalKey> + * + * <!-- Default severity when enabling the rule in a Quality profile. --> + * <!-- Possible values are INFO, MINOR, MAJOR (default), CRITICAL, BLOCKER. --> * <severity>BLOCKER</severity> - * <cardinality>MULTIPLE</cardinality> + * + * <!-- Possible values are SINGLE (default) and MULTIPLE for template rules --> + * <cardinality>SINGLE</cardinality> + * + * <!-- Status displayed in rules console. Possible values are BETA, READY (default), DEPRECATED. --> * <status>BETA</status> + * + * <!-- Optional tags. See org.sonar.api.server.rule.RuleTagFormat. --> * <tag>style</tag> * <tag>security</tag> + * * <param> * <key>the-param-key</key> * <description> - * <![CDATA[the param-description]]> + * <![CDATA[the optional param description]]> * </description> + * <!-- Optional field to define the default value used when enabling the rule in a Quality profile --> * <defaultValue>42</defaultValue> * </param> * <param> * <key>another-param</key> * </param> * - * <!-- deprecated fields --> + * <!-- Deprecated field, replaced by "internalKey" --> * <configKey>Checker/TreeWalker/LocalVariableName</configKey> + * + * <!-- Deprecated field, replaced by "severity" --> * <priority>BLOCKER</priority> * </rule> * </rules> diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RuleTagFormatTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RuleTagFormatTest.java index 799df3a20c4..d42daa246cf 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RuleTagFormatTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/server/rule/RuleTagFormatTest.java @@ -39,6 +39,7 @@ public class RuleTagFormatTest { assertThat(RuleTagFormat.isValid("c++")).isTrue(); assertThat(RuleTagFormat.isValid("f#")).isTrue(); assertThat(RuleTagFormat.isValid("c++11")).isTrue(); + assertThat(RuleTagFormat.isValid("c.d")).isTrue(); } @Test |