Search in sources :

Example 6 with IssueManagement

use of org.apache.maven.model.IssueManagement 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 IssueManagement

use of org.apache.maven.model.IssueManagement in project fabric8-maven-plugin by fabric8io.

the class MavenIssueManagementEnricherTest method testMavenIssueManagementAll.

@Test
public void testMavenIssueManagementAll() {
    final MavenProject project = new MavenProject();
    final IssueManagement issueManagement = new IssueManagement();
    issueManagement.setSystem("GitHub");
    issueManagement.setUrl("https://github.com/fabric8io/vertx-maven-plugin/issues/");
    project.setIssueManagement(issueManagement);
    // Setup mock behaviour
    new Expectations() {

        {
            {
                context.getProject();
                result = project;
            }
        }
    };
    MavenIssueManagementEnricher enricher = new MavenIssueManagementEnricher(context);
    Map<String, String> scmAnnotations = enricher.getAnnotations(Kind.DEPLOYMENT_CONFIG);
    assertNotNull(scmAnnotations);
    Assert.assertEquals(2, scmAnnotations.size());
    assertEquals("GitHub", scmAnnotations.get(MavenIssueManagementEnricher.ISSUE_MANAGEMENT_SYSTEM));
    assertEquals("https://github.com/fabric8io/vertx-maven-plugin/issues/", scmAnnotations.get(MavenIssueManagementEnricher.ISSUE_MANAGEMENT_URL));
}
Also used : Expectations(mockit.Expectations) MavenProject(org.apache.maven.project.MavenProject) IssueManagement(org.apache.maven.model.IssueManagement) Test(org.junit.Test)

Example 8 with IssueManagement

use of org.apache.maven.model.IssueManagement in project fabric8-maven-plugin by fabric8io.

the class MavenIssueManagementEnricherTest method testMavenIssueManagementOnlyUrl.

@Test
public void testMavenIssueManagementOnlyUrl() {
    final MavenProject project = new MavenProject();
    final IssueManagement issueManagement = new IssueManagement();
    issueManagement.setUrl("https://github.com/fabric8io/fabric8-maven-plugin/issues/");
    project.setIssueManagement(issueManagement);
    // Setup mock behaviour
    new Expectations() {

        {
            {
                context.getProject();
                result = project;
            }
        }
    };
    MavenIssueManagementEnricher enricher = new MavenIssueManagementEnricher(context);
    Map<String, String> scmAnnotations = enricher.getAnnotations(Kind.DEPLOYMENT_CONFIG);
    assertTrue(scmAnnotations.isEmpty());
}
Also used : Expectations(mockit.Expectations) MavenProject(org.apache.maven.project.MavenProject) IssueManagement(org.apache.maven.model.IssueManagement) Test(org.junit.Test)

Example 9 with IssueManagement

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

the class GitHubDownloaderTestCase method testConfigureAuthenticationWithProblems.

public void testConfigureAuthenticationWithProblems() throws Exception {
    IssueManagement issueManagement = newGitHubIssueManagement();
    GitHubDownloader gitHubDownloader = newGitHubDownloader(issueManagement);
    Settings settings = new Settings();
    Server server = newServer("github-server");
    settings.addServer(server);
    SettingsDecrypter decrypter = mock(SettingsDecrypter.class);
    SettingsDecryptionResult result = mock(SettingsDecryptionResult.class);
    Log log = mock(Log.class);
    when(result.getProblems()).thenReturn(Arrays.<SettingsProblem>asList(new DefaultSettingsProblem("Ups " + server.getId(), Severity.ERROR, null, -1, -1, null)));
    when(result.getServer()).thenReturn(server);
    when(decrypter.decrypt(any(SettingsDecryptionRequest.class))).thenReturn(result);
    gitHubDownloader.configureAuthentication(decrypter, "github-server", settings, log);
    verify(log).error("Ups github-server", null);
    ArgumentCaptor<SettingsDecryptionRequest> argument = ArgumentCaptor.forClass(SettingsDecryptionRequest.class);
    verify(decrypter).decrypt(argument.capture());
    List<Server> servers = ((DefaultSettingsDecryptionRequest) argument.getValue()).getServers();
    assertEquals(1, servers.size());
    assertSame(server, servers.get(0));
}
Also used : DefaultSettingsProblem(org.apache.maven.settings.building.DefaultSettingsProblem) Server(org.apache.maven.settings.Server) SettingsDecrypter(org.apache.maven.settings.crypto.SettingsDecrypter) Log(org.apache.maven.plugin.logging.Log) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) SettingsDecryptionResult(org.apache.maven.settings.crypto.SettingsDecryptionResult) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) SettingsDecryptionRequest(org.apache.maven.settings.crypto.SettingsDecryptionRequest) IssueManagement(org.apache.maven.model.IssueManagement) Settings(org.apache.maven.settings.Settings)

Example 10 with IssueManagement

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

the class GitHubDownloaderTestCase method newGitHubIssueManagement.

private IssueManagement newGitHubIssueManagement() {
    IssueManagement issueManagement = new IssueManagement();
    issueManagement.setSystem("GitHub");
    issueManagement.setUrl("https://github.com/dadoonet/spring-elasticsearch/issues/");
    return issueManagement;
}
Also used : IssueManagement(org.apache.maven.model.IssueManagement)

Aggregations

IssueManagement (org.apache.maven.model.IssueManagement)10 MavenProject (org.apache.maven.project.MavenProject)4 Expectations (mockit.Expectations)3 Test (org.junit.Test)3 Log (org.apache.maven.plugin.logging.Log)2 Server (org.apache.maven.settings.Server)2 Settings (org.apache.maven.settings.Settings)2 DefaultSettingsDecryptionRequest (org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest)2 SettingsDecrypter (org.apache.maven.settings.crypto.SettingsDecrypter)2 SettingsDecryptionResult (org.apache.maven.settings.crypto.SettingsDecryptionResult)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Build (org.apache.maven.model.Build)1 CiManagement (org.apache.maven.model.CiManagement)1 Contributor (org.apache.maven.model.Contributor)1 Dependency (org.apache.maven.model.Dependency)1 DependencyManagement (org.apache.maven.model.DependencyManagement)1