Search in sources :

Example 6 with Prompter

use of org.codehaus.plexus.components.interactivity.Prompter in project unleash-maven-plugin by shillner.

the class CalculateVersions method execute.

@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
    this.log.info("Calculating required versions for all modules.");
    for (MavenProject project : this.reactorProjects) {
        this.log.info("\tVersions of module " + ProjectToString.EXCLUDE_VERSION.apply(project) + ":");
        ArtifactCoordinates preReleaseCoordinates = this.metadata.getArtifactCoordinatesByPhase(project.getGroupId(), project.getArtifactId()).get(ReleasePhase.PRE_RELEASE);
        this.log.info("\t\t" + ReleasePhase.PRE_RELEASE + " = " + preReleaseCoordinates.getVersion());
        Optional<Prompter> prompterToUse = this.settings.isInteractiveMode() ? Optional.of(this.prompter) : Optional.<Prompter>absent();
        String releaseVersion = calculateReleaseVersion(project.getVersion(), prompterToUse);
        ArtifactCoordinates releaseCoordinates = new ArtifactCoordinates(project.getGroupId(), project.getArtifactId(), releaseVersion, PomUtil.ARTIFACT_TYPE_POM);
        this.metadata.addArtifactCoordinates(releaseCoordinates, ReleasePhase.RELEASE);
        this.log.info("\t\t" + ReleasePhase.RELEASE + " = " + releaseVersion);
        String nextDevVersion = calculateDevelopmentVersion(project.getVersion(), prompterToUse);
        ArtifactCoordinates postReleaseCoordinates = new ArtifactCoordinates(project.getGroupId(), project.getArtifactId(), nextDevVersion, PomUtil.ARTIFACT_TYPE_POM);
        this.metadata.addArtifactCoordinates(postReleaseCoordinates, ReleasePhase.POST_RELEASE);
        this.log.info("\t\t" + ReleasePhase.POST_RELEASE + " = " + nextDevVersion);
    }
}
Also used : Prompter(org.codehaus.plexus.components.interactivity.Prompter) MavenProject(org.apache.maven.project.MavenProject) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString)

Example 7 with Prompter

use of org.codehaus.plexus.components.interactivity.Prompter in project maven-archetype by apache.

the class DefaultArchetypeGenerationQueryerTest method testPropertyRegexValidationRetry.

public void testPropertyRegexValidationRetry() throws PrompterException {
    MockControl control = MockControl.createControl(Prompter.class);
    Prompter prompter = (Prompter) control.getMock();
    prompter.prompt("");
    control.setMatcher(createArgumentMatcher());
    control.setReturnValue("invalid-answer");
    queryer.setPrompter(prompter);
    prompter.prompt("");
    control.setReturnValue("valid-answer");
    queryer.setPrompter(prompter);
    control.replay();
    String value = queryer.getPropertyValue("custom-property", null, Pattern.compile("^valid-.*"));
    assertEquals("valid-answer", value);
}
Also used : Prompter(org.codehaus.plexus.components.interactivity.Prompter) MockControl(org.easymock.MockControl)

Example 8 with Prompter

use of org.codehaus.plexus.components.interactivity.Prompter in project maven-archetype by apache.

the class DefaultArchetypeSelectionQueryerTest method testDefaultArchetypeInMapDefaultSelection.

public void testDefaultArchetypeInMapDefaultSelection() throws PrompterException {
    Map<String, List<Archetype>> map = createDefaultArchetypeCatalog();
    MockControl control = MockControl.createControl(Prompter.class);
    Prompter prompter = (Prompter) control.getMock();
    prompter.prompt("", "2");
    control.setMatcher(createArgumentMatcher());
    control.setReturnValue("2");
    queryer.setPrompter(prompter);
    control.replay();
    ArchetypeDefinition defaultDefinition = new ArchetypeDefinition();
    defaultDefinition.setGroupId("default-groupId");
    defaultDefinition.setArtifactId("default-artifactId");
    defaultDefinition.setVersion("default-version");
    Archetype archetype = queryer.selectArchetype(map, defaultDefinition);
    control.verify();
    assertEquals("default-groupId", archetype.getGroupId());
    assertEquals("default-artifactId", archetype.getArtifactId());
    assertEquals("default-version", archetype.getVersion());
}
Also used : Prompter(org.codehaus.plexus.components.interactivity.Prompter) ArchetypeDefinition(org.apache.maven.archetype.ui.ArchetypeDefinition) MockControl(org.easymock.MockControl) Archetype(org.apache.maven.archetype.catalog.Archetype) List(java.util.List) ArrayList(java.util.ArrayList)

Example 9 with Prompter

use of org.codehaus.plexus.components.interactivity.Prompter in project maven-archetype by apache.

the class DefaultArchetypeSelectionQueryerTest method testDefaultArchetypeNotInMap.

public void testDefaultArchetypeNotInMap() throws PrompterException {
    Map<String, List<Archetype>> map = createDefaultArchetypeCatalog();
    MockControl control = MockControl.createControl(Prompter.class);
    Prompter prompter = (Prompter) control.getMock();
    prompter.prompt("");
    control.setMatcher(createArgumentMatcher());
    control.setReturnValue("1");
    queryer.setPrompter(prompter);
    control.replay();
    ArchetypeDefinition defaultDefinition = new ArchetypeDefinition();
    defaultDefinition.setGroupId("invalid-groupId");
    defaultDefinition.setArtifactId("invalid-artifactId");
    defaultDefinition.setVersion("invalid-version");
    Archetype archetype = queryer.selectArchetype(map, defaultDefinition);
    control.verify();
    assertEquals("set-groupId", archetype.getGroupId());
    assertEquals("set-artifactId", archetype.getArtifactId());
    assertEquals("set-version", archetype.getVersion());
}
Also used : Prompter(org.codehaus.plexus.components.interactivity.Prompter) ArchetypeDefinition(org.apache.maven.archetype.ui.ArchetypeDefinition) MockControl(org.easymock.MockControl) Archetype(org.apache.maven.archetype.catalog.Archetype) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

Prompter (org.codehaus.plexus.components.interactivity.Prompter)9 MockControl (org.easymock.MockControl)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Archetype (org.apache.maven.archetype.catalog.Archetype)5 ArchetypeDefinition (org.apache.maven.archetype.ui.ArchetypeDefinition)3 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)2 Test (org.junit.Test)2 ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)1 ProjectToString (com.itemis.maven.plugins.unleash.util.functions.ProjectToString)1 MavenProject (org.apache.maven.project.MavenProject)1