diff options
author | Fabrice Bellingard <fabrice.bellingard@sonarsource.com> | 2012-09-10 19:04:52 +0200 |
---|---|---|
committer | Fabrice Bellingard <fabrice.bellingard@sonarsource.com> | 2012-09-11 09:18:23 +0200 |
commit | fcd0b85e1c08caf84e6e07b992ccec1a76823320 (patch) | |
tree | 17215ebf404372f1133d62c608bfc8eeedaf771b /src/main/java/org/sonar/runner | |
parent | 7ba663bea3a7a7e55b946de6de96237781bef01f (diff) | |
download | sonar-scanner-cli-fcd0b85e1c08caf84e6e07b992ccec1a76823320.tar.gz sonar-scanner-cli-fcd0b85e1c08caf84e6e07b992ccec1a76823320.zip |
SONARPLUGINS-2202 sonar.projectKey not mandatory on a module def.
=> it is automatically generated from the module Id found in
"sonar.modules"
Diffstat (limited to 'src/main/java/org/sonar/runner')
-rw-r--r-- | src/main/java/org/sonar/runner/internal/Main.java | 7 | ||||
-rw-r--r-- | src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java | 8 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/main/java/org/sonar/runner/internal/Main.java b/src/main/java/org/sonar/runner/internal/Main.java index 61d70ef..8b7566b 100644 --- a/src/main/java/org/sonar/runner/internal/Main.java +++ b/src/main/java/org/sonar/runner/internal/Main.java @@ -20,13 +20,10 @@ package org.sonar.runner.internal; -import org.sonar.runner.internal.bootstrapper.BootstrapException; - import org.sonar.runner.Runner; import org.sonar.runner.RunnerException; - +import org.sonar.runner.internal.bootstrapper.BootstrapException; import org.sonar.runner.internal.bootstrapper.utils.PrivateIOUtils; - import org.sonar.runner.utils.SonarRunnerVersion; import java.io.File; @@ -120,7 +117,7 @@ public final class Main { result.putAll(loadProjectProperties(commandLineProps)); result.putAll(commandLineProps); - if (result.contains(PROJECT_HOME)) { + if (result.containsKey(PROJECT_HOME)) { // the real property of the Sonar Runner is "sonar.projectDir" String baseDir = result.getProperty(PROJECT_HOME); result.remove(PROJECT_HOME); 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 e3b5c19..efbb3d2 100644 --- a/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java +++ b/src/main/java/org/sonar/runner/internal/batch/SonarProjectBuilder.java @@ -169,6 +169,7 @@ public final class SonarProjectBuilder { } private ProjectDefinition loadChildProjectFromProperties(ProjectDefinition parentProject, Properties childProps, String moduleId) { + setProjectKeyIfNotDefined(childProps, moduleId); checkMandatoryProperties(moduleId, childProps, MANDATORY_PROPERTIES_FOR_CHILD); mergeParentProperties(childProps, parentProject.getProperties()); @@ -216,6 +217,13 @@ public final class SonarProjectBuilder { } @VisibleForTesting + protected static void setProjectKeyIfNotDefined(Properties childProps, String moduleId) { + if (!childProps.containsKey(PROPERTY_PROJECT_KEY)) { + childProps.put(PROPERTY_PROJECT_KEY, moduleId); + } + } + + @VisibleForTesting protected static void checkUnicityOfChildKey(ProjectDefinition childProject, ProjectDefinition parentProject) { for (ProjectDefinition definition : parentProject.getSubProjects()) { if (definition.getKey().equals(childProject.getKey())) { |