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();
}
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;
}
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();
}
Aggregations