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);
}
}
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);
}
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());
}
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());
}
Aggregations