aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java15
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java10
3 files changed, 28 insertions, 0 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java b/sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java
index 68eb57b18f8..8e0ada5e60d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/InMemoryPomCreator.java
@@ -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);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java b/sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java
index 83550c40c0d..260e6846d69 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/InMemoryPomCreatorTest.java
@@ -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";
@@ -63,6 +65,19 @@ public class InMemoryPomCreatorTest {
}
@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();
properties.setProperty("sonar.projectBinaries", "junit.jar");
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
index f39be2c6c7a..f8a64be0113 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
@@ -40,6 +40,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()}.
*
* @since 2.6