本文整理汇总了Java中org.eclipse.aether.DefaultRepositorySystemSession.setCache方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultRepositorySystemSession.setCache方法的具体用法?Java DefaultRepositorySystemSession.setCache怎么用?Java DefaultRepositorySystemSession.setCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.aether.DefaultRepositorySystemSession
的用法示例。
在下文中一共展示了DefaultRepositorySystemSession.setCache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupRepoSession
import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
public DefaultRepositorySystemSession setupRepoSession(final RepositorySystem repoSystem, final Settings settings)
{
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
session.setOffline(false);
Proxy activeProxy = settings.getActiveProxy();
if (activeProxy != null)
{
DefaultProxySelector dps = new DefaultProxySelector();
dps.add(convertFromMavenProxy(activeProxy), activeProxy.getNonProxyHosts());
session.setProxySelector(dps);
}
final DefaultMirrorSelector mirrorSelector = createMirrorSelector(settings);
final LazyAuthenticationSelector authSelector = createAuthSelector(settings, mirrorSelector);
session.setMirrorSelector(mirrorSelector);
session.setAuthenticationSelector(authSelector);
LocalRepository localRepo = new LocalRepository(new File(settings.getLocalRepository()));
session.setLocalRepositoryManager(repoSystem.newLocalRepositoryManager(session, localRepo));
session.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_IGNORE);
session.setCache(new DefaultRepositoryCache());
boolean cacheNotFoundArtifacts = true;
boolean cacheTransferErrors = true;
session.setResolutionErrorPolicy(new SimpleResolutionErrorPolicy(cacheNotFoundArtifacts, cacheTransferErrors));
session.setWorkspaceReader(new ClasspathWorkspaceReader());
if (Boolean.getBoolean("org.apache.maven.log_transfer"))
{
session.setTransferListener(new JULMavenTransferListener());
}
return session;
}
示例2: setupRepoSession
import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
public DefaultRepositorySystemSession setupRepoSession(final RepositorySystem repoSystem, final Settings settings)
{
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
session.setOffline(false);
Proxy activeProxy = settings.getActiveProxy();
if (activeProxy != null)
{
DefaultProxySelector dps = new DefaultProxySelector();
dps.add(convertFromMavenProxy(activeProxy), activeProxy.getNonProxyHosts());
session.setProxySelector(dps);
}
final DefaultMirrorSelector mirrorSelector = createMirrorSelector(settings);
final LazyAuthenticationSelector authSelector = createAuthSelector(settings, mirrorSelector);
session.setMirrorSelector(mirrorSelector);
session.setAuthenticationSelector(authSelector);
LocalRepository localRepo = new LocalRepository(new File(settings.getLocalRepository()));
session.setLocalRepositoryManager(repoSystem.newLocalRepositoryManager(session, localRepo));
session.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_IGNORE);
session.setCache(new DefaultRepositoryCache());
boolean cacheNotFoundArtifacts = true;
boolean cacheTransferErrors = true;
session.setResolutionErrorPolicy(new SimpleResolutionErrorPolicy(cacheNotFoundArtifacts, cacheTransferErrors));
session.setWorkspaceReader(new ClasspathWorkspaceReader());
session.setTransferListener(new LogTransferListener(System.out));
return session;
}
示例3: execute
import org.eclipse.aether.DefaultRepositorySystemSession; //导入方法依赖的package包/类
@Override
protected void execute(GitBranchType type, String gitBranch, String branchPattern) throws MojoExecutionException, MojoFailureException {
getLog().debug("update-stage-dependencies setting up Repository session...");
DefaultRepositorySystemSession reresolveSession = new DefaultRepositorySystemSession(session);
reresolveSession.setUpdatePolicy(org.eclipse.aether.repository.RepositoryPolicy.UPDATE_POLICY_ALWAYS);
reresolveSession.setCache(new DefaultRepositoryCache());
LocalRepositoryManager localRepositoryManager = reresolveSession.getLocalRepositoryManager();
getLog().debug("configuring stage as the remote repository for artifact resolution requests...");
List<RemoteRepository> stageRepo = Arrays.asList(getRepository(stageDeploymentRepository));
boolean itemsPurged = false;
try {
DependencyResolutionResult depencencyResult = dependenciesResolver.resolve(
new DefaultDependencyResolutionRequest(project, reresolveSession));
for (Dependency dependency : depencencyResult.getResolvedDependencies()) {
if (!dependency.getArtifact().isSnapshot()) {
// Find the artifact in the local repo, and if it came from the 'stageRepo', populate that info
// as the 'repository' on the artifact.
LocalArtifactResult localResult = localRepositoryManager.find(reresolveSession,
new LocalArtifactRequest(dependency.getArtifact(), stageRepo, null));
// If the result has a file... and the getRepository() matched the stage repo id...
if (localResult.getFile() != null && localResult.getRepository() != null) {
getLog().info("Purging: " + dependency + " from remote repository: " + localResult.getRepository() + ".");
File deleteTarget = new File(localRepositoryManager.getRepository().getBasedir(), localRepositoryManager.getPathForLocalArtifact(dependency.getArtifact()));
if (deleteTarget.isDirectory()) {
try {
FileUtils.deleteDirectory(deleteTarget);
} catch (IOException ioe) {
getLog().warn("Failed to purge stage artifact from local repository: " + deleteTarget, ioe);
}
} else if (!deleteTarget.delete()) {
getLog().warn("Failed to purge stage artifact from local repository: " + deleteTarget);
}
itemsPurged = true;
}
}
}
} catch (DependencyResolutionException dre) {
throw new MojoExecutionException("Initial dependency resolution to resolve dependencies which may have been provided by the 'stage' repository failed.", dre);
}
if (itemsPurged) {
try {
getLog().info("Resolving purged dependencies...");
dependenciesResolver.resolve(new DefaultDependencyResolutionRequest(project, reresolveSession));
getLog().info("All stage dependencies purged and re-resolved.");
} catch (DependencyResolutionException e) {
throw new MojoExecutionException("Post-purge dependency resolution failed!", e);
}
}
}