DependencyType dependency = toDependencyType(artifact, includeVersion, explicitDependency, includeImport);
return dependency;
}
DependencyType toDependencyType(Artifact artifact, boolean includeVersion, DependencyType explicitDependency, boolean includeImport) {
DependencyType dependency = new DependencyType();
dependency.setGroupId(artifact.getGroupId());
dependency.setArtifactId(artifact.getArtifactId());
String version = null;
if (includeVersion) {
if (artifact.getVersionRange() == null) {
version = artifact.getVersion();
} else {
version = artifact.getVersionRange().getRecommendedVersion().toString();
}
}
dependency.setVersion(version);
dependency.setType(artifact.getType());
if (includeImport) {
ImportType importType = ImportType.ALL;
if (explicitDependency != null && explicitDependency.getImport() != null) {
importType = explicitDependency.getImport();
}
dependency.setImport(importType);
}
if (explicitDependency != null) {
dependency.setStart(explicitDependency.isStart());
}
return dependency;
}