Bug 484004: Start publishing Eclipse platform artifacts to Maven central
- add developers section
diff --git a/releng/EnrichPoms/src/org/eclipse/cbi/p2repo/aggregator/maven/pom/ArtifactInfo.java b/releng/EnrichPoms/src/org/eclipse/cbi/p2repo/aggregator/maven/pom/ArtifactInfo.java
index abf7de1..59397cb 100644
--- a/releng/EnrichPoms/src/org/eclipse/cbi/p2repo/aggregator/maven/pom/ArtifactInfo.java
+++ b/releng/EnrichPoms/src/org/eclipse/cbi/p2repo/aggregator/maven/pom/ArtifactInfo.java
@@ -10,6 +10,8 @@
  ********************************************************************************/
 package org.eclipse.cbi.p2repo.aggregator.maven.pom;
 
+import java.util.List;
+
 public class ArtifactInfo {
 
 	private static final String SCM_GITROOT = "scm:git:git://git.eclipse.org/gitroot/";
@@ -74,6 +76,14 @@
 					subElement("connection", connectionUrl),
 					subElement("tag", extractScmTag()),
 					subElement("url", url));
+				String projRepo = extractProjectRepo(url);
+				if (projRepo != null) {
+					List<Developer> devs = Developer.developersPerRepo.get(projRepo);
+					if (devs == null)
+						System.err.println("No developers for project repo "+projRepo+" ("+this.bsn+")");
+					else
+						element("developers", indent, buf, Developer.pomSubElements(devs));
+				}
 			}
 			return buf.toString();
 		} catch (RuntimeException e) {
@@ -134,7 +144,17 @@
 		return connection.replace("eclipse.org/r", "eclipse.org/c");
 	}
 
-	void element(String tag, String indent, StringBuilder buf, String... contents) {
+	String extractProjectRepo(String url) {
+		int pos = 0;
+		for (int i=0; i<5; i++) {
+			pos = url.indexOf('/', pos+1);
+			if (pos == -1)
+				return null;
+		}
+		return url.substring(0, pos);
+	}
+
+	public static void element(String tag, String indent, StringBuilder buf, String... contents) {
 		buf.append(indent).append('<').append(tag).append('>');
 		if (contents.length == 1 && !contents[0].contains("\n")) {
 			buf.append(contents[0]);
@@ -149,7 +169,7 @@
 		buf.append("</").append(tag).append(">\n");
 	}
 
-	String subElement(String tag, String content) {
+	public static String subElement(String tag, String content) {
 		if (content == null)
 			return null;
 		StringBuilder buf = new StringBuilder();
diff --git a/releng/EnrichPoms/src/org/eclipse/cbi/p2repo/aggregator/maven/pom/Developer.java b/releng/EnrichPoms/src/org/eclipse/cbi/p2repo/aggregator/maven/pom/Developer.java
new file mode 100644
index 0000000..cfc48d4
--- /dev/null
+++ b/releng/EnrichPoms/src/org/eclipse/cbi/p2repo/aggregator/maven/pom/Developer.java
@@ -0,0 +1,68 @@
+/********************************************************************************
+ * Copyright (c) 2016 GK Software AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Stephan Herrmann - initial implementation
+ ********************************************************************************/
+package org.eclipse.cbi.p2repo.aggregator.maven.pom;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+
+import static org.eclipse.cbi.p2repo.aggregator.maven.pom.ArtifactInfo.element;
+import static org.eclipse.cbi.p2repo.aggregator.maven.pom.ArtifactInfo.subElement;
+
+public class Developer {
+
+	static final String[] ROLE_LEAD = { "Project Lead" };
+	
+	public static final HashMap<String, List<Developer>> developersPerRepo = new HashMap<String, List<Developer>>();
+	static {
+		developersPerRepo.put("https://git.eclipse.org/c/equinox",
+				Arrays.asList(new Developer("Ian Bull"), new Developer("Pascal Rapicault"), new Developer("Thomas Watson")));
+		developersPerRepo.put("https://git.eclipse.org/c/platform",
+				Arrays.asList(new Developer("Dani Megert")));
+	}
+	
+	String name;
+	String[] roles;
+
+	public Developer(String name) {
+		this.name = name;
+		this.roles = ROLE_LEAD;
+	}
+	
+	public void toPom(StringBuilder buf, String indent) {
+		element("developer", indent, buf,
+				subElement("name", this.name),
+				getRolesElement());
+	}
+	
+	private String getRolesElement() {
+		StringBuilder rolesElement = new StringBuilder();
+		element("roles", "", rolesElement, String.join("\n", getRoleElements()));
+		return rolesElement.toString();
+	}
+
+	private String[] getRoleElements() {
+		String[] roleElements = new String[this.roles.length];
+		for (int i = 0; i < this.roles.length; i++) {
+			StringBuilder subBuf = new StringBuilder();
+			element("role", "", subBuf, this.roles[i]);
+			roleElements[i] = subBuf.toString();
+		}
+		return roleElements;
+	}
+
+	public static String pomSubElements(List<Developer> devs) {
+		StringBuilder buf = new StringBuilder();
+		for (Developer developer : devs)
+			developer.toPom(buf, "");
+		return buf.toString();
+	}
+}