Search in sources :

Example 1 with Plugin

use of com.mulesoft.tools.migration.project.model.pom.Plugin in project mule-migration-assistant by mulesoft.

the class ThrottlingWithFileRenameMigrationTestCase method assertPomDeployProperties.

private void assertPomDeployProperties(PomModel pomModel) {
    assertThat(pomModel.getGroupId(), is(GROUP_ID_VALUE));
    Properties pomProperties = pomModel.getProperties();
    assertNotNull(pomProperties);
    assertThat(pomProperties.size(), is(5));
    assertThat(pomProperties.getProperty(EXCHANGE_URL_KEY), is(EXCHANGE_URL_VALUE));
    assertThat(pomProperties.getProperty(MULE_MAVEN_PLUGIN_VERSION_KEY), is(notNullValue()));
    List<Repository> repositoryList = pomModel.getRepositories();
    assertThat(repositoryList.size(), is(1));
    Repository repository = repositoryList.get(0);
    assertThat(repository.getId(), is(EXCHANGE_SERVER_ID));
    assertThat(repository.getName(), is(EXCHANGE_SERVER_NAME));
    assertThat(repository.getUrl(), is(EXCHANGE_SERVER_URL));
    assertThat(repository.areSnapshotsEnabled(), is(true));
    DeploymentRepository deploymentRepository = pomModel.getMavenModelCopy().getDistributionManagement().getRepository();
    assertNotNull(deploymentRepository);
    assertThat(deploymentRepository.getId(), is(EXCHANGE_SERVER_ID));
    assertThat(deploymentRepository.getName(), is(DISTRIBUTION_MANAGEMENT_REPOSITORY_NAME));
    assertThat(deploymentRepository.getUrl(), is(EXCHANGE_SERVER_URL));
    assertThat(deploymentRepository.getLayout(), is(DISTRIBUTION_MANAGEMENT_LAYOUT));
    List<Plugin> pluginList = pomModel.getPlugins();
    assertThat(pluginList.size(), is(2));
    Plugin muleMavenPlugin = pluginList.get(0);
    assertThat(muleMavenPlugin.getGroupId(), is(MULE_MAVEN_PLUGIN_GROUP_ID));
    assertThat(muleMavenPlugin.getArtifactId(), is(MULE_MAVEN_PLUGIN_ARTIFACT_ID));
    assertThat(muleMavenPlugin.getVersion(), is(MULE_MAVEN_PLUGIN_VERSION));
    assertThat(muleMavenPlugin.getExtensions(), is(MULE_MAVEN_PLUGIN_EXTENSIONS));
    Plugin mavenDeployPlugin = pluginList.get(1);
    assertThat(mavenDeployPlugin.getGroupId(), is(MAVEN_DEPLOY_PLUGIN_GROUP_ID));
    assertThat(mavenDeployPlugin.getArtifactId(), is(MAVEN_DEPLOY_PLUGIN_ARTIFACT_ID));
    List<PluginExecution> pluginExecutionList = mavenDeployPlugin.getExecutions();
    assertThat(pluginExecutionList.size(), is(1));
    PluginExecution pluginExecution = pluginExecutionList.get(0);
    assertThat(pluginExecution.getId(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_ID));
    assertThat(pluginExecution.getPhase(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_PHASE));
    assertThat(pluginExecution.getGoals().get(0), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_GOAL));
    Xpp3Dom configuration = pluginExecution.getConfiguration();
    assertThat(configuration.getChild(REPOSITORY_ID_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_REPOSITORY_ID));
    assertThat(configuration.getChild(URL_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_URL));
    assertThat(configuration.getChild(FILE_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_FILE));
    assertThat(configuration.getChild(GENERATE_POM_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_GENERATE_POM));
    assertThat(configuration.getChild(GROUP_ID_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_GROUP_ID));
    assertThat(configuration.getChild(ARTIFACT_ID_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_ARTIFACT_ID));
    assertThat(configuration.getChild(VERSION_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_VERSION));
    assertThat(configuration.getChild(PACKAGING_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_PACKAGING));
    assertThat(configuration.getChild(CLASSIFIER_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_CLASSIFIER));
    List<Repository> pluginRepositoriesList = pomModel.getPluginRepositories();
    assertThat(pluginRepositoriesList.size(), is(1));
    Repository pluginRepository = pluginRepositoriesList.get(0);
    assertThat(pluginRepository.getId(), is(MULE_PLUGIN_CLASSIFIER));
    assertThat(pluginRepository.getName(), is(PLUGIN_REPOSITORY_NAME));
    assertThat(pluginRepository.getUrl(), is(PLUGIN_REPOSITORY_URL));
}
Also used : PluginExecution(com.mulesoft.tools.migration.project.model.pom.PluginExecution) Repository(com.mulesoft.tools.migration.project.model.pom.Repository) DeploymentRepository(org.apache.maven.model.DeploymentRepository) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) DeploymentRepository(org.apache.maven.model.DeploymentRepository) Properties(java.util.Properties) Plugin(com.mulesoft.tools.migration.project.model.pom.Plugin)

Example 2 with Plugin

use of com.mulesoft.tools.migration.project.model.pom.Plugin in project mule-migration-assistant by mulesoft.

the class MUnitPomContribution method execute.

@Override
public void execute(PomModel pomModel, MigrationReport report) throws RuntimeException {
    pomModel.addDependency(new DependencyBuilder().withGroupId("com.mulesoft.munit").withArtifactId("munit-runner").withVersion(targetVersion("munit-maven-plugin")).withClassifier("mule-plugin").withScope("test").build());
    pomModel.addDependency(new DependencyBuilder().withGroupId("com.mulesoft.munit").withArtifactId("munit-tools").withVersion(targetVersion("munit-maven-plugin")).withClassifier("mule-plugin").withScope("test").build());
    if (!getMUnitPlugin(pomModel).isEmpty()) {
        Plugin munitPlugin = getMUnitPlugin(pomModel).get(0);
        munitPlugin.setVersion(targetVersion("munit-maven-plugin"));
    } else {
        pomModel.addPlugin(buildMunitPlugin());
    }
    pomModel.removeProperty(MUNIT_SUPPORT_PROPERTY);
    pomModel.removeProperty(MUNIT_PROPERTY);
    pomModel.addProperty(MUNIT_PROPERTY, targetVersion("munit-maven-plugin"));
}
Also used : DependencyBuilder(com.mulesoft.tools.migration.project.model.pom.Dependency.DependencyBuilder) Plugin(com.mulesoft.tools.migration.project.model.pom.Plugin)

Example 3 with Plugin

use of com.mulesoft.tools.migration.project.model.pom.Plugin in project mule-migration-assistant by mulesoft.

the class UpdateMuleMavenPluginTest method execute.

@Test
public void execute() throws IOException, XmlPullParserException, URISyntaxException {
    Path pomPath = Paths.get(getClass().getResource(POM_WITH_MULE_MAVEN_PLUGIN).toURI());
    model = new PomModel.PomModelBuilder().withPom(pomPath).build();
    updateMuleMavenPlugin.execute(model, report.getReport());
    Plugin muleMavenPlugin = model.getPlugins().stream().filter(p -> p.getArtifactId().equals(MULE_MAVEN_PLUGIN_ARTIFACT_ID)).findFirst().get();
    assertThat("Version is not the expected", muleMavenPlugin.getVersion(), equalTo(MULE_MAVEN_PLUGIN_VERSION));
    Xpp3Dom[] configurationChildren = muleMavenPlugin.getConfiguration().getChildren();
    assertThat("Number of children is not the expected", configurationChildren.length, equalTo(1));
    Xpp3Dom standaloneConfiguration = configurationChildren[0];
    assertThat("Configuration does not have the expected name", standaloneConfiguration.getName(), equalTo("standaloneDeployment"));
    assertThat("Number of children is not the expected", standaloneConfiguration.getChildren().length, equalTo(2));
    assertThat("Child is not the expected", standaloneConfiguration.getChildren()[0].getName(), equalTo("deploymentTimeout"));
    assertThat("Child is not the expected", standaloneConfiguration.getChildren()[1].getName(), equalTo("muleHome"));
}
Also used : Path(java.nio.file.Path) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Plugin(com.mulesoft.tools.migration.project.model.pom.Plugin) Test(org.junit.Test)

Example 4 with Plugin

use of com.mulesoft.tools.migration.project.model.pom.Plugin in project mule-migration-assistant by mulesoft.

the class PolicyDeployPropertiesPomContributionMigrationStep method getMavenDeployPlugin.

private Plugin getMavenDeployPlugin() {
    Plugin plugin = new Plugin();
    plugin.setGroupId(MAVEN_DEPLOY_PLUGIN_GROUP_ID);
    plugin.setArtifactId(MAVEN_DEPLOY_PLUGIN_ARTIFACT_ID);
    PluginExecution pluginExecution = new PluginExecution.PluginExecutionBuilder().withId(MAVEN_DEPLOY_PLUGIN_EXECUTION_ID).withPhase(MAVEN_DEPLOY_PLUGIN_EXECUTION_PHASE).withGoals(Arrays.asList(MAVEN_DEPLOY_PLUGIN_EXECUTION_GOAL)).build();
    pluginExecution.setConfiguration(getConfigurationElement());
    plugin.setExecutions(Arrays.asList(pluginExecution));
    return plugin;
}
Also used : PluginExecution(com.mulesoft.tools.migration.project.model.pom.PluginExecution) Plugin(com.mulesoft.tools.migration.project.model.pom.Plugin)

Example 5 with Plugin

use of com.mulesoft.tools.migration.project.model.pom.Plugin in project mule-migration-assistant by mulesoft.

the class PolicyDeployPropertiesPomContributionMigrationStepTestCase method pomDeployPropertiesTest.

@Test
public void pomDeployPropertiesTest() {
    PomModel pomModel = new PomModel();
    PolicyDeployPropertiesPomContributionMigrationStep step = new PolicyDeployPropertiesPomContributionMigrationStep();
    step.execute(pomModel, mock(MigrationReport.class));
    assertThat(pomModel.getGroupId(), is(GROUP_ID_VALUE));
    Properties pomProperties = pomModel.getProperties();
    assertNotNull(pomProperties);
    assertThat(pomProperties.size(), is(2));
    assertThat(pomProperties.getProperty(EXCHANGE_URL_KEY), is(EXCHANGE_URL_VALUE));
    assertThat(pomProperties.getProperty(MULE_MAVEN_PLUGIN_VERSION_KEY), is(notNullValue()));
    List<Repository> repositoryList = pomModel.getRepositories();
    assertThat(repositoryList.size(), is(1));
    Repository repository = repositoryList.get(0);
    assertThat(repository.getId(), is(EXCHANGE_SERVER_ID));
    assertThat(repository.getName(), is(EXCHANGE_SERVER_NAME));
    assertThat(repository.getUrl(), is(EXCHANGE_SERVER_URL));
    assertThat(repository.areSnapshotsEnabled(), is(true));
    DeploymentRepository deploymentRepository = pomModel.getMavenModelCopy().getDistributionManagement().getRepository();
    assertNotNull(deploymentRepository);
    assertThat(deploymentRepository.getId(), is(EXCHANGE_SERVER_ID));
    assertThat(deploymentRepository.getName(), is(DISTRIBUTION_MANAGEMENT_REPOSITORY_NAME));
    assertThat(deploymentRepository.getUrl(), is(EXCHANGE_SERVER_URL));
    assertThat(deploymentRepository.getLayout(), is(DISTRIBUTION_MANAGEMENT_LAYOUT));
    List<Plugin> pluginList = pomModel.getPlugins();
    assertThat(pluginList.size(), is(2));
    Plugin muleMavenPlugin = pluginList.get(0);
    assertThat(muleMavenPlugin.getGroupId(), is(MULE_MAVEN_PLUGIN_GROUP_ID));
    assertThat(muleMavenPlugin.getArtifactId(), is(MULE_MAVEN_PLUGIN_ARTIFACT_ID));
    assertThat(muleMavenPlugin.getVersion(), is(MULE_MAVEN_PLUGIN_VERSION));
    assertThat(muleMavenPlugin.getExtensions(), is(MULE_MAVEN_PLUGIN_EXTENSIONS));
    Plugin mavenDeployPlugin = pluginList.get(1);
    assertThat(mavenDeployPlugin.getGroupId(), is(MAVEN_DEPLOY_PLUGIN_GROUP_ID));
    assertThat(mavenDeployPlugin.getArtifactId(), is(MAVEN_DEPLOY_PLUGIN_ARTIFACT_ID));
    List<PluginExecution> pluginExecutionList = mavenDeployPlugin.getExecutions();
    assertThat(pluginExecutionList.size(), is(1));
    PluginExecution pluginExecution = pluginExecutionList.get(0);
    assertThat(pluginExecution.getId(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_ID));
    assertThat(pluginExecution.getPhase(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_PHASE));
    assertThat(pluginExecution.getGoals().get(0), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_GOAL));
    Xpp3Dom configuration = pluginExecution.getConfiguration();
    assertThat(configuration.getChild(REPOSITORY_ID_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_REPOSITORY_ID));
    assertThat(configuration.getChild(URL_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_URL));
    assertThat(configuration.getChild(FILE_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_FILE));
    assertThat(configuration.getChild(GENERATE_POM_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_GENERATE_POM));
    assertThat(configuration.getChild(GROUP_ID_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_GROUP_ID));
    assertThat(configuration.getChild(ARTIFACT_ID_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_ARTIFACT_ID));
    assertThat(configuration.getChild(VERSION_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_VERSION));
    assertThat(configuration.getChild(PACKAGING_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_PACKAGING));
    assertThat(configuration.getChild(CLASSIFIER_KEY).getValue(), is(MAVEN_DEPLOY_PLUGIN_EXECUTION_CLASSIFIER));
    List<Repository> pluginRepositoriesList = pomModel.getPluginRepositories();
    assertThat(pluginRepositoriesList.size(), is(1));
    Repository pluginRepository = pluginRepositoriesList.get(0);
    assertThat(pluginRepository.getId(), is(MULE_PLUGIN_CLASSIFIER));
    assertThat(pluginRepository.getName(), is(PLUGIN_REPOSITORY_NAME));
    assertThat(pluginRepository.getUrl(), is(PLUGIN_REPOSITORY_URL));
}
Also used : PluginExecution(com.mulesoft.tools.migration.project.model.pom.PluginExecution) Repository(com.mulesoft.tools.migration.project.model.pom.Repository) DeploymentRepository(org.apache.maven.model.DeploymentRepository) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) PolicyDeployPropertiesPomContributionMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.utils.PolicyDeployPropertiesPomContributionMigrationStep) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) DeploymentRepository(org.apache.maven.model.DeploymentRepository) Properties(java.util.Properties) Plugin(com.mulesoft.tools.migration.project.model.pom.Plugin) Test(org.junit.Test)

Aggregations

Plugin (com.mulesoft.tools.migration.project.model.pom.Plugin)6 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)4 PluginExecution (com.mulesoft.tools.migration.project.model.pom.PluginExecution)3 PomModel (com.mulesoft.tools.migration.project.model.pom.PomModel)3 Repository (com.mulesoft.tools.migration.project.model.pom.Repository)2 MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)2 Properties (java.util.Properties)2 DeploymentRepository (org.apache.maven.model.DeploymentRepository)2 Test (org.junit.Test)2 PolicyDeployPropertiesPomContributionMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.utils.PolicyDeployPropertiesPomContributionMigrationStep)1 DependencyBuilder (com.mulesoft.tools.migration.project.model.pom.Dependency.DependencyBuilder)1 MULE_APPLICATION_3_PACKAGING_TYPE (com.mulesoft.tools.migration.project.model.pom.PomModelUtils.MULE_APPLICATION_3_PACKAGING_TYPE)1 MULE_APPLICATION_4_PACKAGING_TYPE (com.mulesoft.tools.migration.project.model.pom.PomModelUtils.MULE_APPLICATION_4_PACKAGING_TYPE)1 MULE_MAVEN_PLUGIN_ARTIFACT_ID (com.mulesoft.tools.migration.project.model.pom.PomModelUtils.MULE_MAVEN_PLUGIN_ARTIFACT_ID)1 MULE_MAVEN_PLUGIN_VERSION (com.mulesoft.tools.migration.project.model.pom.PomModelUtils.MULE_MAVEN_PLUGIN_VERSION)1 PomModelUtils.buildMule4MuleMavenPluginConfiguration (com.mulesoft.tools.migration.project.model.pom.PomModelUtils.buildMule4MuleMavenPluginConfiguration)1 PomContribution (com.mulesoft.tools.migration.step.category.PomContribution)1 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 OptionalInt (java.util.OptionalInt)1