use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.
the class WarnCircularDependencyStrategyTest method setResolveContext.
private void setResolveContext(String resolveId) {
IvySettings settings = new IvySettings();
IvyContext.getContext().setResolveData(new ResolveData(new ResolveEngine(settings, new EventManager(), new SortEngine(settings)), new ResolveOptions().setResolveId(resolveId)));
}
use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.
the class CheckEngine method check.
/**
* Checks the given ivy file using current settings to see if all dependencies are available,
* with good confs. If a resolver name is given, it also checks that the declared publications
* are available in the corresponding resolver. Note that the check is not performed
* recursively, i.e. if a dependency has itself dependencies badly described or not available,
* this check will not discover it.
*
* @param ivyFile URL
* @param resolvername String
* @return boolean
*/
public boolean check(URL ivyFile, String resolvername) {
try {
boolean result = true;
// parse ivy file
ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance().parseDescriptor(settings, ivyFile, settings.doValidate());
// check publications if possible
if (resolvername != null) {
DependencyResolver resolver = settings.getResolver(resolvername);
Set<Artifact> artifacts = new HashSet<>();
for (String conf : md.getConfigurationsNames()) {
artifacts.addAll(Arrays.asList(md.getArtifacts(conf)));
}
for (Artifact artifact : artifacts) {
if (!resolver.exists(artifact)) {
Message.info("declared publication not found: " + artifact);
result = false;
}
}
}
// check dependencies
ResolveData data = new ResolveData(resolveEngine, new ResolveOptions());
for (DependencyDescriptor dd : md.getDependencies()) {
// check master confs
for (String masterConf : dd.getModuleConfigurations()) {
if (!"*".equals(masterConf.trim()) && md.getConfiguration(masterConf) == null) {
Message.info("dependency required in non existing conf for " + ivyFile + " \n\tin " + dd + ": " + masterConf);
result = false;
}
}
// resolve
DependencyResolver resolver = settings.getResolver(dd.getDependencyRevisionId());
ResolvedModuleRevision rmr = resolver.getDependency(dd, data);
if (rmr == null) {
Message.info("dependency not found in " + ivyFile + ":\n\t" + dd);
result = false;
} else {
for (String depConf : dd.getDependencyConfigurations(md.getConfigurationsNames())) {
if (!Arrays.asList(rmr.getDescriptor().getConfigurationsNames()).contains(depConf)) {
Message.info("dependency configuration is missing for " + ivyFile + "\n\tin " + dd + ": " + depConf);
result = false;
}
for (Artifact art : rmr.getDescriptor().getArtifacts(depConf)) {
if (!resolver.exists(art)) {
Message.info("dependency artifact is missing for " + ivyFile + "\n\t in " + dd + ": " + art);
result = false;
}
}
}
}
}
return result;
} catch (ParseException e) {
Message.info("parse problem on " + ivyFile, e);
return false;
} catch (IOException e) {
Message.info("io problem on " + ivyFile, e);
return false;
} catch (Exception e) {
Message.info("problem on " + ivyFile, e);
return false;
}
}
use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.
the class Ivy method findModule.
// ///////////////////////////////////////////////////////////////////////
// SEARCH
// ///////////////////////////////////////////////////////////////////////
public ResolvedModuleRevision findModule(ModuleRevisionId mrid) {
pushContext();
try {
ResolveOptions options = new ResolveOptions();
options.setValidate(false);
return resolveEngine.findModule(mrid, options);
} finally {
popContext();
}
}
use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.
the class Ivy14 method findModule.
public ResolvedModuleRevision findModule(ModuleRevisionId id) {
ResolveOptions options = new ResolveOptions();
options.setValidate(false);
return ivy.getResolveEngine().findModule(id, options);
}
use of org.apache.ivy.core.resolve.ResolveOptions in project ant-ivy by apache.
the class ChainResolverTest method setUp.
@Before
public void setUp() {
settings = new IvySettings();
engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
TestHelper.createCache();
data = new ResolveData(engine, new ResolveOptions());
settings.setDefaultCache(TestHelper.cache);
}
Aggregations