Java Code Examples for org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor#newCallerInstance()
The following examples show how to use
org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor#newCallerInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResolveEngine.java From ant-ivy with Apache License 2.0 | 6 votes |
public ResolvedModuleRevision findModule(ModuleRevisionId id, ResolveOptions options) { DependencyResolver r = settings.getResolver(id); if (r == null) { throw new IllegalStateException("no resolver found for " + id.getModuleId()); } DefaultModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(id, new String[] {"*"}, false, false); if (options.getResolveId() == null) { options.setResolveId(ResolveOptions.getDefaultResolveId(md)); } try { return r.getDependency(new DefaultDependencyDescriptor(id, true), new ResolveData(this, options, new ConfigurationResolveReport(this, md, "default", null, options))); } catch (ParseException e) { throw new RuntimeException("problem while parsing repository module descriptor for " + id + ": " + e, e); } }
Example 2
Source File: ResolveEngine.java From ant-ivy with Apache License 2.0 | 5 votes |
/** * Resolves the module identified by the given mrid with its dependencies if transitive is set * to true. * * @param mrid ModuleRevisionId * @param options ResolveOptions * @param changing boolean * @return ResolveReport * @throws ParseException if something goes wrong * @throws IOException if something goes wrong */ public ResolveReport resolve(final ModuleRevisionId mrid, ResolveOptions options, boolean changing) throws ParseException, IOException { DefaultModuleDescriptor md; ResolveOptions optionsToUse = new ResolveOptions(options); if (options.useSpecialConfs()) { // create new resolve options because this is a different resolve than the real resolve // (which will be a resolve of a newCallerInstance module) ResolvedModuleRevision rmr = findModule(mrid, new ResolveOptions(options)); if (rmr == null) { Message.verbose("module not found " + mrid); // we will continue the resolve anyway to get a nice error message back // to the user, however reduce the amount of logging in this case optionsToUse.setLog(LogOptions.LOG_DOWNLOAD_ONLY); md = DefaultModuleDescriptor.newCallerInstance(mrid, new String[] {"default"}, options.isTransitive(), changing); } else { String[] confs = options.getConfs(rmr.getDescriptor()); md = DefaultModuleDescriptor.newCallerInstance( ModuleRevisionId.newInstance(mrid, rmr.getId().getRevision()), confs, options.isTransitive(), changing); } } else { md = DefaultModuleDescriptor.newCallerInstance(mrid, options.getConfs(), options.isTransitive(), changing); } return resolve(md, optionsToUse); }
Example 3
Source File: MavenResolver.java From IJava with MIT License | 4 votes |
public List<File> resolveMavenDependency(String canonical, Set<String> repos, int verbosity) throws IOException, ParseException { ChainResolver rootResolver = this.searchAllReposResolver(repos); Ivy ivy = this.createDefaultIvyInstance(verbosity); IvySettings settings = ivy.getSettings(); settings.addResolver(rootResolver); rootResolver.setCheckmodified(true); settings.setDefaultResolver(rootResolver.getName()); ivy.getLoggerEngine().info("Searching for dependencies in: " + rootResolver.getResolvers()); ResolveOptions resolveOptions = new ResolveOptions(); resolveOptions.setTransitive(true); resolveOptions.setDownload(true); ModuleRevisionId artifactIdentifier = MavenResolver.parseCanonicalArtifactName(canonical); DefaultModuleDescriptor containerModule = DefaultModuleDescriptor.newCallerInstance( artifactIdentifier, DEFAULT_RESOLVE_CONFS, true, // Transitive repos != null // Changing - the resolver will set this based on SNAPSHOT since they are all m2 compatible // but if `repos` is specified, we want to force a lookup. ); ResolveReport resolved = ivy.resolve(containerModule, resolveOptions); if (resolved.hasError()) { MessageLogger logger = ivy.getLoggerEngine(); Arrays.stream(resolved.getAllArtifactsReports()) .forEach(r -> { logger.error("download " + r.getDownloadStatus() + ": " + r.getArtifact() + " of " + r.getType()); if (r.getArtifactOrigin() == null) logger.error("\tCouldn't find artifact."); else logger.error("\tfrom: " + r.getArtifactOrigin()); }); // TODO better error... throw new RuntimeException("Error resolving '" + canonical + "'. " + resolved.getAllProblemMessages()); } return Arrays.stream(resolved.getAllArtifactsReports()) .filter(a -> JAR_TYPE.equalsIgnoreCase(a.getType())) .map(ArtifactDownloadReport::getLocalFile) .collect(Collectors.toList()); }
Example 4
Source File: IvyRepositoryReport.java From ant-ivy with Apache License 2.0 | 4 votes |
public void doExecute() throws BuildException { Ivy ivy = getIvyInstance(); IvySettings settings = ivy.getSettings(); if (xsl && xslFile == null) { throw new BuildException("xsl file is mandatory when using xsl generation"); } if (module == null && PatternMatcher.EXACT.equals(matcher)) { throw new BuildException("no module name provided for ivy repository graph task: " + "It can either be set explicitly via the attribute 'module' or " + "via 'ivy.module' property or a prior call to <resolve/>"); } else if (module == null && !PatternMatcher.EXACT.equals(matcher)) { module = PatternMatcher.ANY_EXPRESSION; } ModuleRevisionId moduleRevisionId = ModuleRevisionId.newInstance(organisation, module, revision); try { ModuleRevisionId criteria = (revision == null) || settings.getVersionMatcher().isDynamic(moduleRevisionId) ? new ModuleRevisionId(new ModuleId(organisation, module), branch, "*") : new ModuleRevisionId(new ModuleId(organisation, module), branch, revision); ModuleRevisionId[] mrids = ivy.listModules(criteria, settings.getMatcher(matcher)); // replace all found revisions with the original requested revision Set<ModuleRevisionId> modules = new HashSet<>(); for (ModuleRevisionId mrid : mrids) { modules.add(ModuleRevisionId.newInstance(mrid, revision)); } mrids = modules.toArray(new ModuleRevisionId[modules.size()]); ModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(mrids, true, false); String resolveId = ResolveOptions.getDefaultResolveId(md); ResolveReport report = ivy.resolve(md, new ResolveOptions().setResolveId(resolveId) .setValidate(doValidate(settings))); ResolutionCacheManager cacheMgr = getIvyInstance().getResolutionCacheManager(); new XmlReportOutputter().output(report, cacheMgr, new ResolveOptions()); if (graph) { gengraph(cacheMgr, md.getModuleRevisionId().getOrganisation(), md.getModuleRevisionId().getName()); } if (dot) { gendot(cacheMgr, md.getModuleRevisionId().getOrganisation(), md.getModuleRevisionId().getName()); } if (xml) { FileUtil.copy(cacheMgr.getConfigurationResolveReportInCache(resolveId, "default"), new File(getTodir(), outputname + ".xml"), null); } if (xsl) { genreport(cacheMgr, md.getModuleRevisionId().getOrganisation(), md.getModuleRevisionId().getName()); } } catch (Exception e) { throw new BuildException("impossible to generate graph for " + moduleRevisionId + ": " + e, e); } }