Java Code Examples for org.apache.ivy.core.resolve.ResolveOptions#getDefaultResolveId()
The following examples show how to use
org.apache.ivy.core.resolve.ResolveOptions#getDefaultResolveId() .
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: IvyRepositoryReport.java From ant-ivy with Apache License 2.0 | 6 votes |
private void genreport(ResolutionCacheManager cache, String organisation, String module) { // first process the report with xslt XSLTProcess xslt = new XSLTProcess(); xslt.setTaskName(getTaskName()); xslt.setProject(getProject()); xslt.init(); String resolveId = ResolveOptions.getDefaultResolveId(new ModuleId(organisation, module)); xslt.setIn(cache.getConfigurationResolveReportInCache(resolveId, "default")); xslt.setOut(new File(getTodir(), outputname + "." + xslext)); xslt.setStyle(xslFile); XSLTProcess.Param xslExt = xslt.createParam(); xslExt.setName("extension"); xslExt.setExpression(xslext); // add the provided XSLT parameters for (XSLTProcess.Param param : params) { XSLTProcess.Param realParam = xslt.createParam(); realParam.setName(param.getName()); realParam.setExpression(param.getExpression()); } xslt.execute(); }
Example 2
Source File: IvyArtifactProperty.java From ant-ivy with Apache License 2.0 | 6 votes |
public void doExecute() throws BuildException { prepareAndCheck(); try { ResolutionCacheManager cacheMgr = getIvyInstance().getResolutionCacheManager(); String resolveId = getResolveId(); if (resolveId == null) { resolveId = ResolveOptions.getDefaultResolveId(getResolvedModuleId()); } XmlReportParser parser = new XmlReportParser(); for (String conf : splitToArray(getConf())) { File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, conf); parser.parse(report); for (Artifact artifact : parser.getArtifacts()) { String name = IvyPatternHelper.substitute(getSettings().substitute(getName()), artifact, conf); String value = IvyPatternHelper.substitute( getSettings().substitute(getValue()), artifact, conf); setProperty(name, value); } } } catch (Exception ex) { throw new BuildException("impossible to add artifact properties: " + ex, ex); } }
Example 3
Source File: IvyRepositoryReport.java From ant-ivy with Apache License 2.0 | 5 votes |
private void gen(ResolutionCacheManager cache, String organisation, String module, String style, String ext) { XSLTProcess xslt = new XSLTProcess(); xslt.setTaskName(getTaskName()); xslt.setProject(getProject()); xslt.init(); String resolveId = ResolveOptions.getDefaultResolveId(new ModuleId(organisation, module)); xslt.setIn(cache.getConfigurationResolveReportInCache(resolveId, "default")); xslt.setOut(new File(getTodir(), outputname + "." + ext)); xslt.setBasedir(cache.getResolutionCacheRoot()); xslt.setStyle(style); xslt.execute(); }
Example 4
Source File: Main.java From ant-ivy with Apache License 2.0 | 5 votes |
private static void outputCachePath(Ivy ivy, File cache, ModuleDescriptor md, String[] confs, String outFile) { try { StringBuilder buf = new StringBuilder(); Collection<ArtifactDownloadReport> all = new LinkedHashSet<>(); ResolutionCacheManager cacheMgr = ivy.getResolutionCacheManager(); XmlReportParser parser = new XmlReportParser(); for (String conf : confs) { String resolveId = ResolveOptions.getDefaultResolveId(md); File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, conf); parser.parse(report); all.addAll(Arrays.asList(parser.getArtifactReports())); } for (ArtifactDownloadReport artifact : all) { if (artifact.getLocalFile() != null) { buf.append(artifact.getLocalFile().getCanonicalPath()); buf.append(File.pathSeparator); } } PrintWriter writer = new PrintWriter(new FileOutputStream(outFile)); if (buf.length() > 0) { buf.setLength(buf.length() - File.pathSeparator.length()); writer.println(buf); } writer.close(); System.out.println("cachepath output to " + outFile); } catch (Exception ex) { throw new RuntimeException("impossible to build ivy cache path: " + ex.getMessage(), ex); } }
Example 5
Source File: IvyPostResolveTask.java From ant-ivy with Apache License 2.0 | 4 votes |
private String[] getConfsToResolve(ModuleDescriptor reference, String conf, String[] rconfs) { Message.debug("calculating configurations to resolve"); if (reference == null) { Message.debug("module not yet resolved, all confs still need to be resolved"); if (conf == null) { return new String[] {"*"}; } return splitToArray(conf); } if (conf == null) { Message.debug("module already resolved, no configuration to resolve"); return new String[0]; } String[] confs; if ("*".equals(conf)) { confs = reference.getConfigurationsNames(); } else { confs = splitToArray(conf); } Set<String> rconfsSet = new HashSet<>(); // for each resolved configuration, check if the report still exists ResolutionCacheManager cache = getSettings().getResolutionCacheManager(); for (String resolvedConf : rconfs) { String resolveId = getResolveId(); if (resolveId == null) { resolveId = ResolveOptions.getDefaultResolveId(reference); } File report = cache.getConfigurationResolveReportInCache(resolveId, resolvedConf); // if the report does not exist any longer, we have to recreate it... if (report.exists()) { rconfsSet.add(resolvedConf); } } Set<String> confsSet = new HashSet<>(Arrays.asList(confs)); Message.debug("resolved configurations: " + rconfsSet); Message.debug("asked configurations: " + confsSet); confsSet.removeAll(rconfsSet); Message.debug("to resolve configurations: " + confsSet); return confsSet.toArray(new String[confsSet.size()]); }
Example 6
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); } }
Example 7
Source File: IvyReport.java From ant-ivy with Apache License 2.0 | 4 votes |
public void doExecute() throws BuildException { Ivy ivy = getIvyInstance(); IvySettings settings = ivy.getSettings(); conf = getProperty(conf, settings, "ivy.resolved.configurations", resolveId); if ("*".equals(conf)) { conf = getProperty(settings, "ivy.resolved.configurations", resolveId); } if (conf == null) { throw new BuildException("no conf provided for ivy report task: " + "It can either be set explicitly via the attribute 'conf' or " + "via 'ivy.resolved.configurations' property or a prior call to <resolve/>"); } if (todir == null) { String t = getProperty(settings, "ivy.report.todir"); if (t != null) { todir = getProject().resolveFile(t); } } if (todir != null && todir.exists()) { todir.mkdirs(); } outputpattern = getProperty(outputpattern, settings, "ivy.report.output.pattern"); if (outputpattern == null) { outputpattern = "[organisation]-[module]-[conf].[ext]"; } if (todir != null && todir.exists() && !todir.isDirectory()) { throw new BuildException("destination directory should be a directory !"); } if (resolveId == null) { organisation = getProperty(organisation, settings, "ivy.organisation", resolveId); module = getProperty(module, settings, "ivy.module", resolveId); if (organisation == null) { throw new BuildException("no organisation provided for ivy report task: " + "It can either be set explicitly via the attribute 'organisation' or " + "via 'ivy.organisation' property or a prior call to <resolve/>"); } if (module == null) { throw new BuildException("no module name provided for ivy report task: " + "It can either be set explicitly via the attribute 'module' or " + "via 'ivy.module' property or a prior call to <resolve/>"); } resolveId = ResolveOptions.getDefaultResolveId(new ModuleId(organisation, module)); } try { String[] confs = splitToArray(conf); if (xsl) { genreport(confs); } if (xml) { genxml(confs); } if (graph) { genStyled(confs, getStylePath("ivy-report-graph.xsl"), "graphml"); } if (dot) { genStyled(confs, getStylePath("ivy-report-dot.xsl"), "dot"); } } catch (IOException e) { throw new BuildException("impossible to generate report: " + e, e); } }
Example 8
Source File: ResolveReport.java From ant-ivy with Apache License 2.0 | 4 votes |
public ResolveReport(ModuleDescriptor md) { this(md, ResolveOptions.getDefaultResolveId(md)); }