本文整理汇总了Java中org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata类的典型用法代码示例。如果您正苦于以下问题:Java ArtifactRepositoryMetadata类的具体用法?Java ArtifactRepositoryMetadata怎么用?Java ArtifactRepositoryMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArtifactRepositoryMetadata类属于org.apache.maven.artifact.repository.metadata包,在下文中一共展示了ArtifactRepositoryMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIncorrectSourceChecksumMd5
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
@Test
public void testIncorrectSourceChecksumMd5()
throws Exception
{
// test that it fails when the source md5 is wrong
Artifact artifact = createArtifact( "test", "incorrectMd5Artifact", "1.0.0" );
File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
file.delete();
artifactConverter.convert( artifact, targetRepository );
checkWarnings( artifactConverter, 2 );
assertHasWarningReason( artifactConverter, Messages.getString( "failure.incorrect.md5" ) );
assertFalse( "Check artifact not created", file.exists() );
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
File metadataFile =
new File( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata( metadata ) );
assertFalse( "Check metadata not created", metadataFile.exists() );
}
示例2: testIncorrectSourceChecksumSha1
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
@Test
public void testIncorrectSourceChecksumSha1()
throws Exception
{
// test that it fails when the source sha1 is wrong
Artifact artifact = createArtifact( "test", "incorrectSha1Artifact", "1.0.0" );
File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
file.delete();
artifactConverter.convert( artifact, targetRepository );
checkWarnings( artifactConverter, 2 );
assertHasWarningReason( artifactConverter, Messages.getString( "failure.incorrect.sha1" ) );
assertFalse( "Check artifact not created", file.exists() );
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
File metadataFile =
new File( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata( metadata ) );
assertFalse( "Check metadata not created", metadataFile.exists() );
}
示例3: testInvalidSourceArtifactMetadata
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
@Test
public void testInvalidSourceArtifactMetadata()
throws Exception
{
// test artifact is not converted when source metadata is invalid, and returns failure
createModernSourceRepository();
Artifact artifact = createArtifact( "test", "incorrectArtifactMetadata", "1.0.0" );
File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
file.delete();
artifactConverter.convert( artifact, targetRepository );
checkWarnings( artifactConverter, 2 );
assertHasWarningReason( artifactConverter,
Messages.getString( "failure.incorrect.artifactMetadata.versions" ) );
assertFalse( "Check artifact not created", file.exists() );
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
File metadataFile =
new File( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata( metadata ) );
assertFalse( "Check metadata not created", metadataFile.exists() );
}
示例4: testInvalidSourceSnapshotMetadata
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
@Test
public void testInvalidSourceSnapshotMetadata()
throws Exception
{
// test artifact is not converted when source snapshot metadata is invalid and returns failure
createModernSourceRepository();
Artifact artifact = createArtifact( "test", "incorrectSnapshotMetadata", "1.0.0-20060102.030405-6" );
File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
file.delete();
artifactConverter.convert( artifact, targetRepository );
checkWarnings( artifactConverter, 2 );
assertHasWarningReason( artifactConverter,
Messages.getString( "failure.incorrect.snapshotMetadata.snapshot" ) );
assertFalse( "Check artifact not created", file.exists() );
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
File metadataFile =
new File( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata( metadata ) );
assertFalse( "Check metadata not created", metadataFile.exists() );
}
示例5: retrieveLatestReleasedVersion
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
private String retrieveLatestReleasedVersion(final Artifact artifact) {
final RepositoryMetadata metadata = new ArtifactRepositoryMetadata(artifact);
try {
repositoryMetadataManager.resolve(metadata, currentProject.getRemoteArtifactRepositories(), localRepository);
} catch (final RepositoryMetadataResolutionException e1) {
e1.printStackTrace();
}
final Metadata repoMetadata = metadata.getMetadata();
if (repoMetadata.getVersioning() != null) {
final String releasedVersion = repoMetadata.getVersioning().getRelease();
if (releasedVersion != null) {
return releasedVersion;
}
final String latestVersion = repoMetadata.getVersioning().getLatest();
if (latestVersion != null) {
return latestVersion;
}
}
return repoMetadata.getVersion();
}
示例6: testIncorrectSourceChecksumMd5
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
@Test
public void testIncorrectSourceChecksumMd5()
throws Exception
{
// test that it fails when the source md5 is wrong
Artifact artifact = createArtifact( "test", "incorrectMd5Artifact", "1.0.0" );
Path file = Paths.get( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
Files.deleteIfExists(file);
artifactConverter.convert( artifact, targetRepository );
checkWarnings( artifactConverter, 2 );
assertHasWarningReason( artifactConverter, Messages.getString( "failure.incorrect.md5" ) );
assertFalse( "Check artifact not created", Files.exists(file) );
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
Path metadataFile = Paths.get( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata( metadata ) );
assertFalse( "Check metadata not created", Files.exists(metadataFile) );
}
示例7: testIncorrectSourceChecksumSha1
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
@Test
public void testIncorrectSourceChecksumSha1()
throws Exception
{
// test that it fails when the source sha1 is wrong
Artifact artifact = createArtifact( "test", "incorrectSha1Artifact", "1.0.0" );
Path file = Paths.get( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
Files.deleteIfExists(file);
artifactConverter.convert( artifact, targetRepository );
checkWarnings( artifactConverter, 2 );
assertHasWarningReason( artifactConverter, Messages.getString( "failure.incorrect.sha1" ) );
assertFalse( "Check artifact not created", Files.exists(file) );
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
Path metadataFile = Paths.get( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata( metadata ) );
assertFalse( "Check metadata not created", Files.exists(metadataFile) );
}
示例8: testInvalidSourceArtifactMetadata
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
@Test
public void testInvalidSourceArtifactMetadata()
throws Exception
{
// test artifact is not converted when source metadata is invalid, and returns failure
createModernSourceRepository();
Artifact artifact = createArtifact( "test", "incorrectArtifactMetadata", "1.0.0" );
Path file = Paths.get( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
Files.deleteIfExists(file);
artifactConverter.convert( artifact, targetRepository );
checkWarnings( artifactConverter, 2 );
assertHasWarningReason( artifactConverter,
Messages.getString( "failure.incorrect.artifactMetadata.versions" ) );
assertFalse( "Check artifact not created", Files.exists(file) );
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
Path metadataFile = Paths.get( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata( metadata ) );
assertFalse( "Check metadata not created", Files.exists(metadataFile) );
}
示例9: testInvalidSourceSnapshotMetadata
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
@Test
public void testInvalidSourceSnapshotMetadata()
throws Exception
{
// test artifact is not converted when source snapshot metadata is invalid and returns failure
createModernSourceRepository();
Artifact artifact = createArtifact( "test", "incorrectSnapshotMetadata", "1.0.0-20060102.030405-6" );
Path file = Paths.get( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
Files.deleteIfExists(file);
artifactConverter.convert( artifact, targetRepository );
checkWarnings( artifactConverter, 2 );
assertHasWarningReason( artifactConverter,
Messages.getString( "failure.incorrect.snapshotMetadata.snapshot" ) );
assertFalse( "Check artifact not created", Files.exists(file) );
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
Path metadataFile = Paths.get( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata( metadata ) );
assertFalse( "Check metadata not created", Files.exists(metadataFile) );
}
示例10: testMetadata
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
public void testMetadata() throws Exception
{
ArtifactRepository remoteRepository = remoteRepository();
ArtifactRepository localRepository = localRepository();
Artifact a = createRemoteArtifact( "a", "0.0.1-SNAPSHOT" );
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( a );
File file = new File( localRepository.getBasedir(),
localRepository.pathOfLocalRepositoryMetadata( metadata, localRepository ) );
file.delete();
File touchFile = updateCheckManager.getTouchfile( metadata, file );
touchFile.delete();
assertTrue( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) );
file.getParentFile().mkdirs();
file.createNewFile();
updateCheckManager.touch( metadata, remoteRepository, file );
assertFalse( updateCheckManager.isUpdateRequired( metadata, remoteRepository, file ) );
assertNotNull( updateCheckManager.readLastUpdated( touchFile, updateCheckManager.getMetadataKey( remoteRepository, file ) ) );
}
示例11: retrieveAvailableVersions
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
public List<ArtifactVersion> retrieveAvailableVersions( MetadataResolutionRequest request )
throws ArtifactMetadataRetrievalException
{
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( request.getArtifact() );
try
{
repositoryMetadataManager.resolve( metadata, request );
}
catch ( RepositoryMetadataResolutionException e )
{
throw new ArtifactMetadataRetrievalException( e.getMessage(), e, request.getArtifact() );
}
List<String> availableVersions = request.getLocalRepository().findVersions( request.getArtifact() );
return retrieveAvailableVersionsFromMetadata( metadata.getMetadata(), availableVersions );
}
示例12: retrieveAvailableVersionsFromDeploymentRepository
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact,
ArtifactRepository localRepository,
ArtifactRepository deploymentRepository )
throws ArtifactMetadataRetrievalException
{
RepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
try
{
repositoryMetadataManager.resolveAlways( metadata, localRepository, deploymentRepository );
}
catch ( RepositoryMetadataResolutionException e )
{
throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
}
List<String> availableVersions = localRepository.findVersions( artifact );
return retrieveAvailableVersionsFromMetadata( metadata.getMetadata(), availableVersions );
}
示例13: testV3PomConvertWithRelocation
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
@Test
public void testV3PomConvertWithRelocation()
throws Exception
{
Artifact artifact = createArtifact( "test", "relocated-v3artifact", "1.0.0" );
ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact );
File artifactMetadataFile = new File( targetRepository.getBasedir(),
targetRepository.pathOfRemoteRepositoryMetadata( artifactMetadata ) );
artifactMetadataFile.delete();
ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata( artifact );
File versionMetadataFile = new File( targetRepository.getBasedir(),
targetRepository.pathOfRemoteRepositoryMetadata( versionMetadata ) );
versionMetadataFile.delete();
artifactConverter.convert( artifact, targetRepository );
//checkSuccess(); --> commented until MNG-2100 is fixed
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
assertTrue( "Check if relocated artifact created", artifactFile.exists() );
assertTrue( "Check if relocated artifact matches",
FileUtils.contentEquals( artifactFile, artifact.getFile() ) );
Artifact pomArtifact = createArtifact( "relocated-test", "relocated-v3artifact", "1.0.0", "1.0.0", "pom" );
File pomFile = getTestFile( "src/test/expected-files/" + targetRepository.pathOf( pomArtifact ) );
File testFile = getTestFile( "target/test-target-repository/" + targetRepository.pathOf( pomArtifact ) );
compareFiles( pomFile, testFile );
Artifact orig = createArtifact( "test", "relocated-v3artifact", "1.0.0", "1.0.0", "pom" );
artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( orig ) );
assertTrue( "Check if relocation artifact pom is created", artifactFile.exists() );
testFile = getTestFile( "src/test/expected-files/" + targetRepository.pathOf( orig ) );
compareFiles( artifactFile, testFile );
}
示例14: testV3PomWarningsOnConvert
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
@Test
public void testV3PomWarningsOnConvert()
throws Exception
{
// test that the pom is converted but that warnings are reported
Artifact artifact = createArtifact( "test", "v3-warnings-artifact", "1.0.0" );
ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact );
File artifactMetadataFile = new File( targetRepository.getBasedir(),
targetRepository.pathOfRemoteRepositoryMetadata( artifactMetadata ) );
artifactMetadataFile.delete();
ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata( artifact );
File versionMetadataFile = new File( targetRepository.getBasedir(),
targetRepository.pathOfRemoteRepositoryMetadata( versionMetadata ) );
versionMetadataFile.delete();
artifactConverter.convert( artifact, targetRepository );
checkWarnings( artifactConverter, 2 );
File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
assertTrue( "Check artifact created", artifactFile.exists() );
assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) );
artifact = createPomArtifact( artifact );
File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
File expectedPomFile = getTestFile( "src/test/expected-files/converted-v3-warnings.pom" );
assertTrue( "Check POM created", pomFile.exists() );
compareFiles( expectedPomFile, pomFile );
// TODO: check 2 warnings (extend and versions) matched on i18n key
}
示例15: testModifedArtifactFails
import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; //导入依赖的package包/类
@Test
public void testModifedArtifactFails()
throws Exception
{
// test that it fails when the source artifact has changed and is different to the existing artifact in the
// target repository
Artifact artifact = createArtifact( "test", "modified-artifact", "1.0.0" );
Artifact pomArtifact = createPomArtifact( artifact );
File sourceFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) );
File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( pomArtifact ) );
File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) );
File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) );
assertTrue( "Check target file exists", targetFile.exists() );
assertTrue( "Check target POM exists", targetPomFile.exists() );
sourceFile.setLastModified( System.currentTimeMillis() );
sourcePomFile.setLastModified( System.currentTimeMillis() );
long origTime = targetFile.lastModified();
long origPomTime = targetPomFile.lastModified();
// Need to guarantee last modified is not equal
Thread.sleep( SLEEP_MILLIS );
artifactConverter.convert( artifact, targetRepository );
checkWarnings( artifactConverter, 2 );
assertHasWarningReason( artifactConverter, Messages.getString( "failure.target.already.exists" ) );
assertEquals( "Check unmodified", origTime, targetFile.lastModified() );
assertEquals( "Check unmodified", origPomTime, targetPomFile.lastModified() );
ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact );
File metadataFile =
new File( targetRepository.getBasedir(), targetRepository.pathOfRemoteRepositoryMetadata( metadata ) );
assertFalse( "Check metadata not created", metadataFile.exists() );
}