本文整理了Java中org.apache.ivy.Ivy
类的一些代码示例,展示了Ivy
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ivy
类的具体详情如下:
包路径:org.apache.ivy.Ivy
类名称:Ivy
[英][Ivy](http://ant.apache.org/ivy/) is a free java based dependency manager.
This class is the main class of Ivy, which acts as a Facade to all services offered by Ivy:
Ivy ivy = Ivy.newInstance();
ivy.configure(new URL("ivysettings.xml"));
ivy.resolve(new URL("ivy.xml"));
Using Ivy engines directly
If the methods offered by the Ivy class are not flexible enough and you want to use Ivy engines directly, you need to call the methods within a single IvyContext associated to the Ivy instance you use.
To do so, it is recommended to use the #execute(org.apache.ivy.Ivy.IvyCallback) method like this:
Ivy ivy = Ivy.newInstance();
ivy.execute(new IvyCallback() {
public Object doInIvyContext(Ivy ivy, IvyContext context) {
// obviously we can use regular Ivy methods in the callback
ivy.configure(new URL("ivysettings.xml"));
// and we can safely use Ivy engines too
ivy.getResolveEngine().resolve(new URL("ivy.xml"));
return null;
}
});
[中][Ivy](http://ant.apache.org/ivy/)是一个免费的基于java的依赖关系管理器。
该课程是常春藤的主要课程,作为常春藤提供的所有服务的门面:
*解决依赖关系
*将工件检索到本地位置
*交付和发布模块
*存储库搜索和列表
这里有一个典型用法:
Ivy ivy = Ivy.newInstance();
ivy.configure(new URL("ivysettings.xml"));
ivy.resolve(new URL("ivy.xml"));
直接使用常春藤发动机
如果Ivy类提供的方法不够灵活,并且希望直接使用Ivy引擎,则需要在与所使用的Ivy实例关联的单个IvyContext中调用这些方法。
为此,建议使用以下#execute(org.apache.ivy.ivy.IvyCallback)方法:
Ivy ivy = Ivy.newInstance();
ivy.execute(new IvyCallback() {
public Object doInIvyContext(Ivy ivy, IvyContext context) {
// obviously we can use regular Ivy methods in the callback
ivy.configure(new URL("ivysettings.xml"));
// and we can safely use Ivy engines too
ivy.getResolveEngine().resolve(new URL("ivy.xml"));
return null;
}
});
代码示例来源:origin: vipshop/Saturn
public IvyGetArtifact getIvyGetArtifact() throws ParseException, IOException {
File cacheDirectory = new File(ivyCache);// ivy下包缓存目录
if (!cacheDirectory.exists()) {
cacheDirectory.mkdirs();
}
URL settingsURL = MavenProjectUtils.class.getClassLoader().getResource("ivysettings.xml");
Ivy ivy = Ivy.newInstance();
ivy.getSettings().setDefaultCache(cacheDirectory);
ivy.getSettings().setVariable("ivy.local.default.root", localRepository);
ivy.getSettings().load(settingsURL);
return new IvyGetArtifact(logger, ivy);
}
代码示例来源:origin: vipshop/Saturn
public List<URL> get(String org, String name, String rev, String[] confs, Set<Map<String, Object>> artifacts)
throws IOException, ParseException {
Set<URL> artifactsGeted = new HashSet<URL>();
try {
ivy.getSettings().addAllVariables(System.getProperties());
ivy.pushContext();
File ivyfile = getIvyfile(org, name, rev, confs, artifacts);
String[] conf2 = new String[] { "default" };
ResolveOptions resolveOptions = new ResolveOptions().setConfs(conf2).setValidate(true).setResolveMode(null)
.setArtifactFilter(FilterHelper.getArtifactTypeFilter("jar,bundle,zip"));
ResolveReport report = ivy.resolve(ivyfile.toURI().toURL(), resolveOptions);
if (report.hasError()) {
List<?> problemMessages = report.getAllProblemMessages();
for (Object message : problemMessages) {
log.error(message.toString());
}
} else {
artifactsGeted.addAll(getCachePath(report.getModuleDescriptor(), conf2));
}
} catch (IOException e) {
throw e;
} catch (ParseException e) {
throw e;
} finally {
ivy.popContext();
}
List<URL> result = new ArrayList<URL>();
result.addAll(artifactsGeted);
return result;
}
代码示例来源:origin: vipshop/Saturn
private Set<URL> getCachePath(ModuleDescriptor md, String[] confs) throws ParseException, IOException {
Set<URL> fs = new HashSet<URL>();
StringBuffer buf = new StringBuffer();
Collection<ArtifactDownloadReport> all = new LinkedHashSet<ArtifactDownloadReport>();
ResolutionCacheManager cacheMgr = ivy.getResolutionCacheManager();
XmlReportParser parser = new XmlReportParser();
for (int i = 0; i < confs.length; i++) {
String resolveId = ResolveOptions.getDefaultResolveId(md);
File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, confs[i]);
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);
}
}
String[] fs_str = buf.toString().split(File.pathSeparator);
for (String str : fs_str) {
File file = new File(str);
if (file.exists()) {
fs.add(file.toURI().toURL());
}
}
return fs;
}
代码示例来源:origin: org.apache.ivy/ivy
public ResolveReport resolve(URL ivySource) throws ParseException, IOException {
return ivy.resolve(ivySource);
}
代码示例来源:origin: org.apache.ivy/ivy
System.out.println("Apache Ivy " + Ivy.getIvyVersion() + " - " + Ivy.getIvyDate()
+ " :: " + Ivy.getIvyHomeURL());
return;
Ivy ivy = Ivy.newInstance();
initMessage(line, ivy);
IvySettings settings = initSettings(line, ivy);
ivy.pushContext();
ivy.getSettings().useDeprecatedUseOrigin();
ResolveReport report = ivy.resolve(ivyfile.toURI().toURL(), resolveOptions);
if (report.hasError()) {
System.exit(1);
ivy.retrieve(
md.getModuleRevisionId(),
retrievePattern,
ivy.deliver(
md.getResolvedModuleRevisionId(),
settings.substitute(line.getOptionValue("revision")),
.setValidate(validate));
if (line.hasOption("publish")) {
ivy.publish(
md.getResolvedModuleRevisionId(),
Collections.singleton(settings.substitute(line.getOptionValue("publishpattern",
代码示例来源:origin: org.apache.ivy/ivy
public Ivy14() {
this(Ivy.newInstance());
}
代码示例来源:origin: fizzed/blaze
Ivy ivy = Ivy.newInstance();
IvySettings ivySettings = ivy.getSettings();
ivy.getResolutionCacheManager().clean();
ivy.getSettings().setDefaultResolver(chainResolver.getName());
ResolveReport report = ivy.resolve(md, resolveOptions);
代码示例来源:origin: net.sourceforge.scenarlang/UT_DSL_JAVA_UTL
public static void resolveDependencies() throws ParseException, IOException {
Ivy ivy = Ivy.newInstance(getIvySettings());
File dependencyFile = getIvyDependencyFile();
// resolve the dependencies - Ivy returns a report of the resolution
ResolveReport resolveReport = ivy.resolve(dependencyFile);
// check for errors (if any) during resolve
if (resolveReport.hasError()) {
System.err.println(getErrorString(resolveReport));
} else {
System.out.println("Dependencies in file " + dependencyFile + " were successfully resolved");
}
}
代码示例来源:origin: dkpro/dkpro-core
Ivy ivy = Ivy.newInstance(ivySettings);
report = ivy.resolve(md, options);
ivy.getResolutionCacheManager().getResolvedIvyFileInCache(moduleId).delete();
ivy.getResolutionCacheManager().getResolvedIvyPropertiesInCache(moduleId).delete();
ivy.getResolutionCacheManager().getConfigurationResolveReportInCache(resid, "default")
.delete();
代码示例来源:origin: org.apache.ivy/ivy
public ResolveReport resolve(File ivySource) throws ParseException, IOException {
pushContext();
try {
return resolveEngine.resolve(ivySource);
} finally {
popContext();
}
}
代码示例来源:origin: org.apache.ivy/ivy
protected IvySettings getSettings() {
return getIvyInstance().getSettings();
}
代码示例来源:origin: org.apache.ivy/ivy
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");
ModuleRevisionId[] mrids = ivy.listModules(criteria, settings.getMatcher(matcher));
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) {
代码示例来源:origin: com.google.code.maven-play-plugin.org.playframework/play
ivySettings.setDefaultConflictManager(conflictManager);
Ivy ivy = Ivy.newInstance(ivySettings);
File ivyDefaultSettings = new File(userHome, ".ivy2/ivysettings.xml");
if (ivyDefaultSettings != null && ivyDefaultSettings.exists()) {
ivy.configure(ivyDefaultSettings);
ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_DEBUG));
} else if (verbose) {
ivy.getLoggerEngine().pushLogger(new DefaultMessageLogger(Message.MSG_INFO));
} else {
ivy.getLoggerEngine().setDefaultLogger(this.logger);
ivy.pushContext();
代码示例来源:origin: org.apache.ivy/ivy
Ivy ivy = Ivy.newInstance(settings);
try {
ivy.pushContext();
AntMessageLogger.register(task, ivy);
throw new BuildException("settings file does not exist: " + file);
ivy.configure(file);
} else {
if (url == null) {
+ " and if not defineDefaultSettingFile must set it.");
ivy.configure(url);
+ (file != null ? "file: " + file : "url: " + url) + " : " + e, e);
} finally {
ivy.popContext();
代码示例来源:origin: org.apache.ivy/ivy
public ResolveReport resolve(ModuleRevisionId mrid, String[] confs) throws ParseException,
IOException {
return ivy.resolve(
mrid,
newResolveOptions(confs, null, ivy.getSettings().getDefaultCache(), null, true, false,
true, false, true, true, FilterHelper.NO_FILTER), false);
}
代码示例来源:origin: org.jenkins-ci.plugins/ivytrigger
ivySettings.setDefaultCache(getAndInitCacheDir(launchDir));
Ivy ivy = Ivy.newInstance(ivySettings);
ivy.getLoggerEngine().pushLogger(new IvyTriggerResolverLog(log, debug));
for (Map.Entry<String, String> entry : variables.entrySet()) {
ivy.setVariable(entry.getKey(), entry.getValue());
代码示例来源:origin: org.jvnet.hudson.plugins/ivy
Message.setDefaultLogger(new IvyMessageImpl());
IvyConfiguration ivyConf = getIvyConfiguration();
Ivy ivy = Ivy.newInstance();
Ivy configured = null;
if (ivyConf != null) {
try {
ivy.configure(new File(ivyConf.getIvyConfPath()));
LOGGER.fine("Configured Ivy using the Ivy settings " + ivyConf.getName());
configured = ivy;
ivy.configureDefault();
LOGGER.fine("Configured Ivy using default 2.0 settings");
configured = ivy;
代码示例来源:origin: org.apache.ivy/ivy
private Ivy getDefaultIvy() {
if (defaultIvy == null) {
defaultIvy = Ivy.newInstance();
try {
defaultIvy.configureDefault();
} catch (Exception e) {
Message.debug(e);
// ???
}
}
return defaultIvy;
}
代码示例来源:origin: io.restx/restx-core-shell
private void installDepsFromIvyDescriptor(RestxShell shell, File ivyFile) throws Exception {
Ivy ivy = ShellIvy.loadIvy(shell);
shell.println("resolving dependencies...");
ResolveReport resolveReport = ivy.resolve(ivyFile);
shell.println("synchronizing dependencies in " + shell.currentLocation().resolve("target/dependency") + " ...");
ivy.retrieve(resolveReport.getModuleDescriptor().getModuleRevisionId(),
new RetrieveOptions()
.setDestArtifactPattern(
shell.currentLocation().toAbsolutePath() + "/target/dependency/[artifact]-[revision](-[classifier]).[ext]")
.setSync(true)
);
}
代码示例来源:origin: org.apache.ivy/ivy
public void configure(File settingsFile) throws ParseException, IOException {
pushContext();
try {
assertBound();
settings.load(settingsFile);
postConfigure();
} finally {
popContext();
}
}
内容来源于网络,如有侵权,请联系作者删除!