Java Code Examples for org.apache.ivy.core.settings.IvySettings#getDefaultBranch()

The following examples show how to use org.apache.ivy.core.settings.IvySettings#getDefaultBranch() . 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: IvyFindRevision.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public void doExecute() throws BuildException {
    if (organisation == null) {
        throw new BuildException("no organisation provided for ivy findrevision task");
    }
    if (module == null) {
        throw new BuildException("no module name provided for ivy findrevision task");
    }
    if (revision == null) {
        throw new BuildException("no revision provided for ivy findrevision task");
    }

    Ivy ivy = getIvyInstance();
    IvySettings settings = ivy.getSettings();
    if (branch == null) {
        branch = settings.getDefaultBranch(new ModuleId(organisation, module));
    }
    ResolvedModuleRevision rmr = ivy.findModule(ModuleRevisionId.newInstance(organisation,
        module, branch, revision));
    if (rmr != null) {
        getProject().setProperty(property, rmr.getId().getRevision());
    }
}
 
Example 2
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");
    }
}