mirror of https://github.com/apache/maven.git
PR: MNG-2712
Fix honoring of updatePolicy=daily - create a metadata file even if the remote repo doesn't have one. The following day the repo will again be checked. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@489724 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
260516f8d2
commit
06090da486
|
@ -113,16 +113,16 @@ public abstract class AbstractRepositoryMetadata
|
|||
{
|
||||
changed = metadata.merge( this.metadata );
|
||||
}
|
||||
|
||||
|
||||
// beware meta-versions!
|
||||
String version = metadata.getVersion();
|
||||
if ( version != null && ( Artifact.LATEST_VERSION.equals( version ) || Artifact.RELEASE_VERSION.equals( version ) ) )
|
||||
{
|
||||
// meta-versions are not valid <version/> values...don't write them.
|
||||
changed = false;
|
||||
metadata.setVersion( null );
|
||||
}
|
||||
|
||||
if ( changed )
|
||||
if ( changed || !metadataFile.exists() )
|
||||
{
|
||||
Writer writer = null;
|
||||
try
|
||||
|
|
|
@ -78,6 +78,8 @@ public class DefaultRepositoryMetadataManager
|
|||
File file = new File( localRepository.getBasedir(),
|
||||
localRepository.pathOfLocalRepositoryMetadata( metadata, repository ) );
|
||||
|
||||
|
||||
|
||||
boolean checkForUpdates =
|
||||
policy.checkOutOfDate( new Date( file.lastModified() ) ) || !file.exists();
|
||||
|
||||
|
@ -106,7 +108,7 @@ public class DefaultRepositoryMetadataManager
|
|||
{
|
||||
file.setLastModified( System.currentTimeMillis() );
|
||||
}
|
||||
else if ( !metadataIsEmpty )
|
||||
else
|
||||
{
|
||||
// this ensures that files are not continuously checked when they don't exist remotely
|
||||
try
|
||||
|
|
|
@ -18,63 +18,67 @@ public class AbstractRepositoryMetadataTest
|
|||
|
||||
private MockManager mm = new MockManager();
|
||||
private TestFileManager fileManager = new TestFileManager( "AbstractRepositoryMetadataTest.test.", "" );
|
||||
|
||||
|
||||
public void tearDown() throws IOException
|
||||
{
|
||||
fileManager.cleanUp();
|
||||
}
|
||||
|
||||
public void testUpdateRepositoryMetadata_ShouldNotStoreIfMainVersionIsLATEST()
|
||||
public void testUpdateRepositoryMetadata_NoVersionTagIfMainVersionIsLATEST()
|
||||
throws IOException, XmlPullParserException
|
||||
{
|
||||
MockAndControlForArtifactRepository local = new MockAndControlForArtifactRepository();
|
||||
MockAndControlForArtifactRepository remote = new MockAndControlForArtifactRepository();
|
||||
|
||||
|
||||
File basedir = fileManager.createTempDir();
|
||||
|
||||
|
||||
String path = "metadata.xml";
|
||||
|
||||
|
||||
Metadata m = new Metadata();
|
||||
m.setVersion( Artifact.LATEST_VERSION );
|
||||
|
||||
|
||||
TestRepoMetadata trm = new TestRepoMetadata( m );
|
||||
|
||||
|
||||
local.expectGetBasedir( basedir );
|
||||
local.expectPathOfLocalRepositoryMetadata( trm, remote.repository, path );
|
||||
|
||||
|
||||
mm.replayAll();
|
||||
|
||||
|
||||
trm.updateRepositoryMetadata( local.repository, remote.repository );
|
||||
|
||||
fileManager.assertFileExistence( basedir, path, false );
|
||||
|
||||
|
||||
fileManager.assertFileExistence( basedir, path, true );
|
||||
assertTrue( fileManager.getFileContents( new File( basedir, path ) ).indexOf( "<version>"
|
||||
+ Artifact.LATEST_VERSION + "</version>" ) < 0 );
|
||||
|
||||
mm.verifyAll();
|
||||
}
|
||||
|
||||
public void testUpdateRepositoryMetadata_ShouldNotStoreIfMainVersionIsRELEASE()
|
||||
public void testUpdateRepositoryMetadata_NoVersionTagIfVersionIsRELEASE()
|
||||
throws IOException, XmlPullParserException
|
||||
{
|
||||
MockAndControlForArtifactRepository local = new MockAndControlForArtifactRepository();
|
||||
MockAndControlForArtifactRepository remote = new MockAndControlForArtifactRepository();
|
||||
|
||||
|
||||
File basedir = fileManager.createTempDir();
|
||||
|
||||
|
||||
String path = "metadata.xml";
|
||||
|
||||
|
||||
Metadata m = new Metadata();
|
||||
m.setVersion( Artifact.RELEASE_VERSION );
|
||||
|
||||
|
||||
TestRepoMetadata trm = new TestRepoMetadata( m );
|
||||
|
||||
|
||||
local.expectGetBasedir( basedir );
|
||||
local.expectPathOfLocalRepositoryMetadata( trm, remote.repository, path );
|
||||
|
||||
|
||||
mm.replayAll();
|
||||
|
||||
|
||||
trm.updateRepositoryMetadata( local.repository, remote.repository );
|
||||
|
||||
fileManager.assertFileExistence( basedir, path, false );
|
||||
|
||||
|
||||
fileManager.assertFileExistence( basedir, path, true );
|
||||
assertTrue( fileManager.getFileContents( new File( basedir, path ) ).indexOf( "<version>"
|
||||
+ Artifact.RELEASE_VERSION + "</version>" ) < 0 );
|
||||
|
||||
mm.verifyAll();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue