use of org.gradle.api.artifacts.VersionConstraint in project gradle by gradle.
the class ModuleMetadataParser method consumeDependencies.
private List<ModuleDependency> consumeDependencies(JsonReader reader) throws IOException {
List<ModuleDependency> dependencies = new ArrayList<ModuleDependency>();
reader.beginArray();
while (reader.peek() != END_ARRAY) {
reader.beginObject();
String group = null;
String module = null;
String reason = null;
VersionConstraint version = DefaultImmutableVersionConstraint.of();
ImmutableList<ExcludeMetadata> excludes = ImmutableList.of();
while (reader.peek() != END_OBJECT) {
String name = reader.nextName();
if (name.equals("group")) {
group = reader.nextString();
} else if (name.equals("module")) {
module = reader.nextString();
} else if (name.equals("version")) {
version = consumeVersion(reader);
} else if (name.equals("excludes")) {
excludes = consumeExcludes(reader);
} else if (name.equals("reason")) {
reason = reader.nextString();
} else {
consumeAny(reader);
}
}
dependencies.add(new ModuleDependency(group, module, version, excludes, reason));
reader.endObject();
}
reader.endArray();
return dependencies;
}
use of org.gradle.api.artifacts.VersionConstraint in project gradle by gradle.
the class ModuleMetadataParser method consumeDependencyConstraints.
private List<ModuleDependencyConstraint> consumeDependencyConstraints(JsonReader reader) throws IOException {
List<ModuleDependencyConstraint> dependencies = new ArrayList<ModuleDependencyConstraint>();
reader.beginArray();
while (reader.peek() != END_ARRAY) {
reader.beginObject();
String group = null;
String module = null;
String reason = null;
VersionConstraint version = null;
while (reader.peek() != END_OBJECT) {
String name = reader.nextName();
if (name.equals("group")) {
group = reader.nextString();
} else if (name.equals("module")) {
module = reader.nextString();
} else if (name.equals("version")) {
version = consumeVersion(reader);
} else if (name.equals("reason")) {
reason = reader.nextString();
} else {
consumeAny(reader);
}
}
dependencies.add(new ModuleDependencyConstraint(group, module, version, reason));
reader.endObject();
}
reader.endArray();
return dependencies;
}
use of org.gradle.api.artifacts.VersionConstraint 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