本文整理汇总了Java中org.apache.maven.artifact.repository.ArtifactRepositoryPolicy类的典型用法代码示例。如果您正苦于以下问题:Java ArtifactRepositoryPolicy类的具体用法?Java ArtifactRepositoryPolicy怎么用?Java ArtifactRepositoryPolicy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArtifactRepositoryPolicy类属于org.apache.maven.artifact.repository包,在下文中一共展示了ArtifactRepositoryPolicy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLocalRepository
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
private ArtifactRepository createLocalRepository(MavenEmbedderSettings generalSettings) {
ArtifactRepositoryLayout layout = getComponent(ArtifactRepositoryLayout.class, "default");
ArtifactRepositoryFactory factory = getComponent(ArtifactRepositoryFactory.class);
String url = mySettings.getLocalRepository();
if (!url.startsWith("file:")) url = "file://" + url;
ArtifactRepository localRepository = new DefaultArtifactRepository("local", url, layout);
boolean snapshotPolicySet = mySettings.isOffline();
if (!snapshotPolicySet && generalSettings.getSnapshotUpdatePolicy() == MavenEmbedderSettings.UpdatePolicy.ALWAYS_UPDATE) {
factory.setGlobalUpdatePolicy(ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS);
}
factory.setGlobalChecksumPolicy(ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN);
return localRepository;
}
示例2: provideLocalRepository
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
/**
* maven-plugin-testing-harness can not inject local repositories (though the real runtime supports it).
* and the default stubs have no sufficient implementation of getPath():
* @see "http://maven.apache.org/plugin-testing/maven-plugin-testing-harness/examples/repositories.html"
*/
private ArtifactRepository provideLocalRepository() throws IllegalAccessException
{
DefaultArtifactRepositoryFactory factory = new DefaultArtifactRepositoryFactory();
setVariableValueToObject(factory, "factory", new org.apache.maven.repository.legacy.repository.DefaultArtifactRepositoryFactory());
LegacySupport legacySupport = new DefaultLegacySupport();
setVariableValueToObject(factory, "legacySupport", legacySupport);
ArtifactRepository localRepository = factory.createArtifactRepository("local", "http://localhost",
new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy());
setVariableValueToObject(localRepository, "basedir", LOCAL_REPOSITORY);
return localRepository;
}
示例3: testFindArtifactInRepository
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
@Test
public void testFindArtifactInRepository() throws MojoExecutionException {
GenerateMojo mojo = new GenerateMojo();
mojo.setLog(new SystemStreamLog());
Dependency dependency = mojo.findArtifactInRepository(
new DefaultArtifact("org.spigotmc", "spigot-api", "1.8-R0.1-SNAPSHOT",
"compile", "jar", "jar", new DefaultArtifactHandler()),
new MavenArtifactRepository("yawkat",
"http://mvn.yawk.at",
new DefaultRepositoryLayout(),
new ArtifactRepositoryPolicy(),
new ArtifactRepositoryPolicy())
);
Assert.assertNotNull(dependency);
}
示例4: setUpProject
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
private void setUpProject( File pomFile, AbstractMojo mojo )
throws Exception
{
MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
ArtifactRepositoryFactory artifactRepositoryFactory =
(ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( true, "never", "never" );
String localRepoUrl = "file://" + System.getProperty( "user.home" ) + "/.m2/repository";
ArtifactRepository localRepository =
artifactRepositoryFactory.createArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout(),
policy, policy );
ProfileManager profileManager = new DefaultProfileManager( getContainer() );
MavenProject project = projectBuilder.buildWithDependencies( pomFile, localRepository, profileManager );
//this gets the classes for these tests of this mojo (exec plugin) onto the project classpath for the test
project.getBuild().setOutputDirectory( new File( "target/test-classes" ).getAbsolutePath() );
setVariableValueToObject( mojo, "project", project );
}
示例5: parseRepository
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
private ArtifactRepository parseRepository(String repo, ArtifactRepositoryPolicy policy) throws MojoFailureException {
// if it's a simple url
String id = null;
ArtifactRepositoryLayout layout = getLayout("default");
String url = repo;
// if it's an extended repo URL of the form id::layout::url
if (repo.contains("::")) {
Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher(repo);
if (!matcher.matches()) {
throw new MojoFailureException(repo, "Invalid syntax for repository: " + repo,
"Invalid syntax for repository. Use \"id::layout::url\" or \"URL\".");
}
id = matcher.group(1).trim();
if (!StringUtils.isEmpty(matcher.group(2))) {
layout = getLayout(matcher.group(2).trim());
}
url = matcher.group(3).trim();
}
return artifactRepositoryFactory.createArtifactRepository(id, url, layout, policy, policy);
}
示例6: convertFromMavenSettingsRepository
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
public static ArtifactRepository convertFromMavenSettingsRepository(Repository repository)
{
MavenArtifactRepository result = new MavenArtifactRepository();
result.setId(repository.getId());
result.setUrl(repository.getUrl());
String layout = repository.getLayout();
if ("default".equals(layout))
result.setLayout(new DefaultRepositoryLayout());
else if ("p2".equals(layout))
result.setLayout(new P2ArtifactRepositoryLayout());
RepositoryPolicy releases = repository.getReleases();
if (releases != null)
result.setReleaseUpdatePolicy(new ArtifactRepositoryPolicy(releases.isEnabled(), releases.getUpdatePolicy(),
releases.getChecksumPolicy()));
RepositoryPolicy snapshots = repository.getSnapshots();
if (snapshots != null)
result.setSnapshotUpdatePolicy(new ArtifactRepositoryPolicy(snapshots.isEnabled(),
snapshots.getUpdatePolicy(),
snapshots.getChecksumPolicy()));
return result;
}
示例7: toArtifactRepository
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
public static ArtifactRepository toArtifactRepository(String id, String url, String layout,
boolean containsReleases,
boolean containsSnapshots)
{
MavenArtifactRepository result = new MavenArtifactRepository();
result.setId(id);
result.setUrl(url);
if (layout == null || layout.isEmpty() || "default".equals(layout))
{
result.setLayout(new DefaultRepositoryLayout());
}
else if ("p2".equals(layout))
{
result.setLayout(new P2ArtifactRepositoryLayout());
}
result.setReleaseUpdatePolicy(new ArtifactRepositoryPolicy(containsReleases,
ArtifactRepositoryPolicy.UPDATE_POLICY_NEVER,
ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN));
result.setSnapshotUpdatePolicy(new ArtifactRepositoryPolicy(containsSnapshots,
ArtifactRepositoryPolicy.UPDATE_POLICY_DAILY,
ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN));
return result;
}
示例8: buildArtifactRepositoryPolicy
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
public ArtifactRepositoryPolicy buildArtifactRepositoryPolicy( RepositoryPolicy policy )
{
boolean enabled = true;
String updatePolicy = null;
String checksumPolicy = null;
if ( policy != null )
{
enabled = policy.isEnabled();
if ( policy.getUpdatePolicy() != null )
{
updatePolicy = policy.getUpdatePolicy();
}
if ( policy.getChecksumPolicy() != null )
{
checksumPolicy = policy.getChecksumPolicy();
}
}
return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy );
}
示例9: createArtifactRepository
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
public ArtifactRepository createArtifactRepository( String repositoryId, String url,
ArtifactRepositoryLayout repositoryLayout,
ArtifactRepositoryPolicy snapshots,
ArtifactRepositoryPolicy releases )
{
if ( repositoryLayout == null )
{
repositoryLayout = layouts.get( "default" );
}
ArtifactRepository artifactRepository =
artifactRepositoryFactory.createArtifactRepository( repositoryId, url, repositoryLayout, snapshots,
releases );
return artifactRepository;
}
示例10: getPolicy
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
public ArtifactRepositoryPolicy getPolicy( ArtifactRepository repository )
{
int nature = getNature();
if ( ( nature & RepositoryMetadata.RELEASE_OR_SNAPSHOT ) == RepositoryMetadata.RELEASE_OR_SNAPSHOT )
{
ArtifactRepositoryPolicy policy = new ArtifactRepositoryPolicy( repository.getReleases() );
policy.merge( repository.getSnapshots() );
return policy;
}
else if ( ( nature & RepositoryMetadata.SNAPSHOT ) != 0 )
{
return repository.getSnapshots();
}
else
{
return repository.getReleases();
}
}
示例11: buildRemoteRepository
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
private RemoteRepository buildRemoteRepository(final String id, final String url, final Authentication auth,
final ArtifactRepositoryPolicy releasesPolicy, final ArtifactRepositoryPolicy snapshotsPolicy) {
RemoteRepository.Builder builder = new RemoteRepository.Builder(id, "default", url);
if (auth != null
&& auth.getUsername() != null
&& auth.getPassword() != null) {
builder.setAuthentication(new AuthenticationBuilder()
.addUsername(auth.getUsername())
.addPassword(auth.getPassword()).build());
}
builder.setSnapshotPolicy(new RepositoryPolicy(snapshotsPolicy.isEnabled(), snapshotsPolicy.getUpdatePolicy(), snapshotsPolicy.getChecksumPolicy()));
builder.setReleasePolicy(new RepositoryPolicy(releasesPolicy.isEnabled(), releasesPolicy.getUpdatePolicy(), releasesPolicy.getChecksumPolicy()));
RemoteRepository repository = builder.build();
final RemoteRepository mirror = session.getMirrorSelector().getMirror(repository);
if (mirror != null) {
final org.eclipse.aether.repository.Authentication mirrorAuth = session.getAuthenticationSelector()
.getAuthentication(mirror);
RemoteRepository.Builder mirrorBuilder = new RemoteRepository.Builder(mirror)
.setId(repository.getId())
.setSnapshotPolicy(new RepositoryPolicy(snapshotsPolicy.isEnabled(), snapshotsPolicy.getUpdatePolicy(), snapshotsPolicy.getChecksumPolicy()))
.setReleasePolicy(new RepositoryPolicy(releasesPolicy.isEnabled(), releasesPolicy.getUpdatePolicy(), releasesPolicy.getChecksumPolicy()));
if (mirrorAuth != null) {
mirrorBuilder.setAuthentication(mirrorAuth);
}
repository = mirrorBuilder.build();
}
Proxy proxy = session.getProxySelector().getProxy(repository);
if (proxy != null) {
repository = new RemoteRepository.Builder(repository).setProxy(proxy).build();
}
return repository;
}
示例12: propagateRepositoryPolicies
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
@Test
// SWARM-1173: swarm-plugin trying to download SNAPSHOTs from Maven Central
public void propagateRepositoryPolicies() {
RepositorySystemSession sessionMock = Mockito.mock(RepositorySystemSession.class);
MirrorSelector mirrorSelectorMock = Mockito.mock(MirrorSelector.class);
Mockito.when(sessionMock.getMirrorSelector()).thenReturn(mirrorSelectorMock);
ProxySelector proxySelectorMock = Mockito.mock(ProxySelector.class);
Mockito.when(sessionMock.getProxySelector()).thenReturn(proxySelectorMock);
MavenArtifactResolvingHelper artifactResolverHelper = new MavenArtifactResolvingHelper(null, null, sessionMock, null);
ArtifactRepositoryPolicy testSnapshotPolicy = new ArtifactRepositoryPolicy(false, "hourly", "warn");
ArtifactRepositoryPolicy testReleasesPolicy = new ArtifactRepositoryPolicy(true, "never", "warn");
ArtifactRepository testingRepo = new MavenArtifactRepository("testing-repo", "http://testing-repo.org", new DefaultRepositoryLayout(), testSnapshotPolicy, testReleasesPolicy);
artifactResolverHelper.remoteRepository(testingRepo);
List<RemoteRepository> remoteRepos = artifactResolverHelper.getRemoteRepositories();
Assert.assertTrue("Remote repositories " + remoteRepos + " do not contain expected testing repo " + testingRepo,
remoteRepos.stream().anyMatch(
remoteRepo -> {
RepositoryPolicy snapshotsPolicy = remoteRepo.getPolicy(true);
RepositoryPolicy releasesPolicy = remoteRepo.getPolicy(false);
return remoteRepo.getId().equals(testingRepo.getId()) &&
!snapshotsPolicy.isEnabled() &&
snapshotsPolicy.getUpdatePolicy().equals(testSnapshotPolicy.getUpdatePolicy()) &&
snapshotsPolicy.getChecksumPolicy().equals(testSnapshotPolicy.getChecksumPolicy()) &&
releasesPolicy.isEnabled() &&
releasesPolicy.getUpdatePolicy().equals(testReleasesPolicy.getUpdatePolicy()) &&
releasesPolicy.getChecksumPolicy().equals(testReleasesPolicy.getChecksumPolicy());
})
);
}
示例13: repo
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
private ArtifactRepository repo(String id, String url, boolean releases,
boolean snapshots) {
MavenArtifactRepository repository = new MavenArtifactRepository();
repository.setLayout(new DefaultRepositoryLayout());
repository.setId(id);
repository.setUrl(url);
ArtifactRepositoryPolicy enabled = new ArtifactRepositoryPolicy();
enabled.setEnabled(true);
ArtifactRepositoryPolicy disabled = new ArtifactRepositoryPolicy();
disabled.setEnabled(false);
repository.setReleaseUpdatePolicy(releases ? enabled : disabled);
repository.setSnapshotUpdatePolicy(snapshots ? enabled : disabled);
return repository;
}
示例14: setupSession
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
private VersioningState setupSession( final Properties properties, final Map<ProjectRef, String[]> versionMap )
throws Exception
{
final ArtifactRepository ar =
new MavenArtifactRepository( "test", "http://repo.maven.apache.org/maven2", new DefaultRepositoryLayout(),
new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy() );
final MavenExecutionRequest req =
new DefaultMavenExecutionRequest().setUserProperties( properties )
.setRemoteRepositories( Arrays.asList( ar ) );
final PlexusContainer container = new DefaultPlexusContainer();
final MavenSession mavenSession = new MavenSession( container, null, req, new DefaultMavenExecutionResult() );
session = new ManipulationSession();
session.setMavenSession( mavenSession );
final VersioningState state = new VersioningState( properties );
session.setState( state );
final Map<String, byte[]> dataMap = new HashMap<>();
if ( versionMap != null && !versionMap.isEmpty() )
{
for ( final Map.Entry<ProjectRef, String[]> entry : versionMap.entrySet() )
{
final String path = toMetadataPath( entry.getKey() );
final byte[] data = setupMetadataVersions( entry.getValue() );
dataMap.put( path, data );
}
}
final Location mdLoc = MavenLocationExpander.EXPANSION_TARGET;
final Transport mdTrans = new StubTransport( dataMap );
modder =
new TestVersionCalculator( new ManipulationSession(), mdLoc, mdTrans, temp.newFolder( "galley-cache" ) );
return state;
}
示例15: convertPolicy
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; //导入依赖的package包/类
private ArtifactRepositoryPolicy convertPolicy( final RepositoryPolicy policy )
{
if ( policy == null )
{
return new ArtifactRepositoryPolicy();
}
return new ArtifactRepositoryPolicy( policy.isEnabled(), policy.getUpdatePolicy(), policy.getChecksumPolicy() );
}