org.apache.ivy.util.filter.FilterHelper Java Examples

The following examples show how to use org.apache.ivy.util.filter.FilterHelper. 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: IvyResolve.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private ResolveOptions getResolveOptions(Ivy ivy, String[] confs, IvySettings settings) {
    if (useOrigin) {
        settings.useDeprecatedUseOrigin();
    }
    return ((ResolveOptions) new ResolveOptions().setLog(log)).setConfs(confs)
            .setValidate(doValidate(settings))
            .setArtifactFilter(FilterHelper.getArtifactTypeFilter(type)).setRevision(revision)
            .setDate(getPubDate(pubdate, null)).setUseCacheOnly(useCacheOnly)
            .setRefresh(refresh).setTransitive(transitive).setResolveMode(resolveMode)
            .setResolveId(resolveId).setCheckIfChanged(checkIfChanged);
}
 
Example #2
Source File: IvyNode.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Returns all the artifacts of this dependency required in the root module configurations in
 * which the node is not evicted nor blacklisted
 *
 * @param artifactFilter Filter
 * @return array of {@link Artifact}s
 */
public Artifact[] getSelectedArtifacts(Filter<Artifact> artifactFilter) {
    Collection<Artifact> ret = new HashSet<>();
    for (String rootModuleConf : getRootModuleConfigurationsSet()) {
        if (!isEvicted(rootModuleConf) && !isBlacklisted(rootModuleConf)) {
            ret.addAll(Arrays.asList(getArtifacts(rootModuleConf)));
        }
    }
    ret = FilterHelper.filter(ret, artifactFilter);
    return ret.toArray(new Artifact[ret.size()]);
}
 
Example #3
Source File: Ivy14.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public IvyNode[] getDependencies(ModuleDescriptor md, String[] confs, File cache, Date date,
        ResolveReport report, boolean validate, boolean transitive) {
    return ivy.getResolveEngine().getDependencies(md, newResolveOptions(confs, null, cache,
        date, validate, false, transitive, false, true, true, FilterHelper.NO_FILTER), report);
}
 
Example #4
Source File: Ivy14.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public IvyNode[] getDependencies(ModuleDescriptor md, String[] confs, File cache, Date date,
        ResolveReport report, boolean validate) {
    return ivy.getResolveEngine().getDependencies(md, newResolveOptions(confs, null, cache,
        date, validate, false, true, false, true, true, FilterHelper.NO_FILTER), report);
}
 
Example #5
Source File: Ivy14.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public IvyNode[] getDependencies(URL ivySource, String[] confs, File cache, Date date,
        boolean validate) throws ParseException, IOException {
    return ivy.getResolveEngine().getDependencies(ivySource, newResolveOptions(confs, null,
        cache, date, validate, false, true, false, true, true, FilterHelper.NO_FILTER));
}
 
Example #6
Source File: Ivy14.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
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);
}
 
Example #7
Source File: Ivy14.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public ResolveReport resolve(URL ivySource, String revision, String[] confs, File cache,
        Date date, boolean validate, boolean useCacheOnly) throws ParseException, IOException {
    return ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate,
        useCacheOnly, true, false, true, true, FilterHelper.NO_FILTER));
}
 
Example #8
Source File: Ivy14.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public ResolveReport resolve(URL ivySource, String revision, String[] confs, File cache,
        Date date, boolean validate) throws ParseException, IOException {
    return ivy.resolve(ivySource, newResolveOptions(confs, revision, cache, date, validate,
        false, true, false, true, true, FilterHelper.NO_FILTER));
}
 
Example #9
Source File: IvyInstall.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public void doExecute() throws BuildException {
    Ivy ivy = getIvyInstance();
    IvySettings settings = ivy.getSettings();
    if (organisation == null) {
        throw new BuildException("no organisation provided for ivy publish 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) {
        if (PatternMatcher.EXACT.equals(matcher)) {
            throw new BuildException("no module name provided for ivy publish task: "
                    + "It can either be set explicitly via the attribute 'module' "
                    + "or via 'ivy.module' property or a prior call to <resolve/>");
        }
        module = PatternMatcher.ANY_EXPRESSION;
    }
    if (revision == null) {
        if (PatternMatcher.EXACT.equals(matcher)) {
            throw new BuildException("no module revision provided for ivy publish task: "
                    + "It can either be set explicitly via the attribute 'revision' "
                    + "or via 'ivy.revision' property or a prior call to <resolve/>");
        }
        revision = PatternMatcher.ANY_EXPRESSION;
    }
    if (branch == null) {
        if (PatternMatcher.EXACT.equals(matcher)) {
            branch = settings.getDefaultBranch(ModuleId.newInstance(organisation, module));
        } else {
            branch = PatternMatcher.ANY_EXPRESSION;
        }
    }
    if (from == null) {
        throw new BuildException(
                "no from resolver name: please provide it through parameter 'from'");
    }
    if (to == null) {
        throw new BuildException(
                "no to resolver name: please provide it through parameter 'to'");
    }
    ModuleRevisionId mrid = ModuleRevisionId
            .newInstance(organisation, module, branch, revision);

    ResolveReport report;
    try {
        report = ivy.install(
            mrid,
            from,
            to,
            new InstallOptions().setTransitive(transitive).setValidate(doValidate(settings))
                    .setOverwrite(overwrite).setConfs(conf.split(","))
                    .setArtifactFilter(FilterHelper.getArtifactTypeFilter(type))
                    .setMatcherName(matcher)
                    .setInstallOriginalMetadata(installOriginalMetadata));
    } catch (Exception e) {
        throw new BuildException("impossible to install " + mrid + ": " + e, e);
    }

    if (report.hasError() && isHaltonfailure()) {
        throw new BuildException(
                "Problem happened while installing modules - see output for details");
    }
}
 
Example #10
Source File: InstallOptions.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public InstallOptions setArtifactFilter(Filter<Artifact> artifactFilter) {
    this.artifactFilter = (artifactFilter == null) ? FilterHelper.NO_FILTER : artifactFilter;
    return this;
}
 
Example #11
Source File: DependenciesManager.java    From restcommander with Apache License 2.0 4 votes vote down vote up
public ResolveReport resolve() throws Exception {

        // Module
        ModuleDescriptorParserRegistry.getInstance().addParser(new YamlParser());
        File ivyModule = new File(application, "conf/dependencies.yml");
        if(!ivyModule.exists()) {
            System.out.println("~ !! " + ivyModule.getAbsolutePath() + " does not exist");
            return null;
        }


        // Variables
        System.setProperty("play.path", framework.getAbsolutePath());
        
        // Ivy
        Ivy ivy = configure();

        // Clear the cache
        boolean clearcache = System.getProperty("clearcache") != null;
        if(clearcache){
           System.out.println("~ Clearing cache : " + ivy.getResolutionCacheManager().getResolutionCacheRoot() + ",");
           System.out.println("~");
           try{
      		   FileUtils.deleteDirectory(ivy.getResolutionCacheManager().getResolutionCacheRoot());
      		   System.out.println("~       Clear");
           }catch(IOException e){
        	   System.out.println("~       Could not clear");
        	   System.out.println("~ ");
        	   e.printStackTrace();
             }

           System.out.println("~");
         }
        

        System.out.println("~ Resolving dependencies using " + ivyModule.getAbsolutePath() + ",");
        System.out.println("~");
        
        // Resolve
        ResolveEngine resolveEngine = ivy.getResolveEngine();
        ResolveOptions resolveOptions = new ResolveOptions();
        resolveOptions.setConfs(new String[]{"default"});
        resolveOptions.setArtifactFilter(FilterHelper.getArtifactTypeFilter(new String[]{"jar", "bundle"}));

        return resolveEngine.resolve(ivyModule.toURI().toURL(), resolveOptions);
    }