use of org.apache.maven.model.Developer in project maven-plugins by apache.
the class ChangeLogReport method sinkAuthorDetails.
/**
* If the supplied author is a known developer this method outputs a
* link to the team members report, or alternatively, if the supplied
* author is unknown, outputs the author's name as plain text.
*
* @param sink Sink to use for outputting
* @param author The author's name.
*/
protected void sinkAuthorDetails(Sink sink, String author) {
Developer developer = developersById.get(author);
if (developer == null) {
developer = developersByName.get(author);
}
if (developer != null) {
sink.link("team-list.html#" + developer.getId());
sink.text(developer.getName());
sink.link_();
} else {
sink.text(author);
}
}
use of org.apache.maven.model.Developer in project maven-plugins by apache.
the class DoapUtilTest method testInterpolate.
/**
* Test method for:
* {@link DoapUtil#interpolate(String, MavenProject, org.apache.maven.settings.Settings)}
*
* @throws Exception if any
*/
public void testInterpolate() throws Exception {
License license = new License();
license.setName("licenseName");
license.setUrl("licenseUrl");
List<Developer> developers = new ArrayList<Developer>();
Developer developer1 = new Developer();
developer1.setId("id1");
developer1.setName("developerName1");
developers.add(developer1);
Developer developer2 = new Developer();
developer2.setId("id1");
developer2.setName("developerName2");
developers.add(developer2);
MavenProject project = new MavenProject();
project.setName("projectName");
project.setDescription("projectDescription");
project.setLicenses(Collections.singletonList(license));
project.setDevelopers(developers);
project.getProperties().put("myKey", "myValue");
assertEquals(DoapUtil.interpolate("${project.name}", project, null), "projectName");
assertEquals(DoapUtil.interpolate("my name is ${project.name}", project, null), "my name is projectName");
assertEquals(DoapUtil.interpolate("my name is ${project.invalid}", project, null), "my name is ${project.invalid}");
assertEquals(DoapUtil.interpolate("${pom.description}", project, null), "projectDescription");
assertNull(DoapUtil.interpolate("${project.licenses.name}", project, null));
assertEquals(DoapUtil.interpolate("${project.licenses[0].name}", project, null), "licenseName");
assertNull(DoapUtil.interpolate("${project.licenses[1].name}", project, null));
assertNotNull(DoapUtil.interpolate("${project.developers}", project, null));
assertEquals(DoapUtil.interpolate("${project.developers[0].name}", project, null), "developerName1");
assertEquals(DoapUtil.interpolate("${project.developers[1].name}", project, null), "developerName2");
assertEquals(DoapUtil.interpolate("${myKey}", project, null), "myValue");
}
use of org.apache.maven.model.Developer in project maven-plugins by apache.
the class DoapMojo method writeASFext.
/**
* Write the ASF extensions
*
* @param writer not null
* @param project the Maven project, not null
* @see <a href="http://svn.apache.org/repos/asf/infrastructure/site-tools/trunk/projects/asfext">
* http://svn.apache.org/repos/asf/infrastructure/site-tools/trunk/projects/asfext</a>
* @see <a href="http://projects.apache.org/docs/pmc.html">http://projects.apache.org/docs/pmc.html</a>
*/
private void writeASFext(XMLWriter writer, MavenProject project) {
if (!asfExtOptions.isIncluded()) {
return;
}
DoapUtil.writeComment(writer, "ASF extension.");
// asfext:pmc
String pmc = DoapUtil.interpolate(asfExtOptions.getPmc(), project, settings);
if (StringUtils.isNotEmpty(pmc)) {
DoapUtil.writeRdfResourceElement(writer, asfExtOptions.getXmlnsPrefix(), "pmc", pmc);
} else {
messages.addMessage(new String[] { "asfExtOptions", "pmc" }, null, UserMessages.REQUIRED_BY_ASF);
}
// asfext:name
String name = DoapUtil.interpolate(asfExtOptions.getName(), project, settings);
if (StringUtils.isNotEmpty(name)) {
if (!name.toLowerCase(Locale.ENGLISH).trim().startsWith("apache")) {
name = "Apache " + name;
}
DoapUtil.writeElement(writer, asfExtOptions.getXmlnsPrefix(), "name", name);
} else {
messages.addMessage(new String[] { "asfExtOptions", "name" }, null, UserMessages.REQUIRED_BY_ASF);
}
String homepage = DoapUtil.interpolate(doapOptions.getHomepage(), project, settings);
if (StringUtils.isNotEmpty(homepage)) {
try {
new URL(homepage);
DoapUtil.writeRdfResourceElement(writer, "foaf", "homepage", homepage);
} catch (MalformedURLException e) {
messages.addMessage(new String[] { "doapOptions", "homepage" }, homepage, UserMessages.INVALID_URL);
}
}
// asfext:charter
if (StringUtils.isEmpty(asfExtOptions.getCharter())) {
messages.addMessage(new String[] { "asfExtOptions", "charter" }, null, UserMessages.REQUIRED_BY_ASF);
} else {
DoapUtil.writeElement(writer, asfExtOptions.getXmlnsPrefix(), "charter", asfExtOptions.getCharter());
}
// asfext:chair
@SuppressWarnings("unchecked") List<Developer> developers = new ArrayList<Developer>(project.getDevelopers());
sortContributors(developers);
if (StringUtils.isNotEmpty(asfExtOptions.getChair())) {
DoapUtil.writeStartElement(writer, asfExtOptions.getXmlnsPrefix(), "chair");
DoapUtil.writeStartElement(writer, "foaf", "Person");
DoapUtil.writeStartElement(writer, "foaf", "name");
writer.writeText(asfExtOptions.getChair());
// foaf:name
writer.endElement();
// foaf:Person
writer.endElement();
// asfext:chair
writer.endElement();
} else {
Developer chair = ASFExtOptionsUtil.findChair(developers);
if (chair != null) {
writeContributor(writer, chair, asfExtOptions.getXmlnsPrefix(), "chair");
developers.remove(chair);
} else {
messages.addMessage(new String[] { "asfExtOptions", "chair" }, null, UserMessages.REQUIRED_BY_ASF);
}
}
// asfext:member
if (developers != null && developers.size() > 0) {
List<Developer> pmcMembers = ASFExtOptionsUtil.findPMCMembers(developers);
for (Developer pmcMember : pmcMembers) {
writeContributor(writer, pmcMember, asfExtOptions.getXmlnsPrefix(), "member");
}
}
writeASFImplements(writer);
Map<Object, String> map = asfExtOptions.getExtra();
writeExtra(writer, project, "Extra ASFExt vocabulary.", map, asfExtOptions.getXmlnsPrefix());
}
use of org.apache.maven.model.Developer in project maven-plugins by apache.
the class MavenJDOMWriter method iterateDeveloper.
// -- void iterateDependency(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
* Method iterateDeveloper
*
* @param counter
* @param childTag
* @param parentTag
* @param list
* @param parent
*/
protected void iterateDeveloper(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) {
boolean shouldExist = list != null && list.size() > 0;
Element element = updateElement(counter, parent, parentTag, shouldExist);
if (shouldExist) {
Iterator it = list.iterator();
Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator();
if (!elIt.hasNext()) {
elIt = null;
}
Counter innerCount = new Counter(counter.getDepth() + 1);
while (it.hasNext()) {
Developer value = (Developer) it.next();
Element el;
if (elIt != null && elIt.hasNext()) {
el = (Element) elIt.next();
if (!elIt.hasNext()) {
elIt = null;
}
} else {
el = factory.element(childTag, element.getNamespace());
insertAtPreferredLocation(element, el, innerCount);
}
updateDeveloper(value, childTag, innerCount, el);
innerCount.increaseCount();
}
if (elIt != null) {
while (elIt.hasNext()) {
elIt.next();
elIt.remove();
}
}
}
}
use of org.apache.maven.model.Developer in project buck by facebook.
the class PomIntegrationTest method shouldUseTemplateIfProvided.
@Test
public void shouldUseTemplateIfProvided() throws Exception {
MavenPublishable withoutTemplate = createMavenPublishable("//example:no-template", "example.com:project:1.0.0", null);
Model noTemplate = parse(Pom.generatePomFile(pathResolver, withoutTemplate));
MavenPublishable withTemplate = createMavenPublishable("//example:template", "example.com:project:1.0.0", new FakeSourcePath(TestDataHelper.getTestDataDirectory(getClass()).resolve("poms/template-pom.xml").toString()));
Model templated = parse(Pom.generatePomFile(pathResolver, withTemplate));
// Template sets developers and an example dep. Check that these aren't in the non-templated
// version
assertTrue(noTemplate.getDevelopers().isEmpty());
assertTrue(noTemplate.getDependencies().isEmpty());
// Now check the same fields in the templated version.
Developer seenDev = Iterables.getOnlyElement(templated.getDevelopers());
assertEquals("susan", seenDev.getId());
assertEquals("Susan The Developer", seenDev.getName());
assertEquals(ImmutableList.of("Owner"), seenDev.getRoles());
Dependency seenDep = Iterables.getOnlyElement(templated.getDependencies());
assertEquals("com.google.guava", seenDep.getGroupId());
assertEquals("guava", seenDep.getArtifactId());
assertEquals("19.0", seenDep.getVersion());
}
Aggregations