mirror of https://github.com/apache/maven.git
[MNG-7063] Infinite loop using Shade plugin and JUnit 5 dependency
This commit is contained in:
parent
a515fbe04e
commit
8ceb6c6e99
|
@ -279,7 +279,11 @@ public class DefaultProjectBuilder
|
|||
request.setUserProperties( configuration.getUserProperties() );
|
||||
request.setBuildStartTime( configuration.getBuildStartTime() );
|
||||
request.setModelResolver( resolver );
|
||||
request.setModelCache( DefaultModelCache.newInstance( config.session ) );
|
||||
// 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.setTransformerContextBuilder( config.transformerContextBuilder );
|
||||
|
||||
return request;
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.maven.repository.RepositorySystem;
|
|||
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
|
||||
import org.apache.maven.test.PlexusTest;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.eclipse.aether.DefaultRepositoryCache;
|
||||
import org.eclipse.aether.DefaultRepositorySystemSession;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -171,6 +172,7 @@ public abstract class AbstractMavenProjectTestCase
|
|||
{
|
||||
File localRepo = new File( request.getLocalRepository().getBasedir() );
|
||||
DefaultRepositorySystemSession repoSession = MavenRepositorySystemUtils.newSession();
|
||||
repoSession.setCache( new DefaultRepositoryCache() );
|
||||
repoSession.setLocalRepositoryManager( new LegacyLocalRepositoryManager( localRepo ) );
|
||||
request.setRepositorySession( repoSession );
|
||||
}
|
||||
|
|
|
@ -307,33 +307,34 @@ public class DefaultMavenProjectBuilderTest
|
|||
assertThat( e.getMessage(), containsString( "Version must be a constant" ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that when re-reading a pom, it should not use the cached Model
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void rereadPom_mng7063() throws Exception
|
||||
{
|
||||
final Path pom = projectRoot.resolve( "pom.xml" );
|
||||
|
||||
try ( InputStream pomResource =
|
||||
DefaultMavenProjectBuilderTest.class.getResourceAsStream( "/projects/reread/pom1.xml" ) )
|
||||
/**
|
||||
* Ensure that when re-reading a pom, it should not use the cached Model
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void rereadPom_mng7063() throws Exception
|
||||
{
|
||||
Files.copy( pomResource, pom, StandardCopyOption.REPLACE_EXISTING );
|
||||
final Path pom = projectRoot.resolve( "pom.xml" );
|
||||
final ProjectBuildingRequest buildingRequest = newBuildingRequest();
|
||||
|
||||
try ( InputStream pomResource =
|
||||
DefaultMavenProjectBuilderTest.class.getResourceAsStream( "/projects/reread/pom1.xml" ) )
|
||||
{
|
||||
Files.copy( pomResource, pom, StandardCopyOption.REPLACE_EXISTING );
|
||||
}
|
||||
|
||||
MavenProject project = projectBuilder.build( pom.toFile(), buildingRequest ).getProject();
|
||||
assertThat( project.getName(), is( "aid" ) ); // inherited from artifactId
|
||||
|
||||
try ( InputStream pomResource =
|
||||
DefaultMavenProjectBuilderTest.class.getResourceAsStream( "/projects/reread/pom2.xml" ) )
|
||||
{
|
||||
Files.copy( pomResource, pom, StandardCopyOption.REPLACE_EXISTING );
|
||||
}
|
||||
|
||||
project = projectBuilder.build( pom.toFile(), buildingRequest ).getProject();
|
||||
assertThat( project.getName(), is( "PROJECT NAME" ) );
|
||||
}
|
||||
|
||||
MavenProject project = getProject( pom.toFile() );
|
||||
assertThat( project.getName(), is( "aid" ) ); // inherited from artifactId
|
||||
|
||||
try ( InputStream pomResource =
|
||||
DefaultMavenProjectBuilderTest.class.getResourceAsStream( "/projects/reread/pom2.xml" ) )
|
||||
{
|
||||
Files.copy( pomResource, pom, StandardCopyOption.REPLACE_EXISTING );
|
||||
}
|
||||
|
||||
project = getProject( pom.toFile() );
|
||||
assertThat( project.getName(), is( "PROJECT NAME" ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue