Search in sources :

Example 16 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class DefaultIvyModuleDescriptorWriter method printDependency.

protected void printDependency(LocalOriginDependencyMetadata dep, SimpleXmlWriter writer) throws IOException {
    writer.startElement("dependency");
    ModuleVersionSelector requested = componentSelectorConverter.getSelector(dep.getSelector());
    writer.attribute("org", requested.getGroup());
    writer.attribute("name", requested.getName());
    writer.attribute("rev", requested.getVersion());
    if (dep.isForce()) {
        writer.attribute("force", "true");
    }
    if (dep.isChanging()) {
        writer.attribute("changing", "true");
    }
    if (!dep.isTransitive()) {
        writer.attribute("transitive", "false");
    }
    writer.attribute("conf", getConfMapping(dep));
    for (IvyArtifactName dependencyArtifact : dep.getArtifacts()) {
        printDependencyArtifact(writer, dependencyArtifact, dep.getModuleConfiguration());
    }
    printDependencyExcludeRules(writer, dep.getExcludes());
    writer.endElement();
}
Also used : ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) IvyArtifactName(org.gradle.internal.component.model.IvyArtifactName)

Example 17 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class DefaultAutoAppliedPluginHandler method isAlreadyRequestedInBuildScriptBlock.

private static boolean isAlreadyRequestedInBuildScriptBlock(PluginRequestInternal autoAppliedPlugin, ScriptHandler scriptHandler) {
    ModuleVersionSelector module = autoAppliedPlugin.getModule();
    if (module == null) {
        return false;
    }
    Configuration classpathConfiguration = scriptHandler.getConfigurations().getByName(ScriptHandler.CLASSPATH_CONFIGURATION);
    for (Dependency dependency : classpathConfiguration.getDependencies()) {
        if (module.getGroup().equals(dependency.getGroup()) && module.getName().equals(dependency.getName())) {
            return true;
        }
    }
    return false;
}
Also used : ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) Configuration(org.gradle.api.artifacts.Configuration) Dependency(org.gradle.api.artifacts.Dependency)

Example 18 with ModuleVersionSelector

use of org.gradle.api.artifacts.ModuleVersionSelector in project gradle by gradle.

the class ModuleMetadataFileGenerator method writeDependency.

private void writeDependency(Dependency dependency, JsonWriter jsonWriter) throws IOException {
    jsonWriter.beginObject();
    if (dependency instanceof ProjectDependency) {
        ProjectDependency projectDependency = (ProjectDependency) dependency;
        ModuleVersionIdentifier identifier = projectDependencyResolver.resolve(ModuleVersionIdentifier.class, projectDependency);
        jsonWriter.name("group");
        jsonWriter.value(identifier.getGroup());
        jsonWriter.name("module");
        jsonWriter.value(identifier.getName());
        writeVersionConstraint(DefaultImmutableVersionConstraint.of(identifier.getVersion()), jsonWriter);
    } else {
        jsonWriter.name("group");
        jsonWriter.value(dependency.getGroup());
        jsonWriter.name("module");
        jsonWriter.value(dependency.getName());
        VersionConstraint vc;
        if (dependency instanceof ModuleVersionSelector) {
            vc = ((ExternalDependency) dependency).getVersionConstraint();
        } else {
            vc = DefaultImmutableVersionConstraint.of(Strings.nullToEmpty(dependency.getVersion()));
        }
        writeVersionConstraint(vc, jsonWriter);
    }
    if (dependency instanceof ModuleDependency) {
        writeExcludes((ModuleDependency) dependency, jsonWriter);
    }
    String reason = dependency.getReason();
    if (StringUtils.isNotEmpty(reason)) {
        jsonWriter.name("reason");
        jsonWriter.value(reason);
    }
    jsonWriter.endObject();
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) VersionConstraint(org.gradle.api.artifacts.VersionConstraint) DefaultImmutableVersionConstraint(org.gradle.api.internal.artifacts.dependencies.DefaultImmutableVersionConstraint) ModuleVersionSelector(org.gradle.api.artifacts.ModuleVersionSelector) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) ProjectDependency(org.gradle.api.artifacts.ProjectDependency)

Aggregations

ModuleVersionSelector (org.gradle.api.artifacts.ModuleVersionSelector)18 DefaultModuleVersionSelector (org.gradle.api.internal.artifacts.DefaultModuleVersionSelector)9 ModuleComponentSelector (org.gradle.api.artifacts.component.ModuleComponentSelector)5 DefaultModuleComponentSelector (org.gradle.internal.component.external.model.DefaultModuleComponentSelector)5 Exclude (org.gradle.internal.component.model.Exclude)4 IvyArtifactName (org.gradle.internal.component.model.IvyArtifactName)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 ComponentSelector (org.gradle.api.artifacts.component.ComponentSelector)3 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)3 LinkedHashMap (java.util.LinkedHashMap)2 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)2 DefaultUnresolvedDependency (org.gradle.api.internal.artifacts.ivyservice.DefaultUnresolvedDependency)2 Artifact (org.gradle.internal.component.external.descriptor.Artifact)2 DefaultExclude (org.gradle.internal.component.external.descriptor.DefaultExclude)2 DslOriginDependencyMetadataWrapper (org.gradle.internal.component.local.model.DslOriginDependencyMetadataWrapper)2 DefaultIvyArtifactName (org.gradle.internal.component.model.DefaultIvyArtifactName)2 LocalComponentDependencyMetadata (org.gradle.internal.component.model.LocalComponentDependencyMetadata)2 ImmutableSet (com.google.common.collect.ImmutableSet)1