Search in sources :

Example 6 with Developer

use of org.apache.maven.model.Developer in project buck by facebook.

the class Pom method merge.

private Model merge(Model first, @Nullable Model second) {
    if (second == null) {
        return first;
    }
    Model model = first.clone();
    //---- Values from ModelBase
    List<String> modules = second.getModules();
    if (modules != null) {
        for (String module : modules) {
            model.addModule(module);
        }
    }
    DistributionManagement distributionManagement = second.getDistributionManagement();
    if (distributionManagement != null) {
        model.setDistributionManagement(distributionManagement);
    }
    Properties properties = second.getProperties();
    if (properties != null) {
        for (Map.Entry<Object, Object> entry : properties.entrySet()) {
            model.addProperty((String) entry.getKey(), (String) entry.getValue());
        }
    }
    DependencyManagement dependencyManagement = second.getDependencyManagement();
    if (dependencyManagement != null) {
        model.setDependencyManagement(dependencyManagement);
    }
    List<Dependency> dependencies = second.getDependencies();
    if (dependencies != null) {
        for (Dependency dependency : dependencies) {
            model.addDependency(dependency);
        }
    }
    List<Repository> repositories = second.getRepositories();
    if (repositories != null) {
        for (Repository repository : repositories) {
            model.addRepository(repository);
        }
    }
    List<Repository> pluginRepositories = second.getPluginRepositories();
    if (pluginRepositories != null) {
        for (Repository pluginRepository : pluginRepositories) {
            model.addPluginRepository(pluginRepository);
        }
    }
    // Ignore reports, reporting, and locations
    //----- From Model
    Parent parent = second.getParent();
    if (parent != null) {
        model.setParent(parent);
    }
    Organization organization = second.getOrganization();
    if (organization != null) {
        model.setOrganization(organization);
    }
    List<License> licenses = second.getLicenses();
    Set<String> currentLicenseUrls = new HashSet<>();
    if (model.getLicenses() != null) {
        for (License license : model.getLicenses()) {
            currentLicenseUrls.add(license.getUrl());
        }
    }
    if (licenses != null) {
        for (License license : licenses) {
            if (!currentLicenseUrls.contains(license.getUrl())) {
                model.addLicense(license);
                currentLicenseUrls.add(license.getUrl());
            }
        }
    }
    List<Developer> developers = second.getDevelopers();
    Set<String> currentDevelopers = new HashSet<>();
    if (model.getDevelopers() != null) {
        for (Developer developer : model.getDevelopers()) {
            currentDevelopers.add(developer.getName());
        }
    }
    if (developers != null) {
        for (Developer developer : developers) {
            if (!currentDevelopers.contains(developer.getName())) {
                model.addDeveloper(developer);
                currentDevelopers.add(developer.getName());
            }
        }
    }
    List<Contributor> contributors = second.getContributors();
    Set<String> currentContributors = new HashSet<>();
    if (model.getContributors() != null) {
        for (Contributor contributor : model.getContributors()) {
            currentDevelopers.add(contributor.getName());
        }
    }
    if (contributors != null) {
        for (Contributor contributor : contributors) {
            if (!currentContributors.contains(contributor.getName())) {
                model.addContributor(contributor);
                currentContributors.add(contributor.getName());
            }
        }
    }
    List<MailingList> mailingLists = second.getMailingLists();
    if (mailingLists != null) {
        for (MailingList mailingList : mailingLists) {
            model.addMailingList(mailingList);
        }
    }
    Prerequisites prerequisites = second.getPrerequisites();
    if (prerequisites != null) {
        model.setPrerequisites(prerequisites);
    }
    Scm scm = second.getScm();
    if (scm != null) {
        model.setScm(scm);
    }
    String url = second.getUrl();
    if (url != null) {
        model.setUrl(url);
    }
    String description = second.getDescription();
    if (description != null) {
        model.setDescription(description);
    }
    IssueManagement issueManagement = second.getIssueManagement();
    if (issueManagement != null) {
        model.setIssueManagement(issueManagement);
    }
    CiManagement ciManagement = second.getCiManagement();
    if (ciManagement != null) {
        model.setCiManagement(ciManagement);
    }
    Build build = second.getBuild();
    if (build != null) {
        model.setBuild(build);
    }
    List<Profile> profiles = second.getProfiles();
    Set<String> currentProfileIds = new HashSet<>();
    if (model.getProfiles() != null) {
        for (Profile profile : model.getProfiles()) {
            currentProfileIds.add(profile.getId());
        }
    }
    if (profiles != null) {
        for (Profile profile : profiles) {
            if (!currentProfileIds.contains(profile.getId())) {
                model.addProfile(profile);
                currentProfileIds.add(profile.getId());
            }
        }
    }
    return model;
}
Also used : Organization(org.apache.maven.model.Organization) Parent(org.apache.maven.model.Parent) License(org.apache.maven.model.License) MailingList(org.apache.maven.model.MailingList) Developer(org.apache.maven.model.Developer) Contributor(org.apache.maven.model.Contributor) Properties(java.util.Properties) Profile(org.apache.maven.model.Profile) Prerequisites(org.apache.maven.model.Prerequisites) Build(org.apache.maven.model.Build) DependencyManagement(org.apache.maven.model.DependencyManagement) IssueManagement(org.apache.maven.model.IssueManagement) HashSet(java.util.HashSet) Dependency(org.apache.maven.model.Dependency) Repository(org.apache.maven.model.Repository) Model(org.apache.maven.model.Model) CiManagement(org.apache.maven.model.CiManagement) DistributionManagement(org.apache.maven.model.DistributionManagement) Scm(org.apache.maven.model.Scm) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 7 with Developer

use of org.apache.maven.model.Developer in project maven-plugins by apache.

the class DoapUtilTest method testDevelopersOrContributorsByDoapRoles.

/**
     * Test method for:
     * {@link DoapUtil#getContributorsWithDeveloperRole(I18N, List)}
     * {@link DoapUtil#getContributorsWithDocumenterRole(I18N, List)}
     * {@link DoapUtil#getContributorsWithHelperRole(I18N, List)}
     * {@link DoapUtil#getContributorsWithMaintainerRole(I18N, List)}
     * {@link DoapUtil#getContributorsWithTesterRole(I18N, List)}
     * {@link DoapUtil#getContributorsWithTranslatorRole(I18N, List)}
     * {@link DoapUtil#getContributorsWithUnknownRole(I18N, List)}
     *
     * @throws Exception if any
     */
public void testDevelopersOrContributorsByDoapRoles() throws Exception {
    I18N i18n = (I18N) getContainer().lookup(I18N.ROLE);
    assertNotNull(i18n);
    assertNotNull(i18n.getBundle());
    List<Contributor> developersOrContributors = new ArrayList<Contributor>();
    // One role
    Developer dev = new Developer();
    dev.setId("dev1");
    dev.addRole("maintainer");
    developersOrContributors.add(dev);
    assertTrue(DoapUtil.getContributorsWithDeveloperRole(i18n, developersOrContributors).isEmpty());
    assertTrue(DoapUtil.getContributorsWithDocumenterRole(i18n, developersOrContributors).isEmpty());
    assertTrue(DoapUtil.getContributorsWithHelperRole(i18n, developersOrContributors).isEmpty());
    assertFalse(DoapUtil.getContributorsWithMaintainerRole(i18n, developersOrContributors).isEmpty());
    assertTrue(DoapUtil.getContributorsWithTesterRole(i18n, developersOrContributors).isEmpty());
    assertTrue(DoapUtil.getContributorsWithTranslatorRole(i18n, developersOrContributors).isEmpty());
    assertTrue(DoapUtil.getContributorsWithUnknownRole(i18n, developersOrContributors).isEmpty());
    // Several roles
    developersOrContributors.clear();
    dev = new Developer();
    dev.setId("dev1");
    dev.addRole(" MAINTAINER");
    dev.addRole("tesTER ");
    dev.addRole("blabla");
    dev.addRole("translato r");
    developersOrContributors.add(dev);
    assertTrue(DoapUtil.getContributorsWithDeveloperRole(i18n, developersOrContributors).isEmpty());
    assertTrue(DoapUtil.getContributorsWithDocumenterRole(i18n, developersOrContributors).isEmpty());
    assertTrue(DoapUtil.getContributorsWithHelperRole(i18n, developersOrContributors).isEmpty());
    assertFalse(DoapUtil.getContributorsWithMaintainerRole(i18n, developersOrContributors).isEmpty());
    assertFalse(DoapUtil.getContributorsWithTesterRole(i18n, developersOrContributors).isEmpty());
    assertTrue(DoapUtil.getContributorsWithTranslatorRole(i18n, developersOrContributors).isEmpty());
    assertFalse(DoapUtil.getContributorsWithUnknownRole(i18n, developersOrContributors).isEmpty());
    // Skip emeritus role
    developersOrContributors.clear();
    dev = new Developer();
    dev.setId("dev1");
    dev.addRole("maintainer");
    dev.addRole("unknown");
    developersOrContributors.add(dev);
    int sizeBeforeEmeritus = DoapUtil.getContributorsWithUnknownRole(i18n, developersOrContributors).size();
    dev.addRole(" Emeritus");
    assertTrue(DoapUtil.getContributorsWithUnknownRole(i18n, developersOrContributors).size() == sizeBeforeEmeritus);
}
Also used : ArrayList(java.util.ArrayList) Contributor(org.apache.maven.model.Contributor) Developer(org.apache.maven.model.Developer) I18N(org.codehaus.plexus.i18n.I18N)

Example 8 with Developer

use of org.apache.maven.model.Developer in project maven-plugins by apache.

the class ChangeLogReport method initializeDeveloperMaps.

/**
     * Creates maps of the project developers by developer Id and developer Name
     * for quick lookups.
     */
private void initializeDeveloperMaps() {
    developersById = new HashMap<String, Developer>();
    developersByName = new HashMap<String, Developer>();
    if (developers != null) {
        for (Developer developer : developers) {
            developersById.put(developer.getId(), developer);
            developersByName.put(developer.getName(), developer);
        }
    }
}
Also used : Developer(org.apache.maven.model.Developer)

Example 9 with Developer

use of org.apache.maven.model.Developer in project maven-plugins by apache.

the class DocumentModelBuilder method getAuthors.

/**
     * Wrap the list of project {@link Developer} to a list of {@link DocumentAuthor}.
     *
     * @param project the MavenProject to extract the authors from.
     * @return a list of DocumentAuthors from the project developers.
     * Returns null if project is null or contains no developers.
     */
private static List<DocumentAuthor> getAuthors(MavenProject project) {
    if (project == null || project.getDevelopers() == null) {
        return null;
    }
    final List<DocumentAuthor> ret = new ArrayList<DocumentAuthor>(4);
    for (Object o : project.getDevelopers()) {
        final Developer developer = (Developer) o;
        final DocumentAuthor author = new DocumentAuthor();
        author.setName(developer.getName());
        author.setEmail(developer.getEmail());
        author.setCompanyName(developer.getOrganization());
        StringBuilder roles = null;
        for (final String role : developer.getRoles()) {
            if (roles == null) {
                roles = new StringBuilder(32);
            } else {
                roles.append(',').append(' ');
            }
            roles.append(role);
        }
        if (roles != null) {
            author.setPosition(roles.toString());
        }
        ret.add(author);
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) Developer(org.apache.maven.model.Developer) DocumentAuthor(org.apache.maven.doxia.document.DocumentAuthor)

Aggregations

Developer (org.apache.maven.model.Developer)9 ArrayList (java.util.ArrayList)4 Contributor (org.apache.maven.model.Contributor)2 Dependency (org.apache.maven.model.Dependency)2 License (org.apache.maven.model.License)2 Model (org.apache.maven.model.Model)2 MavenPublishable (com.facebook.buck.jvm.java.MavenPublishable)1 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Properties (java.util.Properties)1 DocumentAuthor (org.apache.maven.doxia.document.DocumentAuthor)1 Build (org.apache.maven.model.Build)1 CiManagement (org.apache.maven.model.CiManagement)1 DependencyManagement (org.apache.maven.model.DependencyManagement)1 DistributionManagement (org.apache.maven.model.DistributionManagement)1