Search in sources :

Example 6 with PatternMatcher

use of org.apache.ivy.plugins.matcher.PatternMatcher in project ant-ivy by apache.

the class IvyListModules method doExecute.

public void doExecute() throws BuildException {
    if (organisation == null) {
        throw new BuildException("no organisation provided for ivy listmodules task");
    }
    if (module == null) {
        throw new BuildException("no module name provided for ivy listmodules task");
    }
    if (revision == null) {
        throw new BuildException("no revision provided for ivy listmodules task");
    }
    if (property == null) {
        throw new BuildException("no property provided for ivy listmodules task");
    }
    if (value == null) {
        throw new BuildException("no value provided for ivy listmodules task");
    }
    Ivy ivy = getIvyInstance();
    IvySettings settings = ivy.getSettings();
    SearchEngine searcher = new SearchEngine(settings);
    PatternMatcher patternMatcher = settings.getMatcher(matcher);
    ModuleRevisionId[] mrids;
    if (resolver == null) {
        mrids = searcher.listModules(ModuleRevisionId.newInstance(organisation, module, branch, revision), patternMatcher);
    } else {
        DependencyResolver depResolver = settings.getResolver(resolver);
        if (depResolver == null) {
            throw new BuildException("Unknown resolver: " + resolver);
        }
        mrids = searcher.listModules(depResolver, ModuleRevisionId.newInstance(organisation, module, branch, revision), patternMatcher);
    }
    for (ModuleRevisionId mrid : mrids) {
        String name = IvyPatternHelper.substitute(settings.substitute(property), mrid);
        String value = IvyPatternHelper.substitute(settings.substitute(this.value), mrid);
        getProject().setProperty(name, value);
    }
}
Also used : SearchEngine(org.apache.ivy.core.search.SearchEngine) IvySettings(org.apache.ivy.core.settings.IvySettings) ModuleRevisionId(org.apache.ivy.core.module.id.ModuleRevisionId) BuildException(org.apache.tools.ant.BuildException) Ivy(org.apache.ivy.Ivy) PatternMatcher(org.apache.ivy.plugins.matcher.PatternMatcher) DependencyResolver(org.apache.ivy.plugins.resolver.DependencyResolver)

Aggregations

PatternMatcher (org.apache.ivy.plugins.matcher.PatternMatcher)6 ModuleRevisionId (org.apache.ivy.core.module.id.ModuleRevisionId)4 ModuleId (org.apache.ivy.core.module.id.ModuleId)3 ExactPatternMatcher (org.apache.ivy.plugins.matcher.ExactPatternMatcher)3 DependencyResolver (org.apache.ivy.plugins.resolver.DependencyResolver)3 ArrayList (java.util.ArrayList)2 Ivy (org.apache.ivy.Ivy)2 SearchEngine (org.apache.ivy.core.search.SearchEngine)2 IvySettings (org.apache.ivy.core.settings.IvySettings)2 BuildException (org.apache.tools.ant.BuildException)2 File (java.io.File)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Configuration (org.apache.ivy.core.module.descriptor.Configuration)1 DefaultDependencyDescriptor (org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor)1 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)1 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)1 ArtifactDownloadReport (org.apache.ivy.core.report.ArtifactDownloadReport)1 MetadataArtifactDownloadReport (org.apache.ivy.core.report.MetadataArtifactDownloadReport)1 ResolveReport (org.apache.ivy.core.report.ResolveReport)1