protected static void validateDirectories(Map<String, String> props, File baseDir, String projectId) { if (!props.containsKey(PROPERTY_MODULES)) { // SONARPLUGINS-2285 Not an aggregator project so we can validate that paths are correct if defined // Check sonar.tests String[] testPaths = getListFromProperty(props, PROPERTY_TESTS); checkExistenceOfPaths(projectId, baseDir, testPaths, PROPERTY_TESTS); } }
private static void logMissingSourcesAndTests(ProjectDefinition project) { Map<String, String> properties = project.properties(); File baseDir = project.getBaseDir(); logMissingPaths("source", baseDir, getListFromProperty(properties, PROPERTY_SOURCES)); logMissingPaths("test", baseDir, getListFromProperty(properties, PROPERTY_TESTS)); }
String[] moduleIds = getListFromProperty(currentModuleProperties, PROPERTY_MODULES);
@VisibleForTesting protected static void cleanAndCheckModuleProperties(ProjectDefinition project) { Map<String, String> properties = project.properties(); // We need to check the existence of source directories String[] sourcePaths = getListFromProperty(properties, PROPERTY_SOURCES); checkExistenceOfPaths(project.getKey(), project.getBaseDir(), sourcePaths, PROPERTY_SOURCES); }
private void defineChildren(ProjectDefinition parentProject, Map<String, Map<String, String>> propertiesByModuleIdPath, String parentModuleIdPath) { Map<String, String> parentProps = parentProject.properties(); if (parentProps.containsKey(PROPERTY_MODULES)) { for (String moduleId : getListFromProperty(parentProps, PROPERTY_MODULES)) { String moduleIdPath = parentModuleIdPath.isEmpty() ? moduleId : (parentModuleIdPath + "." + moduleId); Map<String, String> moduleProps = propertiesByModuleIdPath.get(moduleIdPath); ProjectDefinition childProject = loadChildProject(parentProject, moduleProps, moduleId); // check the uniqueness of the child key checkUniquenessOfChildKey(childProject, parentProject); // the child project may have children as well defineChildren(childProject, propertiesByModuleIdPath, moduleIdPath); // and finally add this child project to its parent parentProject.addSubProject(childProject); } } }
@Test public void shouldGetList() { Map<String, String> props = new HashMap<>(); props.put("prop", " foo ,, bar , toto,tutu"); assertThat(ProjectReactorBuilder.getListFromProperty(props, "prop")).containsOnly("foo", "bar", "toto", "tutu"); }
@Test public void shouldGetListWithComma() { Map<String, String> props = new HashMap<>(); props.put("prop", "\"foo,bar\", toto,tutu"); assertThat(ProjectReactorBuilder.getListFromProperty(props, "prop")).containsOnly("foo,bar", "toto", "tutu"); }
@Test public void shouldGetEmptyList() { Map<String, String> props = new HashMap<>(); props.put("prop", ""); assertThat(ProjectReactorBuilder.getListFromProperty(props, "prop")).isEmpty(); }
@Test public void shouldGetListFromFile() throws IOException { String filePath = "shouldGetList/foo.properties"; Map<String, String> props = loadPropsFromFile(filePath); assertThat(ProjectReactorBuilder.getListFromProperty(props, "prop")).containsOnly("foo", "bar", "toto", "tutu"); }
protected static void validateDirectories(Map<String, String> props, File baseDir, String projectId) { if (!props.containsKey(PROPERTY_MODULES)) { // SONARPLUGINS-2285 Not an aggregator project so we can validate that paths are correct if defined // Check sonar.tests String[] testPaths = getListFromProperty(props, PROPERTY_TESTS); checkExistenceOfPaths(projectId, baseDir, testPaths, PROPERTY_TESTS); } }
private static void logMissingSourcesAndTests(ProjectDefinition project) { Map<String, String> properties = project.properties(); File baseDir = project.getBaseDir(); logMissingPaths("source", baseDir, getListFromProperty(properties, PROPERTY_SOURCES)); logMissingPaths("test", baseDir, getListFromProperty(properties, PROPERTY_TESTS)); }
String[] moduleIds = getListFromProperty(currentModuleProperties, PROPERTY_MODULES);
@VisibleForTesting protected static void cleanAndCheckModuleProperties(ProjectDefinition project) { Map<String, String> properties = project.properties(); // We need to check the existence of source directories String[] sourcePaths = getListFromProperty(properties, PROPERTY_SOURCES); checkExistenceOfPaths(project.getKey(), project.getBaseDir(), sourcePaths, PROPERTY_SOURCES); }
private void defineChildren(ProjectDefinition parentProject, Map<String, Map<String, String>> propertiesByModuleIdPath, String parentModuleIdPath) { Map<String, String> parentProps = parentProject.properties(); if (parentProps.containsKey(PROPERTY_MODULES)) { for (String moduleId : getListFromProperty(parentProps, PROPERTY_MODULES)) { String moduleIdPath = parentModuleIdPath.isEmpty() ? moduleId : (parentModuleIdPath + "." + moduleId); Map<String, String> moduleProps = propertiesByModuleIdPath.get(moduleIdPath); ProjectDefinition childProject = loadChildProject(parentProject, moduleProps, moduleId); // check the uniqueness of the child key checkUniquenessOfChildKey(childProject, parentProject); // the child project may have children as well defineChildren(childProject, propertiesByModuleIdPath, moduleIdPath); // and finally add this child project to its parent parentProject.addSubProject(childProject); } } }