[MNG-7063] Infinite loop using Shade plugin and JUnit 5 dependency

This commit is contained in:
rfscholte 2021-02-20 20:14:36 +01:00
parent a515fbe04e
commit 8ceb6c6e99
3 changed files with 34 additions and 27 deletions

View File

@ -279,7 +279,11 @@ public class DefaultProjectBuilder
request.setUserProperties( configuration.getUserProperties() ); request.setUserProperties( configuration.getUserProperties() );
request.setBuildStartTime( configuration.getBuildStartTime() ); request.setBuildStartTime( configuration.getBuildStartTime() );
request.setModelResolver( resolver ); request.setModelResolver( resolver );
// this is a hint that we want to build 1 file, so don't cache. See MNG-7063
if ( config.modelPool != null )
{
request.setModelCache( DefaultModelCache.newInstance( config.session ) ); request.setModelCache( DefaultModelCache.newInstance( config.session ) );
}
request.setTransformerContextBuilder( config.transformerContextBuilder ); request.setTransformerContextBuilder( config.transformerContextBuilder );
return request; return request;

View File

@ -29,6 +29,7 @@ import org.apache.maven.repository.RepositorySystem;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils; import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.apache.maven.test.PlexusTest; import org.apache.maven.test.PlexusTest;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.eclipse.aether.DefaultRepositoryCache;
import org.eclipse.aether.DefaultRepositorySystemSession; import org.eclipse.aether.DefaultRepositorySystemSession;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -171,6 +172,7 @@ public abstract class AbstractMavenProjectTestCase
{ {
File localRepo = new File( request.getLocalRepository().getBasedir() ); File localRepo = new File( request.getLocalRepository().getBasedir() );
DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession(); DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession();
repoSession.setCache( new DefaultRepositoryCache() );
repoSession.setLocalRepositoryManager( new LegacyLocalRepositoryManager( localRepo ) ); repoSession.setLocalRepositoryManager( new LegacyLocalRepositoryManager( localRepo ) );
request.setRepositorySession( repoSession ); request.setRepositorySession( repoSession );
} }

View File

@ -316,6 +316,7 @@ public class DefaultMavenProjectBuilderTest
public void rereadPom_mng7063() throws Exception public void rereadPom_mng7063() throws Exception
{ {
final Path pom = projectRoot.resolve( "pom.xml" ); final Path pom = projectRoot.resolve( "pom.xml" );
final ProjectBuildingRequest buildingRequest = newBuildingRequest();
try ( InputStream pomResource = try ( InputStream pomResource =
DefaultMavenProjectBuilderTest.class.getResourceAsStream( "/projects/reread/pom1.xml" ) ) DefaultMavenProjectBuilderTest.class.getResourceAsStream( "/projects/reread/pom1.xml" ) )
@ -323,7 +324,7 @@ public class DefaultMavenProjectBuilderTest
Files.copy( pomResource, pom, StandardCopyOption.REPLACE_EXISTING ); Files.copy( pomResource, pom, StandardCopyOption.REPLACE_EXISTING );
} }
MavenProject project = getProject( pom.toFile() ); MavenProject project = projectBuilder.build( pom.toFile(), buildingRequest ).getProject();
assertThat( project.getName(), is( "aid" ) ); // inherited from artifactId assertThat( project.getName(), is( "aid" ) ); // inherited from artifactId
try ( InputStream pomResource = try ( InputStream pomResource =
@ -332,7 +333,7 @@ public class DefaultMavenProjectBuilderTest
Files.copy( pomResource, pom, StandardCopyOption.REPLACE_EXISTING ); Files.copy( pomResource, pom, StandardCopyOption.REPLACE_EXISTING );
} }
project = getProject( pom.toFile() ); project = projectBuilder.build( pom.toFile(), buildingRequest ).getProject();
assertThat( project.getName(), is( "PROJECT NAME" ) ); assertThat( project.getName(), is( "PROJECT NAME" ) );
} }