@Override public Result execute(UIExecutionContext context) { Project project = getSelectedProject(context.getUIContext()); final DependencyFacet deps = project.getFacet(DependencyFacet.class); if (arguments.hasValue()) { int count = 0; for (Dependency gav : arguments.getValue()) { Dependency existingDep = deps.getEffectiveManagedDependency(DependencyBuilder.create(gav).setVersion(null)); if (existingDep != null) { if (context .getPrompt() .promptBoolean( String.format( "Dependency [%s:%s] is currently managed. " + "Reference the existing managed dependency [%s:%s:%s]?", gav.getCoordinate().getArtifactId(), gav.getCoordinate().getGroupId(), existingDep.getCoordinate().getGroupId(), existingDep.getCoordinate().getArtifactId(), existingDep.getCoordinate().getVersion()))) { gav = DependencyBuilder.create(existingDep).setScopeType(gav.getScopeType()); } } this.installer.install(project, gav); count++; } return Results.success( "Installed [" + count + "] dependenc" + (count == 1 ? "y" : "ies") + "."); } return Results.fail("No arguments specified."); }
private boolean promptToFixMethod( UIExecutionContext context, String methodName, String propertyName) { UIPrompt prompt = context.getPrompt(); return prompt.promptBoolean( "Method '" + methodName + "'already exists for property" + propertyName + " . Method is not following the selected pattern." + " Should it be fixed?"); }
@Override public Result execute(UIExecutionContext context) throws Exception { context.getPrompt().prompt("Press <ENTER> to continue..."); return Results.success(); }