Example usage for org.apache.maven.project MavenProject getRepositories

List of usage examples for org.apache.maven.project MavenProject getRepositories

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getRepositories.

Prototype

public List<Repository> getRepositories() 

Source Link

Usage

From source file:org.wso2.developerstudio.eclipse.artifact.endpoint.ui.wizard.EndpointProjectCreationWizard.java

License:Open Source License

private void addGeneralProjectPlugin(IProject project) throws Exception {
    MavenProject mavenProject;

    File mavenProjectPomLocation = project.getFile("pom.xml").getLocation().toFile();
    if (!mavenProjectPomLocation.exists()) {
        mavenProject = MavenUtils.createMavenProject("org.wso2.carbon." + project.getName(), project.getName(),
                "1.0.0", "pom");
    } else {/*from   w  w  w .ja  va  2 s  .  com*/
        mavenProject = MavenUtils.getMavenProject(mavenProjectPomLocation);
    }

    boolean pluginExists = MavenUtils.checkOldPluginEntry(mavenProject, "org.wso2.maven",
            "wso2-general-project-plugin", ESBMavenConstants.WSO2_GENERAL_PROJECT_VERSION);
    if (pluginExists) {
        return;
    }

    Plugin plugin = MavenUtils.createPluginEntry(mavenProject, "org.wso2.maven", "wso2-general-project-plugin",
            ESBMavenConstants.WSO2_GENERAL_PROJECT_VERSION, true);

    PluginExecution pluginExecution;

    pluginExecution = new PluginExecution();
    pluginExecution.addGoal("pom-gen");
    pluginExecution.setPhase("process-resources");
    pluginExecution.setId("registry");
    plugin.addExecution(pluginExecution);

    Xpp3Dom configurationNode = MavenUtils.createMainConfigurationNode();
    Xpp3Dom artifactLocationNode = MavenUtils.createXpp3Node(configurationNode, "artifactLocation");
    artifactLocationNode.setValue(".");
    Xpp3Dom typeListNode = MavenUtils.createXpp3Node(configurationNode, "typeList");
    typeListNode.setValue("${artifact.types}");
    pluginExecution.setConfiguration(configurationNode);

    Repository repo = new Repository();
    repo.setUrl("http://dist.wso2.org/maven2");
    repo.setId("wso2-maven2-repository-1");

    Repository repo1 = new Repository();
    repo1.setUrl("http://maven.wso2.org/nexus/content/groups/wso2-public/");
    repo1.setId("wso2-nexus-maven2-repository-1");

    if (!mavenProject.getRepositories().contains(repo)) {
        mavenProject.getModel().addRepository(repo);
        mavenProject.getModel().addPluginRepository(repo);
    }

    if (!mavenProject.getRepositories().contains(repo1)) {
        mavenProject.getModel().addRepository(repo1);
        mavenProject.getModel().addPluginRepository(repo1);
    }

    MavenUtils.saveMavenProject(mavenProject, mavenProjectPomLocation);
}

From source file:org.wso2.developerstudio.eclipse.esb.presentation.ui.NewResourceTemplateDialog.java

License:Open Source License

private void addGeneralProjectPlugin(IProject project) throws Exception {
    MavenProject mavenProject;

    File mavenProjectPomLocation = project.getFile("pom.xml").getLocation().toFile();
    if (!mavenProjectPomLocation.exists()) {
        mavenProject = MavenUtils.createMavenProject("org.wso2.carbon", project.getName(), "1.0.0", "pom");
    } else {//from  ww  w  .  j  a v  a 2s  .  com
        mavenProject = MavenUtils.getMavenProject(mavenProjectPomLocation);
    }

    boolean pluginExists = MavenUtils.checkOldPluginEntry(mavenProject, "org.wso2.maven",
            "wso2-general-project-plugin", MavenConstants.WSO2_GENERAL_PROJECT_VERSION);
    if (pluginExists) {
        return;
    }

    mavenProject = MavenUtils.getMavenProject(mavenProjectPomLocation);
    Plugin plugin = MavenUtils.createPluginEntry(mavenProject, "org.wso2.maven", "wso2-general-project-plugin",
            MavenConstants.WSO2_GENERAL_PROJECT_VERSION, true);

    PluginExecution pluginExecution;

    pluginExecution = new PluginExecution();
    pluginExecution.addGoal("pom-gen");
    pluginExecution.setPhase("process-resources");
    pluginExecution.setId("registry");
    plugin.addExecution(pluginExecution);

    Xpp3Dom configurationNode = MavenUtils.createMainConfigurationNode();
    Xpp3Dom artifactLocationNode = MavenUtils.createXpp3Node(configurationNode, "artifactLocation");
    artifactLocationNode.setValue(".");
    Xpp3Dom typeListNode = MavenUtils.createXpp3Node(configurationNode, "typeList");
    typeListNode.setValue("${artifact.types}");
    pluginExecution.setConfiguration(configurationNode);

    Repository repo = new Repository();
    repo.setUrl("http://dist.wso2.org/maven2");
    repo.setId("wso2-maven2-repository-1");

    Repository repo1 = new Repository();
    repo1.setUrl("http://maven.wso2.org/nexus/content/groups/wso2-public/");
    repo1.setId("wso2-nexus-maven2-repository-1");

    if (!mavenProject.getRepositories().contains(repo)) {
        mavenProject.getModel().addRepository(repo);
        mavenProject.getModel().addPluginRepository(repo);
    }

    if (!mavenProject.getRepositories().contains(repo1)) {
        mavenProject.getModel().addRepository(repo1);
        mavenProject.getModel().addPluginRepository(repo1);
    }

    MavenUtils.saveMavenProject(mavenProject, mavenProjectPomLocation);
}

From source file:org.wso2.developerstudio.eclipse.gmf.brs.diagram.custom.provider.NewResourceTemplateDialog.java

License:Open Source License

private void addGeneralProjectPlugin(IProject project) throws Exception {
    MavenProject mavenProject;

    File mavenProjectPomLocation = project.getFile("pom.xml").getLocation().toFile();
    if (!mavenProjectPomLocation.exists()) {
        mavenProject = MavenUtils.createMavenProject("org.wso2.carbon", project.getName(), "1.0.0", "pom");
    } else {/* w w  w .j  a  v a 2 s .c  o m*/
        mavenProject = MavenUtils.getMavenProject(mavenProjectPomLocation);
    }

    boolean pluginExists = MavenUtils.checkOldPluginEntry(mavenProject, "org.wso2.maven",
            "wso2-general-project-plugin", ESBMavenConstants.WSO2_GENERAL_PROJECT_VERSION);
    if (pluginExists) {
        return;
    }

    mavenProject = MavenUtils.getMavenProject(mavenProjectPomLocation);
    Plugin plugin = MavenUtils.createPluginEntry(mavenProject, "org.wso2.maven", "wso2-general-project-plugin",
            ESBMavenConstants.WSO2_GENERAL_PROJECT_VERSION, true);

    PluginExecution pluginExecution;

    pluginExecution = new PluginExecution();
    pluginExecution.addGoal("pom-gen");
    pluginExecution.setPhase("process-resources");
    pluginExecution.setId("registry");
    plugin.addExecution(pluginExecution);

    Xpp3Dom configurationNode = MavenUtils.createMainConfigurationNode();
    Xpp3Dom artifactLocationNode = MavenUtils.createXpp3Node(configurationNode, "artifactLocation");
    artifactLocationNode.setValue(".");
    Xpp3Dom typeListNode = MavenUtils.createXpp3Node(configurationNode, "typeList");
    typeListNode.setValue("${artifact.types}");
    pluginExecution.setConfiguration(configurationNode);

    Repository repo = new Repository();
    repo.setUrl("http://dist.wso2.org/maven2");
    repo.setId("wso2-maven2-repository-1");

    Repository repo1 = new Repository();
    repo1.setUrl("http://maven.wso2.org/nexus/content/groups/wso2-public/");
    repo1.setId("wso2-nexus-maven2-repository-1");

    if (!mavenProject.getRepositories().contains(repo)) {
        mavenProject.getModel().addRepository(repo);
        mavenProject.getModel().addPluginRepository(repo);
    }

    if (!mavenProject.getRepositories().contains(repo1)) {
        mavenProject.getModel().addRepository(repo1);
        mavenProject.getModel().addPluginRepository(repo1);
    }

    MavenUtils.saveMavenProject(mavenProject, mavenProjectPomLocation);
}