]> source.dussan.org Git - sonarqube.git/commitdiff
Add properties "sonar.projectName" and "sonar.projectDescription"
authorEvgeny Mandrikov <mandrikov@gmail.com>
Sun, 30 Jan 2011 22:55:26 +0000 (01:55 +0300)
committerEvgeny Mandrikov <mandrikov@gmail.com>
Sun, 30 Jan 2011 23:33:07 +0000 (02:33 +0300)
sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java
sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java
sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java

index 68eb57b18f87f49051e74cac405c902c6e461b0c..8e0ada5e60d5171a09d8dbde1040530bf0290fd2 100644 (file)
@@ -73,6 +73,9 @@ public class InMemoryPomCreator {
     pom.setArtifactId(keys[1]);
     pom.setVersion(getPropertyOrDie(properties, CoreProperties.PROJECT_VERSION_PROPERTY));
 
+    pom.setName(properties.getProperty(CoreProperties.PROJECT_NAME_PROPERTY, "Unnamed - " + key));
+    pom.setDescription(properties.getProperty(CoreProperties.PROJECT_DESCRIPTION_PROPERTY, ""));
+
     pom.getModel().setProperties(properties);
 
     pom.setArtifacts(Collections.EMPTY_SET);
index 83550c40c0d824bf3486b0dd0786d14f135f0152..260e6846d696097d6581e21b4722910f28303e3c 100644 (file)
@@ -54,6 +54,8 @@ public class InMemoryPomCreatorTest {
     assertThat(pom.getBasedir(), is(project.getBaseDir()));
     assertThat(pom.getGroupId(), is("org.example"));
     assertThat(pom.getArtifactId(), is("example"));
+    assertThat(pom.getName(), is("Unnamed - org.example:example"));
+    assertThat(pom.getDescription(), is(""));
     assertThat(pom.getProperties(), is(project.getProperties()));
     assertThat(pom.getBasedir(), is(project.getBaseDir()));
     String buildDirectory = project.getWorkDir().getAbsolutePath() + "/target";
@@ -62,6 +64,19 @@ public class InMemoryPomCreatorTest {
     assertThat(pom.getReporting().getOutputDirectory(), is(buildDirectory + "/site"));
   }
 
+  @Test
+  public void nameAndDescription() {
+    createRequiredProperties();
+
+    properties.setProperty(CoreProperties.PROJECT_NAME_PROPERTY, "Foo");
+    properties.setProperty(CoreProperties.PROJECT_DESCRIPTION_PROPERTY, "Bar");
+
+    MavenProject pom = create();
+
+    assertThat(pom.getName(), is("Foo"));
+    assertThat(pom.getDescription(), is("Bar"));
+  }
+
   @Test
   public void sourceDirectories() {
     createRequiredProperties();
index f39be2c6c7a836e21f0e67730f385875ded3a371..f8a64be01131239d7aea47e0fab8456dee540617 100644 (file)
@@ -39,6 +39,16 @@ public interface CoreProperties {
    */
   String PROJECT_KEY_PROPERTY = "sonar.projectKey";
 
+  /**
+   * @since 2.6
+   */
+  String PROJECT_NAME_PROPERTY = "sonar.projectName";
+
+  /**
+   * @since 2.6
+   */
+  String PROJECT_DESCRIPTION_PROPERTY = "sonar.projectDescription";
+
   /**
    * To determine value of this property use {@link ProjectFileSystem#getSourceCharset()}.
    *