Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ class IncrementalModuleBuilderImpl
public void build()
throws ExecutionException, InterruptedException
{
this.mavenSession.setProjects( this.projects );

logger.info( "Recalculated reactor:" );
for ( MavenProject mavenProject : this.mavenSession.getProjects() )
for ( MavenProject mavenProject : this.projects )
{
logger.info( " {}", mavenProject.getName() );
}
Expand All @@ -108,7 +106,7 @@ public void build()
{
logger.debug( " task:" + task );
}
for ( MavenProject mavenProject : mavenSession.getProjects() )
for ( MavenProject mavenProject : this.projects )
{
logger.info( "Building project: {}", mavenProject.getId() );
lifecycleModuleBuilder.buildProject( mavenSession, reactorContext, mavenProject, taskSegment );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,28 @@ public List<MavenProject> calculateChangedModules( Path projectRootpath )
// TODO: Think about if we got only pom packaging modules? Do we
// need to do something special there?
List<MavenProject> result = new ArrayList<>();
for ( MavenProject project : projectList )
for ( ScmFile fileItem : changeList )
{
Path relativize = projectRootpath.relativize( project.getBasedir().toPath() );
for ( ScmFile fileItem : changeList )
MavenProject project = null;
int longestRelativePathLength = -1;
for ( MavenProject currProject : projectList )
{
boolean startsWith = new File( fileItem.getPath() ).toPath().startsWith( relativize );
logger.debug( "startswith: " + startsWith + " " + fileItem.getPath() + " " + relativize );
if ( startsWith )
Path relativize = projectRootpath.relativize( currProject.getBasedir().toPath() );
boolean startsWith = "".equals(relativize.toString()) || ".".equals(relativize.toString())
|| new File(fileItem.getPath()).toPath().startsWith(relativize);
logger.debug("startswith: " + startsWith + " " + fileItem.getPath() + " " + relativize);
int currRelativePathLength = relativize.toString().length();
if (startsWith && longestRelativePathLength < currRelativePathLength)
{
if ( !result.contains( project ) )
{
result.add( project );
}
longestRelativePathLength = currRelativePathLength;
project = currProject;
}
}
if (project != null && !result.contains(project)) {
result.add(project);
}
}

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class ModuleCalculatorTest

private MavenProject subdomain = createProject( "subdomain", new File( baseDir, "domain/subdomain" ) );

private MavenProject subsubdomain = createProject( "subsubdomain", new File( baseDir, "domain/subdomain/subsubdomain" ) );

private ModuleCalculator moduleCalculator;

@Before
Expand All @@ -61,6 +63,7 @@ public void before()
projectList.add( assembly );
projectList.add( domain );
projectList.add( subdomain );
projectList.add( subsubdomain );
}

private MavenProject createProject( String artifactId, File baseDir )
Expand Down Expand Up @@ -125,7 +128,7 @@ public void shouldResultInTwoModulesDomainAndSubDomain()
assertThat( changedModules ).hasSize( 2 ).containsOnly( domain, subdomain );
}

@Ignore
@Test
public void shouldResultInThreeModules()
{
// TODO: Think about this test case. What
Expand All @@ -143,4 +146,17 @@ public void shouldResultInThreeModules()
assertThat( changedModules ).hasSize( 3 ).containsOnly( domain, subdomain, parent );
}

@Test
public void shouldReturnOnlyChangedModules() {
Path root = baseDir.toPath();
List<ScmFile> changeList = Arrays.asList(
new ScmFile( "domain/subdomain/subsubdomain/pom.xml", ScmFileStatus.MODIFIED ),
new ScmFile( "domain/pom.xml", ScmFileStatus.MODIFIED )
);
moduleCalculator = new ModuleCalculator( projectList, changeList );
List<MavenProject> changedModules = moduleCalculator.calculateChangedModules( root );

assertThat( changedModules ).hasSize( 2 ).containsOnly( subsubdomain, domain );
}

}