diff options
author | Fabrice Bellingard <fabrice.bellingard@sonarsource.com> | 2012-09-13 16:07:23 +0200 |
---|---|---|
committer | Fabrice Bellingard <fabrice.bellingard@sonarsource.com> | 2012-09-13 18:06:47 +0200 |
commit | a3fd8f33a955deb6aac7485cd84104c471cee35f (patch) | |
tree | 36e7533ec362d887b9b0bd3ae82edd36af9cd830 /src/main/java/org | |
parent | 6243d134515efad579827d9de80d3db24c4ec65d (diff) | |
download | sonar-scanner-cli-a3fd8f33a955deb6aac7485cd84104c471cee35f.tar.gz sonar-scanner-cli-a3fd8f33a955deb6aac7485cd84104c471cee35f.zip |
SONARPLUGINS-2202 "sonar.projectName" default value is now module ID
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java b/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java index e4cd483..93a5d81 100644 --- a/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java +++ b/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java @@ -124,7 +124,7 @@ public final class SonarProjectBuilder { } private ProjectDefinition defineProject(Properties properties) { - checkMandatoryProperties("root project", properties, MANDATORY_PROPERTIES_FOR_PROJECT); + checkMandatoryProperties(properties, MANDATORY_PROPERTIES_FOR_PROJECT); File baseDir = new File(properties.getProperty(PROPERTY_PROJECT_BASEDIR)); ProjectDefinition definition = ProjectDefinition.create((Properties) properties.clone()) .setBaseDir(baseDir) @@ -163,7 +163,7 @@ public final class SonarProjectBuilder { } private ProjectDefinition loadChildProject(ProjectDefinition parentProject, Properties moduleProps, String moduleId) { - setProjectKeyIfNotDefined(moduleProps, moduleId); + setProjectKeyAndNameIfNotDefined(moduleProps, moduleId); if (moduleProps.containsKey(PROPERTY_PROJECT_BASEDIR)) { File baseDir = getFileFromPath(moduleProps.getProperty(PROPERTY_PROJECT_BASEDIR), parentProject.getBaseDir()); @@ -178,7 +178,7 @@ public final class SonarProjectBuilder { } // and finish - checkMandatoryProperties(moduleId, moduleProps, MANDATORY_PROPERTIES_FOR_CHILD); + checkMandatoryProperties(moduleProps, MANDATORY_PROPERTIES_FOR_CHILD); mergeParentProperties(moduleProps, parentProject.getProperties()); prefixProjectKeyWithParentKey(moduleProps, parentProject.getKey()); @@ -235,10 +235,13 @@ public final class SonarProjectBuilder { } @VisibleForTesting - protected static void setProjectKeyIfNotDefined(Properties childProps, String moduleId) { + protected static void setProjectKeyAndNameIfNotDefined(Properties childProps, String moduleId) { if (!childProps.containsKey(PROPERTY_PROJECT_KEY)) { childProps.put(PROPERTY_PROJECT_KEY, moduleId); } + if (!childProps.containsKey(PROPERTY_PROJECT_NAME)) { + childProps.put(PROPERTY_PROJECT_NAME, moduleId); + } } @VisibleForTesting @@ -264,7 +267,7 @@ public final class SonarProjectBuilder { } @VisibleForTesting - protected static void checkMandatoryProperties(String moduleId, Properties props, String[] mandatoryProps) { + protected static void checkMandatoryProperties(Properties props, String[] mandatoryProps) { replaceDeprecatedProperties(props); StringBuilder missing = new StringBuilder(); for (String mandatoryProperty : mandatoryProps) { @@ -277,7 +280,7 @@ public final class SonarProjectBuilder { } if (missing.length() != 0) { String projectKey = props.getProperty(PROPERTY_PROJECT_KEY); - throw new RunnerException("You must define the following mandatory properties for '" + (projectKey == null ? moduleId : projectKey) + "': " + missing); + throw new RunnerException("You must define the following mandatory properties for '" + (projectKey == null ? "Unknown" : projectKey) + "': " + missing); } } |