• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PrompterException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.codehaus.plexus.components.interactivity.PrompterException的典型用法代码示例。如果您正苦于以下问题:Java PrompterException类的具体用法?Java PrompterException怎么用?Java PrompterException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PrompterException类属于org.codehaus.plexus.components.interactivity包,在下文中一共展示了PrompterException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: promptForContainer

import org.codehaus.plexus.components.interactivity.PrompterException; //导入依赖的package包/类
/**
 * Lists services and prompts the user to choose one
 */
private static Container promptForContainer(List<Container> containers, Prompter prompter, Log log) throws MojoExecutionException {

	log.info("");
	log.info("SERVICE");
	log.info("");
	Map<Integer, Container> options = new HashMap<>();
	Integer i = 1;

	for (Container container : containers) {
		options.put(i, container);
		log.info(String.format("%2d", i) + " : " + container.getServiceName());
		i++;
	}
	log.info("");
	try {
		String prompt = prompter.prompt("Choose a service");
		return options.get(Integer.valueOf(prompt));
	}
	catch (PrompterException e) {
		throw new MojoExecutionException("Prompter error" + e.getMessage());
	}
}
 
开发者ID:swissquote,项目名称:carnotzet,代码行数:26,代码来源:Shell.java


示例2: getReleaseVersion

import org.codehaus.plexus.components.interactivity.PrompterException; //导入依赖的package包/类
/**
 * Calculates the release version depending on several strategies such as prompting the user or applying a default
 * version.
 *
 * @param version the initial version from which the release version shall be derived.
 * @param defaultReleaseVersion the default release version that should be taken into account.
 * @param prompter a {@link Prompter} for prompting the user for a release version.
 * @return the release version derived after applying several calculation strategies.
 */
public static String getReleaseVersion(String version, Optional<String> defaultReleaseVersion,
    Optional<Prompter> prompter) {
  if (defaultReleaseVersion.isPresent()) {
    return defaultReleaseVersion.get();
  }

  String releaseVersion = MavenVersionUtil.calculateReleaseVersion(version);
  if (prompter.isPresent()) {
    try {
      releaseVersion = prompter.get().prompt("Please specify the release version", releaseVersion);
    } catch (PrompterException e) {
      // in case of an error the calculated version is used
    }
  }

  return releaseVersion;
}
 
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:27,代码来源:ReleaseUtil.java


示例3: getNextDevelopmentVersion

import org.codehaus.plexus.components.interactivity.PrompterException; //导入依赖的package包/类
/**
 * Calculates the next development version depending on several strategies such as prompting the user or applying a
 * default
 * version.
 *
 * @param version the initial version from which the development version shall be derived.
 * @param defaultDevelopmentVersion the default development version that should be taken into account.
 * @param prompter a {@link Prompter} for prompting the user for a version.
 * @param upgradeStrategy the strategy which determines the version segment to increase.
 * @return the development version derived after applying several calculation strategies.
 */
public static String getNextDevelopmentVersion(String version, Optional<String> defaultDevelopmentVersion,
    Optional<Prompter> prompter, VersionUpgradeStrategy upgradeStrategy) {
  if (defaultDevelopmentVersion.isPresent()) {
    return defaultDevelopmentVersion.get();
  }

  String devVersion = MavenVersionUtil.calculateNextSnapshotVersion(version, upgradeStrategy);
  if (prompter.isPresent()) {
    try {
      devVersion = prompter.get().prompt("Please specify the next development version", devVersion);
    } catch (PrompterException e) {
      // in case of an error the calculated version is used
    }
  }

  return devVersion;
}
 
开发者ID:shillner,项目名称:unleash-maven-plugin,代码行数:29,代码来源:ReleaseUtil.java


示例4: getNewVersion

import org.codehaus.plexus.components.interactivity.PrompterException; //导入依赖的package包/类
@Override
protected String getNewVersion() throws MojoExecutionException {
    if ( StringUtils.isEmpty( newVersion ) )
    {
        if ( settings.isInteractiveMode() )
        {
            try
            {
                newVersion =
                        prompter.prompt( "Enter the new version to set", getProject().getOriginalModel().getVersion() );
            }
            catch ( PrompterException e )
            {
                throw new MojoExecutionException( e.getMessage(), e );
            }
        }
        else
        {
            throw new MojoExecutionException( "You must specify the new version, either by using the newVersion "
                    + "property (that is -DnewVersion=... on the command line) or run in interactive mode" );
        }
    }

    return newVersion;
}
 
开发者ID:petr-ujezdsky,项目名称:versions-maven-plugin-svn-clone,代码行数:26,代码来源:SetMojo.java


示例5: askForPermissionAndComment

import org.codehaus.plexus.components.interactivity.PrompterException; //导入依赖的package包/类
/**
 * @return {@code null} if sending statistics should be aborted
 */
private boolean askForPermissionAndComment(DeadCodeStatistics deadCodeStatistics, SystemProperties systemProperties) {
    final Logger logger = getLogger();
    StringBuilder buffy = listStatistics(deadCodeStatistics, systemProperties);
    try {
        buffy.append("\nMay I report those usage statistics (via HTTPS)?");
        String answer = prompter.prompt(buffy.toString(), asList("Y", "N"), "Y");
        if ("N".equals(answer)) {
            logger.info("Sending usage statistics is aborted.");
            logger.info("You may configure deadcode4j to permanently disable sending usage statistics.");
            return false;
        }
        if (deadCodeStatistics.getUsageStatisticsComment() == null) {
            deadCodeStatistics.setUsageStatisticsComment(prompter.prompt(
                    "Awesome! Would you like to state a testimonial or give a comment? Here you can"));
        }
        return true;
    } catch (PrompterException e) {
        logger.debug("Prompter failed!", e);
        logger.info("Failed to interact with the user!");
        return false;
    }
}
 
开发者ID:ImmobilienScout24,项目名称:deadcode4j,代码行数:26,代码来源:UsageStatisticsManager.java


示例6: updateCappDependencies

import org.codehaus.plexus.components.interactivity.PrompterException; //导入依赖的package包/类
private boolean updateCappDependencies() {
	for (MavenProject cappMavenProject : cappMavenProjects) {
		log.info("About to update: " + cappMavenProject.getFile().getAbsolutePath());
		log.warn("All dependencies will be converted to system scope");

		// If updateDependencies parameter is provided in command line
		if (updateDependencies) {
			if (!updatePomFile(cappMavenProject)) {
				return false;
			}
		} else {
			// Ask user consent to proceed
			String userInput = "";
			do {
				try {
					userInput = prompter.prompt(USER_CONSENT_PROMPTER);
				} catch (PrompterException e) {
					log.error("Failed to get user input while updating dependencies", e);
					return false;
				}
			} while (!(USER_CONSENT_DEFAULT.equalsIgnoreCase(userInput)
					|| USER_CONSENT_YES.equalsIgnoreCase(userInput) || USER_CONSENT_NO.equalsIgnoreCase(userInput)));

			// Empty input is considered as default (Y)
			if (USER_CONSENT_NO.equalsIgnoreCase(userInput)) {
				log.info("Skipped updating file: " + cappMavenProject.getFile().getAbsolutePath());
			} else {
				if (!updatePomFile(cappMavenProject)) {
					return false;
				}
			}
		}
	}
	return true;
}
 
开发者ID:wso2,项目名称:maven-tools,代码行数:36,代码来源:PackagePrepareSystemScopeMojo.java


示例7: updateCappDependencies

import org.codehaus.plexus.components.interactivity.PrompterException; //导入依赖的package包/类
private boolean updateCappDependencies() {
	for (MavenProject cappMavenProject : cappMavenProjects) {
		log.info("About to update: " + cappMavenProject.getFile().getAbsolutePath());
		log.warn("All dependencies will be converted to default scope");

		// If updateDependencies parameter is provided in command line
		if (updateDependencies) {
			if (!updatePomFile(cappMavenProject)) {
				return false;
			}
		} else {
			// Ask user consent to proceed
			String userInput = "";
			do {
				try {
					userInput = prompter.prompt(USER_CONSENT_PROMPTER);
				} catch (PrompterException e) {
					log.error("Failed to get user input while updating dependencies", e);
					return false;
				}
			} while (!(USER_CONSENT_DEFAULT.equalsIgnoreCase(userInput)
					|| USER_CONSENT_YES.equalsIgnoreCase(userInput) || USER_CONSENT_NO.equalsIgnoreCase(userInput)));

			// Empty input is considered as default (Y)
			if (USER_CONSENT_NO.equalsIgnoreCase(userInput)) {
				log.info("Skipped updating file: " + cappMavenProject.getFile().getAbsolutePath());
			} else {
				if (!updatePomFile(cappMavenProject)) {
					return false;
				}
			}
		}
	}
	return true;
}
 
开发者ID:wso2,项目名称:maven-tools,代码行数:36,代码来源:PackagePrepareDefaultScopeMojo.java


示例8: promptBranchName

import org.codehaus.plexus.components.interactivity.PrompterException; //导入依赖的package包/类
private String promptBranchName()
        throws MojoFailureException, CommandLineException {
    // git for-each-ref --format='%(refname:short)' refs/heads/feature/*
    final String featureBranches = gitFindBranches(
            gitFlowConfig.getFeatureBranchPrefix(), false);

    if (StringUtils.isBlank(featureBranches)) {
        throw new MojoFailureException("There are no feature branches.");
    }

    final String[] branches = featureBranches.split("\\r?\\n");

    List<String> numberedList = new ArrayList<String>();
    StringBuilder str = new StringBuilder("Feature branches:").append(LS);
    for (int i = 0; i < branches.length; i++) {
        str.append((i + 1) + ". " + branches[i] + LS);
        numberedList.add(String.valueOf(i + 1));
    }
    str.append("Choose feature branch to finish");

    String featureNumber = null;
    try {
        while (StringUtils.isBlank(featureNumber)) {
            featureNumber = prompter.prompt(str.toString(), numberedList);
        }
    } catch (PrompterException e) {
        throw new MojoFailureException("feature-finish", e);
    }

    String featureBranchName = null;
    if (featureNumber != null) {
        int num = Integer.parseInt(featureNumber);
        featureBranchName = branches[num - 1];
    }

    return featureBranchName;
}
 
开发者ID:aleksandr-m,项目名称:gitflow-maven-plugin,代码行数:38,代码来源:GitFlowFeatureFinishMojo.java


示例9: givenUserAgreesToSendStatistics

import org.codehaus.plexus.components.interactivity.PrompterException; //导入依赖的package包/类
private void givenUserAgreesToSendStatistics(String comment) throws IllegalAccessException, PrompterException {
    Prompter mock = mock(Prompter.class);
    when(mock.prompt(anyString(), anyList(), anyString())).thenReturn("Y");
    if (comment != null) {
        when(mock.prompt(anyString())).thenReturn(comment);
    }
    setVariableValueInObject(objectUnderTest, "prompter", mock);
}
 
开发者ID:ImmobilienScout24,项目名称:deadcode4j,代码行数:9,代码来源:A_UsageStatisticsManager.java


示例10: getReleaseVersion

import org.codehaus.plexus.components.interactivity.PrompterException; //导入依赖的package包/类
private String getReleaseVersion() throws MojoFailureException, VersionParseException, CommandLineException {
    // get current project version from pom
    final String currentVersion = getCurrentProjectVersion();

    String defaultVersion = null;
    if (tychoBuild) {
        defaultVersion = currentVersion;
    } else {
        // get default release version
        defaultVersion = new GitFlowVersionInfo(currentVersion)
                .getReleaseVersionString();
    }

    if (defaultVersion == null) {
        throw new MojoFailureException(
                "Cannot get default project version.");
    }

    String version = null;
    if (settings.isInteractiveMode()) {
        try {
            while (version == null) {
                version = prompter.prompt("What is release version? ["
                        + defaultVersion + "]");

                if (!"".equals(version)
                        && (!GitFlowVersionInfo.isValidVersion(version) || !validBranchName(version))) {
                    getLog().info("The version is not valid.");
                    version = null;
                }
            }
        } catch (PrompterException e) {
            throw new MojoFailureException("release-start", e);
        }
    } else {
        version = releaseVersion;
    }

    if (StringUtils.isBlank(version)) {
        getLog().info("Version is blank. Using default version.");
        version = defaultVersion;
    }

    return version;
}
 
开发者ID:aleksandr-m,项目名称:gitflow-maven-plugin,代码行数:46,代码来源:GitFlowReleaseStartMojo.java


示例11: promptBranchName

import org.codehaus.plexus.components.interactivity.PrompterException; //导入依赖的package包/类
private String promptBranchName() throws MojoFailureException, CommandLineException {
    // git for-each-ref --format='%(refname:short)' refs/heads/hotfix/*
    String hotfixBranches = gitFindBranches(gitFlowConfig.getHotfixBranchPrefix(), false);

    // find hotfix support branches
    if (!gitFlowConfig.getHotfixBranchPrefix().endsWith("/")) {
        String supportHotfixBranches = gitFindBranches(gitFlowConfig.getHotfixBranchPrefix() + "*/*", false);
        hotfixBranches = hotfixBranches + supportHotfixBranches;
    }

    if (StringUtils.isBlank(hotfixBranches)) {
        throw new MojoFailureException("There are no hotfix branches.");
    }

    String[] branches = hotfixBranches.split("\\r?\\n");

    List<String> numberedList = new ArrayList<String>();
    StringBuilder str = new StringBuilder("Hotfix branches:").append(LS);
    for (int i = 0; i < branches.length; i++) {
        str.append((i + 1) + ". " + branches[i] + LS);
        numberedList.add(String.valueOf(i + 1));
    }
    str.append("Choose hotfix branch to finish");

    String hotfixNumber = null;
    try {
        while (StringUtils.isBlank(hotfixNumber)) {
            hotfixNumber = prompter.prompt(str.toString(), numberedList);
        }
    } catch (PrompterException e) {
        throw new MojoFailureException("hotfix-finish", e);
    }

    String hotfixBranchName = null;
    if (hotfixNumber != null) {
        int num = Integer.parseInt(hotfixNumber);
        hotfixBranchName = branches[num - 1];
    }

    return hotfixBranchName;
}
 
开发者ID:aleksandr-m,项目名称:gitflow-maven-plugin,代码行数:42,代码来源:GitFlowHotfixFinishMojo.java


示例12: givenPrompterFails

import org.codehaus.plexus.components.interactivity.PrompterException; //导入依赖的package包/类
private void givenPrompterFails() throws IllegalAccessException, PrompterException {
    Prompter mock = mock(Prompter.class);
    when(mock.prompt(anyString(), anyList(), anyString())).thenThrow(new PrompterException("Prompt You!"));
    setVariableValueInObject(objectUnderTest, "prompter", mock);
}
 
开发者ID:ImmobilienScout24,项目名称:deadcode4j,代码行数:6,代码来源:A_UsageStatisticsManager.java



注:本文中的org.codehaus.plexus.components.interactivity.PrompterException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GeoDistanceSortBuilder类代码示例发布时间:2022-05-23
下一篇:
Java CFDefinition类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap