Java Code Examples for org.apache.ivy.core.IvyContext#getContext()

The following examples show how to use org.apache.ivy.core.IvyContext#getContext() . 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: ModuleRevisionId.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private ModuleRevisionId(ModuleId moduleId, String branch, String revision,
        Map<String, String> extraAttributes, boolean replaceNullBranchWithDefault) {
    super(null, extraAttributes);
    this.moduleId = moduleId;
    IvyContext context = IvyContext.getContext();
    this.branch = (replaceNullBranchWithDefault && branch == null)
    // we test if there's already an Ivy instance loaded, to avoid loading a default one
    // just to get the default branch
    ? (context.peekIvy() == null ? null : context.getSettings().getDefaultBranch(moduleId))
            : branch;
    this.revision = revision == null ? Ivy.getWorkingRevision() : normalizeRevision(revision);
    setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, this.moduleId.getOrganisation());
    setStandardAttribute(IvyPatternHelper.MODULE_KEY, this.moduleId.getName());
    setStandardAttribute(IvyPatternHelper.BRANCH_KEY, this.branch);
    setStandardAttribute(IvyPatternHelper.REVISION_KEY, this.revision);
}
 
Example 2
Source File: IvyContextualiser.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static IvyContext getIvyContext() {
    IvyContext context = IvyContext.getContext();
    if (context.peekIvy() == null) {
        throw new IllegalStateException("Ivy context not established");
    }
    return context;
}
 
Example 3
Source File: IvyContextualiser.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static IvyContext getIvyContext() {
    IvyContext context = IvyContext.getContext();
    if (context.peekIvy() == null) {
        throw new IllegalStateException("Ivy context not established");
    }
    return context;
}
 
Example 4
Source File: IvyContextualiser.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static IvyContext getIvyContext() {
    IvyContext context = IvyContext.getContext();
    if (context.peekIvy() == null) {
        throw new IllegalStateException("Ivy context not established");
    }
    return context;
}
 
Example 5
Source File: IvyContextualiser.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static IvyContext getIvyContext() {
    IvyContext context = IvyContext.getContext();
    if (context.peekIvy() == null) {
        throw new IllegalStateException("Ivy context not established");
    }
    return context;
}
 
Example 6
Source File: ResolveEngine.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
/**
 * Compute possible conflicts for a node, in the context of an ancestor (a node which has a
 * dependency - direct or indirect - on the node for which conflicts should be computed.
 *
 * @param node
 *            the node for which conflicts should be computed
 * @param ancestor
 *            the ancestor in which conflicts should be computed
 * @param conf
 *            the configuration of the node in which conflicts should be computed
 * @param toevict
 *            a collection of nodes which have been evicted during conflict resolution at lower
 *            level. It may be empty if no conflict resolution has occurred for this node yet,
 *            or if no node has been evicted.
 * @param selectedNodes
 *            a collection of nodes selected during previous conflict resolution for the given
 *            node and ancestor. This collection is updated by this call, removing nodes which
 *            should be evicted.
 * @return a collection of IvyNode which may be in conflict with the given node in the given
 *         ancestor. This collection always contain at least the given node.
 */
private Collection<IvyNode> computeConflicts(VisitNode node, VisitNode ancestor, String conf,
        Collection<IvyNode> toevict, Collection<IvyNode> selectedNodes) {
    Collection<IvyNode> conflicts = new LinkedHashSet<>();
    conflicts.add(node.getNode());
    /*
     * We first try to remove all evicted nodes from the collection of selected nodes to update
     * this collection. If the collection changes, it means that it contained evicted nodes, and
     * thus is not up to date.
     */
    boolean evictedInSelected = selectedNodes.removeAll(toevict);
    /*
     * Another case where we need to deeply compute selected nodes is when selectedNodes is
     * empty (not computed yet) and we aren't in the context of the direct parent of the node.
     */
    if (evictedInSelected
            || (selectedNodes.isEmpty() && !node.getParent().getNode()
                    .equals(ancestor.getNode()))) {
        IvyContext context = IvyContext.getContext();
        ResolveData data = context.getResolveData();
        VisitNode oldVisitNode = data.getCurrentVisitNode();
        data.setCurrentVisitNode(ancestor);
        try {
            // In this case we need to compute selected nodes again.
            Collection<IvyNode> deps = ancestor.getNode().getDependencies(
                node.getRootModuleConf(),
                ancestor.getNode().getConfigurations(node.getRootModuleConf()),
                ancestor.getRequestedConf());
            for (IvyNode dep : deps) {
                if (dep.getModuleId().equals(node.getModuleId())) {
                    conflicts.add(dep);
                }
                conflicts.addAll(dep.getResolvedNodes(node.getModuleId(),
                    node.getRootModuleConf()));
            }
        } finally {
            data.setCurrentVisitNode(oldVisitNode);
        }
    } else if (selectedNodes.isEmpty()) {
        /*
         * No selected nodes at all yet, and we are in the context of the direct parent
         * (otherwise previous block would have been reached). We can compute conflicts based on
         * the parent direct dependencies in current root module conf.
         */
        VisitNode parent = node.getParent();
        Collection<IvyNode> parentDepIvyNodes = parent.getNode().getDependencies(
            node.getRootModuleConf(),
            parent.getNode().getConfigurations(node.getRootModuleConf()),
            parent.getRequestedConf());
        for (IvyNode parentDep : parentDepIvyNodes) {
            if (parentDep.getModuleId().equals(node.getModuleId())) {
                conflicts.add(parentDep);
            }
        }
    } else {
        conflicts.addAll(selectedNodes);
    }
    return conflicts;
}