protected void prepareAndCheck()

in src/java/org/apache/ivy/ant/IvyPostResolveTask.java [112:214]


    protected void prepareAndCheck() {
        Ivy ivy = getIvyInstance();
        IvySettings settings = ivy.getSettings();

        boolean orgAndModSetManually = organisation != null && module != null;

        organisation = getProperty(organisation, settings, "ivy.organisation");
        module = getProperty(module, settings, "ivy.module");

        if (file == null) {
            String fileName = getProperty(settings, "ivy.resolved.file", resolveId);
            if (fileName != null) {
                file = getProject().resolveFile(fileName);
            }
        }

        if (isInline()) {
            if (conf == null) {
                conf = "*";
            }
            if (organisation == null) {
                throw new BuildException(
                        "no organisation provided for ivy cache task in inline mode: "
                                + "It can either be set explicitly via the attribute 'organisation' "
                                + "or via 'ivy.organisation' property");
            }
            if (module == null) {
                throw new BuildException(
                        "no module name provided for ivy cache task in inline mode: "
                                + "It can either be set explicitly via the attribute 'module' "
                                + "or via 'ivy.module' property");
            }
            String[] toResolve = getConfsToResolve(getOrganisation(), getModule() + "-caller",
                conf, true);
            // When we make an inline resolution, we can not resolve private confs.
            for (int i = 0; i < toResolve.length; i++) {
                if ("*".equals(toResolve[i])) {
                    toResolve[i] = "*(public)";
                }
            }
            if (toResolve.length > 0) {
                Message.verbose(String.format("using inline mode to resolve %s %s %s (%s)",
                        getOrganisation(), getModule(), getRevision(), joinArray(toResolve, ", ")));
                IvyResolve resolve = setupResolve(isHaltonfailure(), isUseOrigin());
                resolve.setOrganisation(getOrganisation());
                resolve.setModule(getModule());
                resolve.setBranch(getBranch());
                resolve.setRevision(getRevision());
                resolve.setInline(true);
                resolve.setChanging(isChanging());
                resolve.setConf(conf);
                resolve.setResolveId(resolveId);
                resolve.setTransitive(isTransitive());
                resolve.execute();
            } else {
                Message.verbose(String.format("inline resolve already done for %s %s %s (%s)",
                        getOrganisation(), getModule(), getRevision(), conf));
            }
            if ("*".equals(conf)) {
                conf = joinArray(
                    getResolvedConfigurations(getOrganisation(), getModule() + "-caller", true),
                    ", ");
            }
        } else {
            Message.debug("using standard ensure resolved");

            // if the organization and module has been manually specified, we'll reuse the resolved
            // data from another build (there is no way to know which configurations were resolved
            // there (TODO: maybe we can check which reports exist and extract the configurations
            // from these report names?)
            if (!orgAndModSetManually) {
                ensureResolved(settings);
            }

            conf = getProperty(conf, settings, "ivy.resolved.configurations");
            if ("*".equals(conf)) {
                conf = getProperty(settings, "ivy.resolved.configurations");
                if (conf == null) {
                    throw new BuildException("bad conf provided for ivy cache task: "
                            + "'*' can only be used with a prior call to <resolve/>");
                }
            }
        }
        organisation = getProperty(organisation, settings, "ivy.organisation");
        module = getProperty(module, settings, "ivy.module");
        if (organisation == null) {
            throw new BuildException("no organisation provided for ivy cache 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 cache task: "
                    + "It can either be set explicitly via the attribute 'module' "
                    + "or via 'ivy.module' property or a prior call to <resolve/>");
        }
        if (conf == null) {
            throw new BuildException("no conf provided for ivy cache task: "
                    + "It can either be set explicitly via the attribute 'conf' or "
                    + "via 'ivy.resolved.configurations' property or a prior call to <resolve/>");
        }

        artifactFilter = FilterHelper.getArtifactTypeFilter(type);
    }