@Test public void shouldSetModuleKeyIfNotPresent() { Map<String, String> props = new HashMap<>(); props.put("sonar.projectVersion", "1.0"); // should be set ProjectReactorBuilder.setModuleKeyAndNameIfNotDefined(props, "foo", "parent"); assertThat(props.get("sonar.moduleKey")).isEqualTo("parent:foo"); assertThat(props.get("sonar.projectName")).isEqualTo("foo"); // but not this 2nd time ProjectReactorBuilder.setModuleKeyAndNameIfNotDefined(props, "bar", "parent"); assertThat(props.get("sonar.moduleKey")).isEqualTo("parent:foo"); assertThat(props.get("sonar.projectName")).isEqualTo("foo"); }
protected ProjectDefinition loadChildProject(ProjectDefinition parentProject, Map<String, String> moduleProps, String moduleId) { final File baseDir; if (moduleProps.containsKey(PROPERTY_PROJECT_BASEDIR)) { baseDir = resolvePath(parentProject.getBaseDir(), moduleProps.get(PROPERTY_PROJECT_BASEDIR)); setProjectBaseDir(baseDir, moduleProps, moduleId); } else { baseDir = new File(parentProject.getBaseDir(), moduleId); setProjectBaseDir(baseDir, moduleProps, moduleId); } setModuleKeyAndNameIfNotDefined(moduleProps, moduleId, parentProject.getKey()); // and finish checkMandatoryProperties(moduleProps, MANDATORY_PROPERTIES_FOR_CHILD); validateDirectories(moduleProps, baseDir, moduleId); mergeParentProperties(moduleProps, parentProject.properties()); return createModuleDefinition(moduleProps, parentProject); }
protected ProjectDefinition loadChildProject(ProjectDefinition parentProject, Map<String, String> moduleProps, String moduleId) { final File baseDir; if (moduleProps.containsKey(PROPERTY_PROJECT_BASEDIR)) { baseDir = resolvePath(parentProject.getBaseDir(), moduleProps.get(PROPERTY_PROJECT_BASEDIR)); setProjectBaseDir(baseDir, moduleProps, moduleId); } else { baseDir = new File(parentProject.getBaseDir(), moduleId); setProjectBaseDir(baseDir, moduleProps, moduleId); } setModuleKeyAndNameIfNotDefined(moduleProps, moduleId, parentProject.getKey()); // and finish checkMandatoryProperties(moduleProps, MANDATORY_PROPERTIES_FOR_CHILD); validateDirectories(moduleProps, baseDir, moduleId); mergeParentProperties(moduleProps, parentProject.properties()); return createModuleDefinition(moduleProps, parentProject); }