本文整理汇总了Java中org.apache.maven.artifact.repository.metadata.Snapshot.setLocalCopy方法的典型用法代码示例。如果您正苦于以下问题:Java Snapshot.setLocalCopy方法的具体用法?Java Snapshot.setLocalCopy怎么用?Java Snapshot.setLocalCopy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.artifact.repository.metadata.Snapshot
的用法示例。
在下文中一共展示了Snapshot.setLocalCopy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMetadata
import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
private static Metadata createMetadata( Artifact artifact, boolean legacyFormat )
{
Snapshot snapshot = new Snapshot();
snapshot.setLocalCopy( true );
Versioning versioning = new Versioning();
versioning.setSnapshot( snapshot );
Metadata metadata = new Metadata();
metadata.setVersioning( versioning );
metadata.setGroupId( artifact.getGroupId() );
metadata.setArtifactId( artifact.getArtifactId() );
metadata.setVersion( artifact.getBaseVersion() );
if ( !legacyFormat )
{
metadata.setModelVersion( "1.1.0" );
}
return metadata;
}
示例2: transformForInstall
import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
public void transformForInstall( Artifact artifact, ArtifactRepository localRepository )
{
if ( artifact.isSnapshot() )
{
Snapshot snapshot = new Snapshot();
snapshot.setLocalCopy( true );
RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );
artifact.addMetadata( metadata );
}
}
示例3: generateMavenMetadata
import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
/**
* Generate the maven-metadata-local.xml for the given Maven <code>Artifact</code>.
*
* @param artifact the Maven <code>Artifact</code>.
* @param target the target maven-metadata-local.xml file to generate.
* @throws IOException if the maven-metadata-local.xml can't be generated.
*/
static void generateMavenMetadata(Artifact artifact, File target) throws IOException {
target.getParentFile().mkdirs();
Metadata metadata = new Metadata();
metadata.setGroupId(artifact.getGroupId());
metadata.setArtifactId(artifact.getArtifactId());
metadata.setVersion(artifact.getVersion());
metadata.setModelVersion("1.1.0");
Versioning versioning = new Versioning();
versioning.setLastUpdatedTimestamp(new Date(System.currentTimeMillis()));
Snapshot snapshot = new Snapshot();
snapshot.setLocalCopy(true);
versioning.setSnapshot(snapshot);
SnapshotVersion snapshotVersion = new SnapshotVersion();
snapshotVersion.setClassifier(artifact.getClassifier());
snapshotVersion.setVersion(artifact.getVersion());
snapshotVersion.setExtension(artifact.getType());
snapshotVersion.setUpdated(versioning.getLastUpdated());
versioning.addSnapshotVersion(snapshotVersion);
metadata.setVersioning(versioning);
MetadataXpp3Writer metadataWriter = new MetadataXpp3Writer();
Writer writer = new FileWriter(target);
metadataWriter.write(writer, metadata);
}
示例4: readVersions
import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
ArtifactRepository repository, VersionResult result )
{
Versioning versioning = null;
FileInputStream fis = null;
try
{
if ( metadata != null )
{
SyncContext syncContext = syncContextFactory.newInstance( session, true );
try
{
syncContext.acquire( null, Collections.singleton( metadata ) );
if ( metadata.getFile() != null && metadata.getFile().exists() )
{
fis = new FileInputStream( metadata.getFile() );
org.apache.maven.artifact.repository.metadata.Metadata m =
new MetadataXpp3Reader().read( fis, false );
versioning = m.getVersioning();
/*
* NOTE: Users occasionally misuse the id "local" for remote repos which screws up the metadata
* of the local repository. This is especially troublesome during snapshot resolution so we try
* to handle that gracefully.
*/
if ( versioning != null && repository instanceof LocalRepository)
{
if ( versioning.getSnapshot() != null && versioning.getSnapshot().getBuildNumber() > 0 )
{
Versioning repaired = new Versioning();
repaired.setLastUpdated( versioning.getLastUpdated() );
Snapshot snapshot = new Snapshot();
snapshot.setLocalCopy( true );
repaired.setSnapshot( snapshot );
versioning = repaired;
throw new IOException( "Snapshot information corrupted with remote repository data"
+ ", please verify that no remote repository uses the id '" + repository.getId()
+ "'" );
}
}
}
}
finally
{
syncContext.release();
}
}
}
catch ( Exception e )
{
invalidMetadata( session, trace, metadata, repository, e );
result.addException( e );
}
finally
{
IOUtil.close(fis);
}
return ( versioning != null ) ? versioning : new Versioning();
}
示例5: install
import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
public void install( File source, Artifact artifact, ArtifactRepository localRepository )
throws ArtifactInstallationException
{
RepositorySystemSession session =
LegacyLocalRepositoryManager.overlay( localRepository, legacySupport.getRepositorySession(), repoSystem );
InstallRequest request = new InstallRequest();
request.setTrace( DefaultRequestTrace.newChild( null, legacySupport.getSession().getCurrentProject() ) );
org.sonatype.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact );
mainArtifact = mainArtifact.setFile( source );
request.addArtifact( mainArtifact );
for ( ArtifactMetadata metadata : artifact.getMetadataList() )
{
if ( metadata instanceof ProjectArtifactMetadata )
{
org.sonatype.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" );
pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() );
request.addArtifact( pomArtifact );
}
else if ( metadata instanceof SnapshotArtifactRepositoryMetadata
|| metadata instanceof ArtifactRepositoryMetadata )
{
// eaten, handled by repo system
}
else
{
request.addMetadata( new MetadataBridge( metadata ) );
}
}
try
{
repoSystem.install( session, request );
}
catch ( InstallationException e )
{
throw new ArtifactInstallationException( e.getMessage(), e );
}
/*
* NOTE: Not used by Maven core, only here to provide backward-compat with plugins like the Install Plugin.
*/
if ( artifact.isSnapshot() )
{
Snapshot snapshot = new Snapshot();
snapshot.setLocalCopy( true );
artifact.addMetadata( new SnapshotArtifactRepositoryMetadata( artifact, snapshot ) );
}
Versioning versioning = new Versioning();
versioning.updateTimestamp();
versioning.addVersion( artifact.getBaseVersion() );
if ( artifact.isRelease() )
{
versioning.setRelease( artifact.getBaseVersion() );
}
artifact.addMetadata( new ArtifactRepositoryMetadata( artifact, versioning ) );
}
示例6: readVersions
import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
private Versioning readVersions( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
ArtifactRepository repository, VersionResult result )
{
Versioning versioning = null;
FileInputStream fis = null;
try
{
if ( metadata != null )
{
SyncContext syncContext = syncContextFactory.newInstance( session, true );
try
{
syncContext.acquire( null, Collections.singleton( metadata ) );
if ( metadata.getFile() != null && metadata.getFile().exists() )
{
fis = new FileInputStream( metadata.getFile() );
org.apache.maven.artifact.repository.metadata.Metadata m =
new MetadataXpp3Reader().read( fis, false );
versioning = m.getVersioning();
/*
* NOTE: Users occasionally misuse the id "local" for remote repos which screws up the metadata
* of the local repository. This is especially troublesome during snapshot resolution so we try
* to handle that gracefully.
*/
if ( versioning != null && repository instanceof LocalRepository )
{
if ( versioning.getSnapshot() != null && versioning.getSnapshot().getBuildNumber() > 0 )
{
Versioning repaired = new Versioning();
repaired.setLastUpdated( versioning.getLastUpdated() );
Snapshot snapshot = new Snapshot();
snapshot.setLocalCopy( true );
repaired.setSnapshot( snapshot );
versioning = repaired;
throw new IOException( "Snapshot information corrupted with remote repository data"
+ ", please verify that no remote repository uses the id '" + repository.getId()
+ "'" );
}
}
}
}
finally
{
syncContext.release();
}
}
}
catch ( Exception e )
{
invalidMetadata( session, trace, metadata, repository, e );
result.addException( e );
}
finally
{
IOUtil.close( fis );
}
return ( versioning != null ) ? versioning : new Versioning();
}