import org.sonar.batch.bootstrap.BootstrapSettings;
import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
*/
public class ProjectReactorBuilder {
+ private static final String INVALID_VALUE_OF_X_FOR_Y = "Invalid value of {0} for {1}";
+
private static final Logger LOG = LoggerFactory.getLogger(ProjectReactorBuilder.class);
/**
return new ProjectReactor(rootProject);
}
- protected ProjectDefinition defineProject(Properties properties, ProjectDefinition parent) {
+ protected ProjectDefinition defineProject(Properties properties, @Nullable ProjectDefinition parent) {
File baseDir = new File(properties.getProperty(PROPERTY_PROJECT_BASEDIR));
if (properties.containsKey(PROPERTY_MODULES)) {
checkMandatoryProperties(properties, MANDATORY_PROPERTIES_FOR_MULTIMODULE_PROJECT);
workDir = initModuleWorkDir(baseDir, properties);
}
- ProjectDefinition definition = ProjectDefinition.create().setProperties(properties)
+ return ProjectDefinition.create().setProperties(properties)
.setBaseDir(baseDir)
.setWorkDir(workDir)
.setBuildDir(initModuleBuildDir(baseDir, properties));
- return definition;
}
@VisibleForTesting
for (String pattern : getListFromProperty(props, PROPERTY_LIBRARIES)) {
File[] files = getLibraries(baseDir, pattern);
if (files == null || files.length == 0) {
- LOG.error("Invalid value of " + PROPERTY_LIBRARIES + " for " + projectId);
+ LOG.error(MessageFormat.format(INVALID_VALUE_OF_X_FOR_Y, PROPERTY_LIBRARIES, projectId));
throw new IllegalStateException("No files nor directories matching '" + pattern + "' in directory " + baseDir);
}
}
for (String path : sourceDirs) {
File sourceFolder = resolvePath(baseDir, path);
if (!sourceFolder.isDirectory()) {
- LOG.error("Invalid value of " + propName + " for " + moduleRef);
+ LOG.error(MessageFormat.format(INVALID_VALUE_OF_X_FOR_Y, propName, moduleRef));
throw new IllegalStateException("The folder '" + path + "' does not exist for '" + moduleRef +
"' (base directory = " + baseDir.getAbsolutePath() + ")");
}
import org.apache.commons.lang.StringUtils;
import org.sonar.api.CoreProperties;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
import java.io.File;
import java.util.List;
import java.util.Properties;
return baseDir;
}
- public ProjectDefinition setWorkDir(File workDir) {
+ public ProjectDefinition setWorkDir(@Nullable File workDir) {
this.workDir = workDir;
return this;
}
+ @CheckForNull
public File getWorkDir() {
return workDir;
}
- public ProjectDefinition setBuildDir(File d) {
+ public ProjectDefinition setBuildDir(@Nullable File d) {
this.buildDir = d;
return this;
}
+ @CheckForNull
public File getBuildDir() {
return buildDir;
}