Validates the name and version_requirement for a dependency, then creates
 the Dependency and adds it.
 Returns the Dependency that was added.
194782
def add_dependency(name, version_requirement=nil, repository=nil)
      validate_name(name)
      validate_version_range(version_requirement) if version_requirement

      if dup = @data['dependencies'].find { |d| d.full_module_name == name && d.version_requirement != version_requirement }
        raise ArgumentError, _("Dependency conflict for %{module_name}: Dependency %{name} was given conflicting version requirements %{version_requirement} and %{dup_version}. Verify that there are no duplicates in the metadata.json.") % { module_name: full_module_name, name: name, version_requirement: version_requirement, dup_version: dup.version_requirement }
      end

      dep = Dependency.new(name, version_requirement, repository)
      @data['dependencies'].add(dep)

      dep
    end
581064
def add_dependency(uri)
      self.config = hash_reassoc(config, :dependencies) do |set|
        set + Set.new([uri])
      end
    end
654113
public void addDependency(Dependency dependency) {
        Dependency newDep = null;
        String classifier = dependency.getArtifact().getClassifier();
        if ( Const.TEST.equals( classifier ) || Const.TEST_JAR.equals( classifier ) ) {
            ArtifactType artifactType = new DefaultArtifactType( Const.TEST_JAR, Const.JAR, Const.TEST_JAR, null );
            
            Artifact artifact = dependency.getArtifact();
            
            artifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),
                    null, Const.JAR, artifact.getBaseVersion(), artifactType );
            newDep =  new Dependency(artifact, dependency.getScope());
        } else {
            newDep = dependency;
        }
        dependencies.add(newDep);
    }
527517
public void add(Make make)
  {
    if (make == this)
      throw new IllegalArgumentException("Can't add self as a dependency.");

    int p = _makeList.indexOf(make);

    // matching make overrides old ones
    // server/10ik
    if (p >= 0) {
      Make oldMake = _makeList.get(p);

      if (oldMake != make)
        _makeList.add(p, make);
    }
    else
      _makeList.add(make);
  }
870549
function createFromDependency(pluginName) {
    var npmID = PluginDependency.nameToNpmID(pluginName);
    var version = pkg.dependencies[npmID];

    return PluginDependency.create(pluginName, version);
}
389417
def find_name(gem_name, version_requirement = Gem::Requirement.default)
      dep = Gem::Dependency.new gem_name, version_requirement
      search dep
    end
570492
def add(modname, features, required_version, installed_version=None,
        optional=False):
    """"""
    global DEPENDENCIES
    for dependency in DEPENDENCIES:
        if dependency.modname == modname:
            raise ValueError("Dependency has already been registered: %s"\
                             % modname)
    DEPENDENCIES += [Dependency(modname, features, required_version,
                                installed_version, optional)]
192922
def update(cls, content, dependency, version, spec="==", hashes=()):
        
        new_line = "{name}{spec}{version}".format(name=dependency.full_name, spec=spec, version=version)
        appendix = ''
        # leave environment markers intact
        if ";" in dependency.line:
            # condense multiline, split out the env marker, strip comments and --hashes
            new_line += ";" + dependency.line.splitlines()[0].split(";", 1)[1] \
                .split("#")[0].split("--hash")[0].rstrip()
        # add the comment
        if "#" in dependency.line:
            # split the line into parts: requirement and comment
            parts = dependency.line.split("#")
            requirement, comment = parts[0], "#".join(parts[1:])
            # find all whitespaces between the requirement and the comment
            whitespaces = (hex(ord('\t')), hex(ord(' ')))
            trailing_whitespace = ''
            for c in requirement[::-1]:
                if hex(ord(c)) in whitespaces:
                    trailing_whitespace += c
                else:
                    break
            appendix += trailing_whitespace + "#" + comment
        # if this is a hashed requirement, add a multiline break before the comment
        if dependency.hashes and not new_line.endswith("\\"):
            new_line += " \\"
        # if this is a hashed requirement, add the hashes
        if hashes:
            for n, new_hash in enumerate(hashes):
                new_line += "\n    --hash={method}:{hash}".format(
                    method=new_hash['method'],
                    hash=new_hash['hash']
                )
                # append a new multiline break if this is not the last line
                if len(hashes) > n + 1:
                    new_line += " \\"
        new_line += appendix

        regex = cls.SUB_REGEX.format(re.escape(dependency.line))

        return re.sub(regex, new_line, content, flags=re.MULTILINE)
305460
def task_requires(*dependencies):
    
    def entangle(task):
        "Decorator wrapper."
        if not isinstance(task, tasks.Task):
            task = tasks.Task(task)

        def tool_task(*args, **kw):
            "Install requirements, then call original task."
            install_tools(dependencies)
            return task_body(*args, **kw)

        # Apply our wrapper to original task
        task_body, task.func = task.func, tool_task
        return task

    return entangle
548160
function requireDependencies(dependencies) {
    var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;

    var promise = new _es6Promise.Promise(function (succeed, fail) {
        var requirements = {};

        // no requirements
        if (!(dependencies instanceof Array)) {
            return succeed(requirements);
        }

        // check if succeeded
        function checkStatus() {
            if (Object.keys(requirements).length === dependencies.length) {
                succeed(requirements);
            }
        }

        dependencies.forEach(function (dependency) {
            if (packages.has(dependency)) {
                requirements[dependency] = packages.get(dependency);
            } else {
                events.once("load:" + dependency, function (requirement) {
                    requirements[dependency] = requirement;
                    checkStatus();
                });
            }
        });

        // First check
        checkStatus();
    });

    return typeof callback === "function" ? promise.then(callback) : promise;
}
134753
@Override
    public RPMBuilder addRequire(String name, String version, Condition... dependency)
    {
        addString(RPMTAG_REQUIRENAME, name);
        addString(RPMTAG_REQUIREVERSION, version);
        addInt32(RPMTAG_REQUIREFLAGS, Dependency.or(dependency));
        ensureVersionReq(version);
        return this;
    }
1262587
@Override
    public RPMBuilder addConflict(String name, String version, Condition... dependency)
    {
        addString(RPMTAG_CONFLICTNAME, name);
        addString(RPMTAG_CONFLICTVERSION, version);
        addInt32(RPMTAG_CONFLICTFLAGS, Dependency.or(dependency));
        ensureVersionReq(version);
        return this;
    }
562314
def construct(cls, name, range=None):
        
        other = Requirement(None)
        other.name_ = name
        other.range_ = VersionRange() if range is None else range
        return other
734141
private DependencyInfo createDependencyInfo(PhpPackage phpPackage) {
        String groupId = getGroupIdFromName(phpPackage);
        String artifactId = phpPackage.getName();
        String version = phpPackage.getVersion();
        String commit = phpPackage.getPackageSource().getReference();
        if (StringUtils.isNotBlank(version) || StringUtils.isNotBlank(commit)) {
            DependencyInfo dependencyInfo = new DependencyInfo(groupId, artifactId, version);
            dependencyInfo.setCommit(commit);
            dependencyInfo.setDependencyType(getDependencyType());
            if (this.addSha1) {
                String sha1 = null;
                String sha1Source = StringUtils.isNotBlank(version) ? version : commit;
                try {
                    sha1 = this.hashCalculator.calculateSha1ByNameVersionAndType(artifactId, sha1Source, DependencyType.PHP);
                } catch (IOException e) {
                    logger.debug("Failed to calculate sha1 of: {}", artifactId);
                }
                if (sha1 != null) {
                    dependencyInfo.setSha1(sha1);
                }
            }
            return dependencyInfo;
        } else {
            logger.debug("The parameters version and commit of {} are null", phpPackage.getName());
            return null;
        }
    }
9397
def find_missing_dependencies(self, requirement):
        
        known_dependencies = self.find_known_dependencies(requirement)
        if known_dependencies:
            installed_packages = self.find_installed_packages()
            logger.debug("Checking for missing dependencies of %s ..", requirement.name)
            missing_dependencies = sorted(set(known_dependencies).difference(installed_packages))
            if missing_dependencies:
                logger.debug("Found %s: %s",
                             pluralize(len(missing_dependencies), "missing dependency", "missing dependencies"),
                             concatenate(missing_dependencies))
            else:
                logger.info("All known dependencies are already installed.")
            return missing_dependencies
5982
def chef_version_requirement
      if spec.metadata['halite_chef_version']
        # Manually overridden by gem metadata, use that.
        [spec.metadata['halite_chef_version']]
      elsif dep = spec.dependencies.find {|inner_dep| inner_dep.name == 'chef' && !inner_dep.requirement.none? }
        # Parse through the dependencies looking for something like `spec.add_dependency 'chef', '>= 12.1''`.
        dep.requirement.as_list
      else
        ['>= 12']
      end
    end
420994
def add_require(self, require):
        
        for p in self.requires:
            if p.value == require.value:
                return
        self.requires.append(require)