This situation shouldn't lead to partial analysis.
private MavenProjectConverter() {
}
- public static ProjectDefinition convert(List<MavenProject> poms) {
+ public static ProjectDefinition convert(List<MavenProject> poms, MavenProject root) {
Map<String, MavenProject> paths = Maps.newHashMap(); // projects by canonical path
Map<MavenProject, ProjectDefinition> defs = Maps.newHashMap();
throw new SonarException(e);
}
- return defs.get(poms.get(0));
+ return defs.get(root);
}
- public static ProjectDefinition convert(MavenProject pom) {
+ /**
+ * Visibility has been relaxed for tests.
+ */
+ static ProjectDefinition convert(MavenProject pom) {
Properties properties = new Properties();
String key = new StringBuilder().append(pom.getGroupId()).append(":").append(pom.getArtifactId()).toString();
protected ProjectTree(ProjectBuilder projectBuilder, List<MavenProject> poms) {
this.projectBuilder = projectBuilder;
definitions = Lists.newArrayList();
- collectProjects(MavenProjectConverter.convert(poms), definitions);
+ collectProjects(MavenProjectConverter.convert(poms, poms.get(0)), definitions);
}
/**
public class MavenProjectConverterTest {
@Test
- public void test2() {
+ public void shouldConvertModules() {
MavenProject root = new MavenProject();
root.setFile(new File("/foo/pom.xml"));
root.getModules().add("module");
MavenProject module = new MavenProject();
module.setFile(new File("/foo/module/pom.xml"));
- ProjectDefinition project = MavenProjectConverter.convert(Arrays.asList(root, module));
+ ProjectDefinition project = MavenProjectConverter.convert(Arrays.asList(root, module), root);
assertThat(project.getModules().size(), is(1));
}
@Test
- public void test() {
+ public void shouldConvertProperties() {
MavenProject pom = new MavenProject();
pom.setGroupId("foo");
pom.setArtifactId("bar");
}
private void executeBatch() throws MojoExecutionException {
- ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects());
+ ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects(), project);
Reactor reactor = new Reactor(def);
Batch batch = new Batch(getInitialConfiguration(), reactor, session, project,
}
private void executeBatch() throws MojoExecutionException {
- ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects());
+ ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects(), project);
Reactor reactor = new Reactor(def);
Batch batch = new Batch(getInitialConfiguration(),
}
private void executeBatch() throws MojoExecutionException {
- ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects());
+ ProjectDefinition def = MavenProjectConverter.convert(session.getSortedProjects(), project);
Reactor reactor = new Reactor(def);
Batch batch = new Batch(getInitialConfiguration(),