This element documents other Eclipse projects that are consumed by this project. JGit doesn't consume any projects, but its sister project EGit does. Change-Id: Ie922d27c580f6742e2acb051815a381af48df7ca Signed-off-by: Shawn O. Pearce <spearce@spearce.org>tags/v0.8.1
/** Projects indexed by their ID string, e.g. {@code technology.jgit}. */ | /** Projects indexed by their ID string, e.g. {@code technology.jgit}. */ | ||||
private final Map<String, Project> projects = new TreeMap<String, Project>(); | private final Map<String, Project> projects = new TreeMap<String, Project>(); | ||||
/** Projects indexed by their ID string, e.g. {@code technology.jgit}. */ | |||||
private final Map<String, Project> consumedProjects = new TreeMap<String, Project>(); | |||||
/** Known committers, indexed by their foundation ID. */ | /** Known committers, indexed by their foundation ID. */ | ||||
private final Map<String, Committer> committersById = new HashMap<String, Committer>(); | private final Map<String, Committer> committersById = new HashMap<String, Committer>(); | ||||
p.setVersion(version); | p.setVersion(version); | ||||
projects.put(p.getName(), p); | projects.put(p.getName(), p); | ||||
} | } | ||||
for (Project p : meta.getConsumedProjects()) { | |||||
consumedProjects.put(p.getName(), p); | |||||
} | |||||
cqs.addAll(meta.getCQs()); | cqs.addAll(meta.getCQs()); | ||||
} | } | ||||
root.appendChild(createProject(project)); | root.appendChild(createProject(project)); | ||||
licenses.addAll(project.getLicenses()); | licenses.addAll(project.getLicenses()); | ||||
} | } | ||||
if (!consumedProjects.isEmpty()) | |||||
appendBlankLine(root); | |||||
for (Project project : sort(consumedProjects, Project.COMPARATOR)) { | |||||
root.appendChild(createConsumes(project)); | |||||
licenses.addAll(project.getLicenses()); | |||||
} | |||||
for (RevCommit c : sort(commits)) | for (RevCommit c : sort(commits)) | ||||
root.appendChild(createCommitMeta(c)); | root.appendChild(createCommitMeta(c)); | ||||
if (licenses.size() > 1) | |||||
appendBlankLine(root); | |||||
for (String name : sort(licenses)) | for (String name : sort(licenses)) | ||||
root.appendChild(createLicense(name)); | root.appendChild(createLicense(name)); | ||||
private Element createProject(Project p) { | private Element createProject(Project p) { | ||||
Element project = createElement("project"); | Element project = createElement("project"); | ||||
populateProjectType(p, project); | |||||
return project; | |||||
} | |||||
private Element createConsumes(Project p) { | |||||
Element project = createElement("consumes"); | |||||
populateProjectType(p, project); | |||||
return project; | |||||
} | |||||
private void populateProjectType(Project p, Element project) { | |||||
required(project, "id", p.getID()); | required(project, "id", p.getID()); | ||||
required(project, "name", p.getName()); | required(project, "name", p.getName()); | ||||
optional(project, "comments", p.getComments()); | optional(project, "comments", p.getComments()); | ||||
optional(project, "version", p.getVersion()); | optional(project, "version", p.getVersion()); | ||||
return project; | |||||
} | } | ||||
private Element createCommitMeta(RevCommit c) { | private Element createCommitMeta(RevCommit c) { |
private static final String S_CQ = "CQ"; | private static final String S_CQ = "CQ"; | ||||
private static final String S_CONSUMES = "consumes"; | |||||
private static final String K_NAME = "name"; | private static final String K_NAME = "name"; | ||||
private static final String K_VERSION = "version"; | |||||
private static final String K_COMMENTS = "comments"; | private static final String K_COMMENTS = "comments"; | ||||
private static final String K_SKIP_COMMIT = "skipCommit"; | private static final String K_SKIP_COMMIT = "skipCommit"; | ||||
private List<Project> projects = new ArrayList<Project>(); | private List<Project> projects = new ArrayList<Project>(); | ||||
private List<Project> consumedProjects = new ArrayList<Project>(); | |||||
private Set<CQ> cqs = new HashSet<CQ>(); | private Set<CQ> cqs = new HashSet<CQ>(); | ||||
List<Project> getProjects() { | List<Project> getProjects() { | ||||
return projects; | return projects; | ||||
} | } | ||||
List<Project> getConsumedProjects() { | |||||
return consumedProjects; | |||||
} | |||||
Set<CQ> getCQs() { | Set<CQ> getCQs() { | ||||
return cqs; | return cqs; | ||||
} | } | ||||
void loadFrom(Config cfg) { | void loadFrom(Config cfg) { | ||||
projects.clear(); | projects.clear(); | ||||
consumedProjects.clear(); | |||||
cqs.clear(); | cqs.clear(); | ||||
for (String id : cfg.getSubsections(S_PROJECT)) { | |||||
String name = cfg.getString(S_PROJECT, id, K_NAME); | |||||
Project project = new Project(id, name); | |||||
project.setComments(cfg.getString(S_PROJECT, id, K_COMMENTS)); | |||||
for (String c : cfg.getStringList(S_PROJECT, id, K_SKIP_COMMIT)) | |||||
project.addSkipCommit(ObjectId.fromString(c)); | |||||
for (String license : cfg.getStringList(S_PROJECT, id, K_LICENSE)) | |||||
project.addLicense(license); | |||||
projects.add(project); | |||||
} | |||||
projects.addAll(parseProjects(cfg, S_PROJECT)); | |||||
consumedProjects.addAll(parseProjects(cfg, S_CONSUMES)); | |||||
for (String id : cfg.getSubsections(S_CQ)) { | for (String id : cfg.getSubsections(S_CQ)) { | ||||
CQ cq = new CQ(Long.parseLong(id)); | CQ cq = new CQ(Long.parseLong(id)); | ||||
} | } | ||||
} | } | ||||
private List<Project> parseProjects(final Config cfg, | |||||
final String sectionName) { | |||||
final List<Project> dst = new ArrayList<Project>(); | |||||
for (String id : cfg.getSubsections(sectionName)) { | |||||
String name = cfg.getString(sectionName, id, K_NAME); | |||||
Project project = new Project(id, name); | |||||
project.setVersion(cfg.getString(sectionName, id, K_VERSION)); | |||||
project.setComments(cfg.getString(sectionName, id, K_COMMENTS)); | |||||
for (String c : cfg.getStringList(sectionName, id, K_SKIP_COMMIT)) | |||||
project.addSkipCommit(ObjectId.fromString(c)); | |||||
for (String license : cfg.getStringList(sectionName, id, K_LICENSE)) | |||||
project.addLicense(license); | |||||
dst.add(project); | |||||
} | |||||
return dst; | |||||
} | |||||
/** | /** | ||||
* Query the Eclipse Foundation's IPzilla database for CQ records. | * Query the Eclipse Foundation's IPzilla database for CQ records. | ||||
* <p> | * <p> |