import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
import java.util.Map.Entry;
+import java.util.Properties;
/**
* Class that creates a Sonar project definition based on a set of properties.
* Array of all mandatory properties required for a project without child.
*/
private static final String[] MANDATORY_PROPERTIES_FOR_SIMPLE_PROJECT = {
- PROPERTY_PROJECT_BASEDIR, CoreProperties.PROJECT_KEY_PROPERTY, CoreProperties.PROJECT_NAME_PROPERTY, CoreProperties.PROJECT_VERSION_PROPERTY, PROPERTY_SOURCES
+ PROPERTY_PROJECT_BASEDIR, CoreProperties.PROJECT_KEY_PROPERTY, CoreProperties.PROJECT_NAME_PROPERTY, CoreProperties.PROJECT_VERSION_PROPERTY
};
/**
if (!ComponentKeys.isValidModuleKey(projectKey)) {
throw new IllegalStateException(String.format(
"Invalid project key '%s'.\n"
- + "Allowed characters are alphanumeric, '-', '_', '.' and ':', with at least one non-digit.", projectKey));
+ + "Allowed characters are alphanumeric, '-', '_', '.' and ':', with at least one non-digit.", projectKey));
}
}
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
+
import java.io.File;
import java.nio.charset.Charset;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
private boolean initialized;
public DefaultModuleFileSystem(ModuleInputFileCache moduleInputFileCache, Project module, Settings settings, FileIndexer indexer, ModuleFileSystemInitializer initializer,
- ComponentIndexer componentIndexer) {
+ ComponentIndexer componentIndexer) {
super(moduleInputFileCache);
this.componentIndexer = componentIndexer;
this.moduleKey = module.getKey();
@Override
public List<File> sourceDirs() {
+ if (sourceDirs.isEmpty()) {
+ // For backward compatibility with File::fromIOFile(file, sourceDirs) we need to always return something
+ return Arrays.asList(baseDir());
+ }
return sourceDirs;
}
throw new IllegalArgumentException("Unsupported file attribute: " + key);
}
-
@Override
public boolean equals(Object o) {
if (this == o) {
}
@Test
- public void shouldFailIfMissingSourceDirectory() throws IOException {
- thrown.expect(IllegalStateException.class);
- thrown.expectMessage("You must define the following mandatory properties for 'com.foo.project': sonar.sources");
-
+ public void shouldNotFailIfMissingSourceDirectory() throws IOException {
loadProjectDefinition("simple-project-with-missing-source-dir");
}
package org.sonar.api.scan.filesystem;
import org.sonar.api.BatchComponent;
+import org.sonar.api.batch.fs.FileSystem;
+import org.sonar.api.batch.fs.InputFile;
import javax.annotation.CheckForNull;
+
import java.io.File;
import java.nio.charset.Charset;
import java.util.List;
File buildDir();
/**
- * Source directories. Non-existing directories are excluded.
- * Example in Maven : ${project.basedir}/src/main/java
- * @deprecated since 4.2 will always return {@link #baseDir()}
+ * Source directories.
+ * @deprecated since 4.2 use {@link FileSystem#files(org.sonar.api.batch.fs.FilePredicate)} to get all files with type {@link InputFile.Type#MAIN}.
*/
List<File> sourceDirs();
/**
* Test directories. Non-existing directories are excluded.
* Example in Maven : ${project.basedir}/src/test/java
- * @deprecated since 4.2 will always return {@link #baseDir()}
+ * @deprecated since 4.2 use {@link FileSystem#files(org.sonar.api.batch.fs.FilePredicate)} to get all files with type {@link InputFile.Type#TEST}.
*/
List<File> testDirs();
* <li>Binary directories can be empty</li>
* <li>Test binary directories are not supported yet.</li>
* </ul>
- * @deprecated since 4.2 sonar.binaries should be converted to language specific property
+ * @deprecated since 4.2 sonar.binaries will be converted to java specific property
*/
List<File> binaryDirs();