@@ -71,7 +71,6 @@ public class SourcePersister implements ScanPersister { | |||
private static final Logger LOG = LoggerFactory.getLogger(SourcePersister.class); | |||
private static final String BOM = "\uFEFF"; | |||
private final ResourcePersister resourcePersister; | |||
private final InputPathCache inputPathCache; | |||
private final MyBatis mybatis; | |||
private final MeasureCache measureCache; | |||
@@ -82,10 +81,9 @@ public class SourcePersister implements ScanPersister { | |||
private CodeColorizers codeColorizers; | |||
private DuplicationCache duplicationCache; | |||
public SourcePersister(ResourcePersister resourcePersister, InputPathCache inputPathCache, | |||
public SourcePersister(InputPathCache inputPathCache, | |||
MyBatis mybatis, MeasureCache measureCache, ComponentDataCache componentDataCache, ProjectTree projectTree, System2 system2, | |||
ResourceCache resourceCache, CodeColorizers codeColorizers, DuplicationCache duplicationCache) { | |||
this.resourcePersister = resourcePersister; | |||
this.inputPathCache = inputPathCache; | |||
this.mybatis = mybatis; | |||
this.measureCache = measureCache; |
@@ -115,8 +115,7 @@ public class ProjectReactorBuilder { | |||
rootProjectWorkDir = rootProject.getWorkDir(); | |||
defineChildren(rootProject, propertiesByModuleId); | |||
cleanAndCheckProjectDefinitions(rootProject); | |||
// Optimization remove all children properties from taskProps | |||
taskProps.properties().clear(); | |||
// Since task properties are now empty we should add root module properties | |||
for (Map.Entry<String, String> entry : propertiesByModuleId.get("").entrySet()) { | |||
taskProps.properties().put((String) entry.getKey(), (String) entry.getValue()); | |||
} | |||
@@ -157,7 +156,7 @@ public class ProjectReactorBuilder { | |||
File workDir; | |||
if (parent == null) { | |||
validateDirectories(rootProperties, baseDir, projectKey); | |||
workDir = initRootProjectWorkDir(baseDir); | |||
workDir = initRootProjectWorkDir(baseDir, rootProperties); | |||
} else { | |||
workDir = initModuleWorkDir(baseDir, rootProperties); | |||
} | |||
@@ -169,8 +168,8 @@ public class ProjectReactorBuilder { | |||
} | |||
@VisibleForTesting | |||
protected File initRootProjectWorkDir(File baseDir) { | |||
String workDir = taskProps.property(CoreProperties.WORKING_DIRECTORY); | |||
protected File initRootProjectWorkDir(File baseDir, Map<String, String> rootProperties) { | |||
String workDir = rootProperties.get(CoreProperties.WORKING_DIRECTORY); | |||
if (StringUtils.isBlank(workDir)) { | |||
return new File(baseDir, CoreProperties.WORKING_DIRECTORY_DEFAULT_VALUE); | |||
} |
@@ -34,7 +34,6 @@ import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.api.measures.Measure; | |||
import org.sonar.api.resources.File; | |||
import org.sonar.api.resources.Project; | |||
import org.sonar.api.resources.Resource; | |||
import org.sonar.api.utils.DateUtils; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.batch.ProjectTree; | |||
@@ -56,7 +55,6 @@ import java.util.Collections; | |||
import java.util.Date; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
import static org.mockito.Matchers.any; | |||
import static org.mockito.Matchers.anyString; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
@@ -81,10 +79,8 @@ public class SourcePersisterTest extends AbstractDaoTestCase { | |||
@Before | |||
public void before() throws IOException { | |||
ResourcePersister resourcePersister = mock(ResourcePersister.class); | |||
Snapshot snapshot = new Snapshot(); | |||
snapshot.setId(1000); | |||
when(resourcePersister.getSnapshotOrFail(any(Resource.class))).thenReturn(snapshot); | |||
inputPathCache = mock(InputPathCache.class); | |||
resourceCache = mock(ResourceCache.class); | |||
projectTree = mock(ProjectTree.class); | |||
@@ -93,7 +89,7 @@ public class SourcePersisterTest extends AbstractDaoTestCase { | |||
when(measureCache.byMetric(anyString(), anyString())).thenReturn(Collections.<org.sonar.api.measures.Measure>emptyList()); | |||
componentDataCache = mock(ComponentDataCache.class); | |||
duplicationCache = mock(DuplicationCache.class); | |||
sourcePersister = new SourcePersister(resourcePersister, inputPathCache, | |||
sourcePersister = new SourcePersister(inputPathCache, | |||
getMyBatis(), measureCache, componentDataCache, projectTree, system2, | |||
resourceCache, mock(CodeColorizers.class), duplicationCache); | |||
Project project = new Project(PROJECT_KEY); |
@@ -437,7 +437,7 @@ public class ProjectReactorBuilderTest { | |||
ProjectReactorBuilder builder = new ProjectReactorBuilder(new TaskProperties(Maps.<String, String>newHashMap(), null)); | |||
File baseDir = new File("target/tmp/baseDir"); | |||
File workDir = builder.initRootProjectWorkDir(baseDir); | |||
File workDir = builder.initRootProjectWorkDir(baseDir, Maps.<String, String>newHashMap()); | |||
assertThat(workDir).isEqualTo(new File(baseDir, ".sonar")); | |||
} | |||
@@ -449,7 +449,7 @@ public class ProjectReactorBuilderTest { | |||
ProjectReactorBuilder builder = new ProjectReactorBuilder(new TaskProperties(props, null)); | |||
File baseDir = new File("target/tmp/baseDir"); | |||
File workDir = builder.initRootProjectWorkDir(baseDir); | |||
File workDir = builder.initRootProjectWorkDir(baseDir, props); | |||
assertThat(workDir).isEqualTo(new File(baseDir, ".foo")); | |||
} | |||
@@ -461,7 +461,7 @@ public class ProjectReactorBuilderTest { | |||
ProjectReactorBuilder builder = new ProjectReactorBuilder(new TaskProperties(props, null)); | |||
File baseDir = new File("target/tmp/baseDir"); | |||
File workDir = builder.initRootProjectWorkDir(baseDir); | |||
File workDir = builder.initRootProjectWorkDir(baseDir, props); | |||
assertThat(workDir).isEqualTo(new File("src").getAbsoluteFile()); | |||
} |