本文整理匯總了Java中org.apache.maven.artifact.repository.ArtifactRepository類的典型用法代碼示例。如果您正苦於以下問題:Java ArtifactRepository類的具體用法?Java ArtifactRepository怎麽用?Java ArtifactRepository使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ArtifactRepository類屬於org.apache.maven.artifact.repository包,在下文中一共展示了ArtifactRepository類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addBndSnapshotRepo
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
private void addBndSnapshotRepo(MavenProject project) {
ArtifactRepository ar = new MavenArtifactRepository();
ar.setId("bnd-snapshots");
ar.setUrl("https://bndtools.ci.cloudbees.com/job/bnd.master/lastSuccessfulBuild/artifact/dist/bundles/");
ar.setLayout(defaultLayout);
List<ArtifactRepository> pluginRepos = new LinkedList<>();
pluginRepos.addAll(project.getPluginArtifactRepositories());
pluginRepos.add(ar);
project.setPluginArtifactRepositories(pluginRepos);
List<ArtifactRepository> repos = new LinkedList<>();
repos.addAll(project.getRemoteArtifactRepositories());
repos.add(ar);
project.setRemoteArtifactRepositories(repos);
}
示例2: readMavenProject
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
private static MavenProject readMavenProject(MavenEmbedder embedder, Artifact artifact, List<ArtifactRepository> remoteRepos) throws ProjectBuildingException {
ProjectBuilder bldr = embedder.lookupComponent(ProjectBuilder.class);
assert bldr !=null : "ProjectBuilder component not found in maven";
DefaultMaven maven = (DefaultMaven) embedder.lookupComponent(Maven.class);
assert bldr !=null : "DefaultMaven component not found in maven";
MavenExecutionRequest req = embedder.createMavenExecutionRequest();
req.setLocalRepository(embedder.getLocalRepository());
req.setRemoteRepositories(remoteRepos);
ProjectBuildingRequest configuration = req.getProjectBuildingRequest();
configuration.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
configuration.setResolveDependencies(true);
configuration.setRepositorySession(maven.newRepositorySession(req));
ProjectBuildingResult projectBuildingResult = bldr.build(artifact, configuration);
return projectBuildingResult.getProject();
}
示例3: createDependencyTree
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
private static DependencyNode createDependencyTree(MavenProject project,
DependencyTreeBuilder dependencyTreeBuilder, ArtifactRepository localRepository,
ArtifactFactory artifactFactory, ArtifactMetadataSource artifactMetadataSource,
ArtifactCollector artifactCollector,
String scope) {
ArtifactFilter artifactFilter = createResolvingArtifactFilter(scope);
try {
// TODO: note that filter does not get applied due to MNG-3236
return dependencyTreeBuilder.buildDependencyTree(project,
localRepository, artifactFactory,
artifactMetadataSource, artifactFilter, artifactCollector);
} catch (DependencyTreeBuilderException exception) {
}
return null;
}
示例4: createArtifact
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
private static @NonNull Artifact createArtifact(@NonNull NBVersionInfo info, @NullAllowed String classifier) {
Artifact art;
MavenEmbedder online = EmbedderFactory.getOnlineEmbedder();
if (info.getClassifier() != null || classifier != null) {
art = online.createArtifactWithClassifier(info.getGroupId(),
info.getArtifactId(),
info.getVersion(),
info.getType() != null ? info.getType() : "jar", //NOI18N
classifier == null ? info.getClassifier() : classifier);
} else {
art = online.createArtifact(info.getGroupId(),
info.getArtifactId(),
info.getVersion(),
null,
info.getType() != null ? info.getType() : "jar"); //NOI18N
}
ArtifactRepository repo = online.getLocalRepository();
String localPath = repo.pathOf(art);
art.setFile(FileUtil.normalizeFile(new File(online.getLocalRepositoryFile(), localPath)));
return art;
}
示例5: addDependency
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
private void addDependency(Artifact art, List<ITypeLoader> deps) throws IOException {
if ("compile".equals(art.getScope())) {
ArtifactRepository localRepository = session.getLocalRepository();
File f = localRepository.find(art).getFile();
if (f != null) {
Path path = f.toPath();
if (!quiet) {
getLog().info("HuntBugs: +dep " + path);
}
if (Files.isRegularFile(path) && art.getType().equals("jar")) {
deps.add(new JarTypeLoader(new JarFile(path.toFile())));
} else if (Files.isDirectory(path)) {
deps.add(new ClasspathTypeLoader(path.toString()));
}
}
}
}
示例6: MavenEnvironment
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
public MavenEnvironment(MavenSession aMavenSession, BuildPluginManager aBuildPluginManager, Log aLog,
DependencyTreeBuilder aDependencyTreeBuilder, ArtifactRepository aLocalRepository,
SecDispatcher aSecurityDispatcher, MavenProjectBuilder aProjectBuilder,
LifecycleExecutor aLifecycleExecutor, ArtifactFactory aArtifactFactory,
ArtifactMetadataSource aArtifactMetadataSource, ArtifactCollector aArtifactCollector, RuntimeInformation aRuntimeInformation,
MojoExecution aExecution) {
mavenSession = aMavenSession;
buildPluginManager = aBuildPluginManager;
log = aLog;
dependencyTreeBuilder = aDependencyTreeBuilder;
localRepository = aLocalRepository;
securityDispatcher = aSecurityDispatcher;
projectBuilder = aProjectBuilder;
lifecycleExecutor = aLifecycleExecutor;
artifactFactory = aArtifactFactory;
artifactMetadataSource = aArtifactMetadataSource;
artifactCollector = aArtifactCollector;
runtimeInformation = aRuntimeInformation;
mojoExecution = aExecution;
}
示例7: ForkedRunner
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
ForkedRunner(final Log log, final int jmxPort, final String vmArgs, final List<String> testClasspathElements,
final List<String> stepImplementationArtifacts, final ArtifactResolver artifactResolver,
final ArtifactFactory artifactFactory, final ProjectBuilder projectBuilder,
final ArtifactRepository localRepository, final List<ArtifactRepository> remoteRepositories,
final ArtifactMetadataSource artifactMetadataSource) throws MojoExecutionException {
this.log = log;
this.jmxPort = jmxPort;
this.vmArgs = vmArgs;
this.testClasspathElements = testClasspathElements;
this.stepImplementationArtifacts = stepImplementationArtifacts;
this.artifactResolver = artifactResolver;
this.artifactFactory = artifactFactory;
this.projectBuilder = projectBuilder;
this.localRepository = localRepository;
this.remoteRepositories = remoteRepositories;
this.artifactMetadataSource = artifactMetadataSource;
this.substepsJmxClient = new SubstepsJMXClient();
this.substepsJmxClient.setNotificiationHandler(this);
this.consumer = startMBeanJVM();
initialiseClient();
}
示例8: addDetails
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
@Override
protected void addDetails(@Nonnull ExecutionEvent executionEvent, @Nonnull Xpp3Dom root) {
super.addDetails(executionEvent, root);
ArtifactRepository artifactRepository = executionEvent.getProject().getDistributionManagementArtifactRepository();
Xpp3Dom artifactRepositoryElt = new Xpp3Dom("artifactRepository");
root.addChild(artifactRepositoryElt);
if (artifactRepository == null) {
} else {
Xpp3Dom idElt = new Xpp3Dom("id");
idElt.setValue(artifactRepository.getId());
artifactRepositoryElt.addChild(idElt);
Xpp3Dom urlElt = new Xpp3Dom("url");
urlElt.setValue(artifactRepository.getUrl());
artifactRepositoryElt.addChild(urlElt);
}
}
示例9: getArtifact
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
@Override
public void getArtifact(Artifact artifact, ArtifactRepository repository) throws TransferFailedException, ResourceDoesNotExistException {
if (myInBatchResolve.get() == Boolean.TRUE) {
super.getArtifact(artifact, repository);
return;
}
if (!takeFromCache(artifact)) {
try {
super.getArtifact(artifact, repository);
}
catch (WagonException ignore) {
}
cache(artifact);
myUnresolvedCollector.collectAndSetResolved(artifact);
}
}
示例10: resolveTransitively
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
public ArtifactResolutionResult resolveTransitively( Set<Artifact> artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List<ResolutionListener> listeners,
List<ConflictResolver> conflictResolvers )
throws ArtifactResolutionException, ArtifactNotFoundException
{
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
.setArtifact( originatingArtifact )
.setResolveRoot( false )
// This is required by the surefire plugin
.setArtifactDependencies( artifacts )
.setManagedVersionMap( managedVersions )
.setLocalRepository( localRepository )
.setRemoteRepositories( remoteRepositories )
.setCollectionFilter( filter )
.setListeners( listeners );
injectSession2( request, legacySupport.getSession() );
return resolveWithExceptions( request );
}
示例11: createLocalRepository
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的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;
}
示例12: resolve
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
@Override
public void resolve(RepositoryMetadata metadata, List remoteRepositories, ArtifactRepository localRepository)
throws RepositoryMetadataResolutionException {
super.resolve(metadata, remoteRepositories, localRepository);
MavenWorkspaceMap map = myWorkspaceMap;
if (map == null) return;
Metadata data = metadata.getMetadata();
Versioning versioning = data.getVersioning();
if (versioning == null) {
data.setVersioning(versioning = new Versioning());
}
for (MavenId each : map.getAvailableIds()) {
if (each.equals(data.getGroupId(), data.getArtifactId())) {
versioning.addVersion(each.getVersion());
}
}
}
示例13: actionPerformed
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
@Messages({"# {0} - artifact ID", "DownloadAction_downloading=Downloading {0}"})
public @Override void actionPerformed(ActionEvent e) {
RP.post(new Runnable() {
public @Override void run() {
MavenEmbedder online = EmbedderFactory.getOnlineEmbedder();
AggregateProgressHandle hndl = AggregateProgressFactory.createHandle(DownloadAction_downloading(art.getId()),
new ProgressContributor[] {AggregateProgressFactory.createProgressContributor("")},
ProgressTransferListener.cancellable(), null);
ProgressTransferListener.setAggregateHandle(hndl);
try {
hndl.start();
//mkleint: XXX theoretically using info from RepositoryPreferences.getRepositoryInfos() here could cause problems as the
// maven embedder code might want to retry applying mirrors on it.
online.resolve(art, Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(info.getRepositoryUrl(), info.getId())), online.getLocalRepository());
} catch (ThreadDeath d) {
return;
} catch (IllegalStateException ise) { //download interrupted in dependent thread. #213812
if (!(ise.getCause() instanceof ThreadDeath)) {
throw ise;
}
return;
} catch (AbstractArtifactResolutionException x) {
return;
} finally {
hndl.finish();
ProgressTransferListener.clearAggregateHandle();
}
if (!primary) {
return;
}
RepositoryIndexer.updateIndexWithArtifacts(RepositoryPreferences.getInstance().getLocalRepository(), Collections.singletonList(art));
setLocalArtifact(findLocalArtifact(info, record));
setChildren(createChildren(localArtifact));
}
});
}
示例14: resolveArtifacts
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
/**
* resolve the artifacts associated with the archetype (ideally downloads them to the local repository)
* @param hndl
* @throws ArtifactResolutionException
* @throws ArtifactNotFoundException
*/
public void resolveArtifacts(AggregateProgressHandle hndl) throws ArtifactResolutionException, ArtifactNotFoundException {
MavenEmbedder online = EmbedderFactory.getOnlineEmbedder();
List<ArtifactRepository> repos;
if (getRepository() == null) {
repos = Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(RepositorySystem.DEFAULT_REMOTE_REPO_URL, RepositorySystem.DEFAULT_REMOTE_REPO_ID));
} else {
repos = Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(getRepository(), "custom-repo"));//NOI18N
for (RepositoryInfo info : RepositoryPreferences.getInstance().getRepositoryInfos()) {
if (getRepository().equals(info.getRepositoryUrl())) {
repos = Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(getRepository(), info.getId()));//NOI18N
break;
}
}
}
try {
ProgressTransferListener.setAggregateHandle(hndl);
hndl.start();
//TODO how to rewrite to track progress?
// try {
// WagonManager wagon = online.getPlexusContainer().lookup(WagonManager.class);
// wagon.setDownloadMonitor(new ProgressTransferListener());
// } catch (ComponentLookupException ex) {
// Exceptions.printStackTrace(ex);
// }
online.resolve(getPomArtifact(), repos, online.getLocalRepository());
online.resolve(getArtifact(), repos, online.getLocalRepository());
} catch (ThreadDeath d) { // download interrupted
} catch (IllegalStateException ise) { //download interrupted in dependent thread. #213812
if (!(ise.getCause() instanceof ThreadDeath)) {
throw ise;
}
} finally {
ProgressTransferListener.clearAggregateHandle();
hndl.finish();
}
}
示例15: loadMavenProject
import org.apache.maven.artifact.repository.ArtifactRepository; //導入依賴的package包/類
private MavenProject loadMavenProject(File pom, String groupId, String artifactId, String version) {
MavenEmbedder embedder = EmbedderFactory.getProjectEmbedder();
Artifact projectArtifact = embedder.createArtifact(groupId, artifactId, version, "jar");
try {
ProjectBuildingRequest dpbr = embedder.createMavenExecutionRequest().getProjectBuildingRequest();
dpbr.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
dpbr.setProcessPlugins(false);
dpbr.setResolveDependencies(true);
ArrayList<ArtifactRepository> remoteRepos = new ArrayList<ArtifactRepository>();
//for project embedder doens't matter
// remoteRepos = RepositoryPreferences.getInstance().remoteRepositories();
dpbr.setRemoteRepositories(remoteRepos);
ProjectBuildingResult res = embedder.buildProject(projectArtifact, dpbr);
if (res.getProject() != null) {
return res.getProject();
} else {
LOG.log(Level.INFO, "No project model from repository for {0}: {1}", new Object[] {projectArtifact, res.getProblems()});
}
} catch (ProjectBuildingException ex) {
LOG.log(Level.FINER, "Failed to load project model from repository for {0}: {1}", new Object[] {projectArtifact, ex});
} catch (Exception exception) {
LOG.log(Level.FINER, "Failed to load project model from repository for " + projectArtifact, exception);
}
return null;
}