@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.");
  }
 /*
  * (non-Javadoc)
  *
  * @see org.jboss.forge.addon.deltaspike.facets.DeltaSpikeFacet#remove(org.jboss.forge.addon.deltaspike.DeltaSpikeModule)
  */
 @Override
 public DeltaSpikeFacet remove(DeltaSpikeModule deltaSpikeModule) {
   DependencyFacet dependencyFacet = getFaceted().getFacet(DependencyFacet.class);
   for (Dependency dependency : deltaSpikeModule.getDependencies()) {
     dependencyFacet.removeManagedDependency(dependency);
     dependencyFacet.removeDependency(dependency);
   }
   return this;
 }
  @Override
  public boolean isInstalled() {
    final DependencyFacet depFacet = getProject().getFacet(DependencyFacet.class);

    for (final DependencyBuilder dep : createDependencies()) {
      if (!depFacet.hasDirectManagedDependency(dep)) {
        return false;
      }
    }
    return true;
  }
  @Override
  public boolean uninstall() {
    final DependencyFacet depFacet = getProject().getFacet(DependencyFacet.class);

    for (final DependencyBuilder dep : createDependencies()) {
      if (depFacet.hasDirectManagedDependency(dep)) {
        depFacet.removeManagedDependency(dep);
      }
    }

    return true;
  }
  protected boolean isDependencyRequirementsMet() {
    DependencyFacet deps = origin.getFacet(DependencyFacet.class);
    for (Entry<Dependency, List<Dependency>> group : getRequiredDependencyOptions().entrySet()) {
      boolean satisfied = false;
      for (Dependency dependency : group.getValue()) {
        if (deps.hasEffectiveDependency(dependency)) {
          satisfied = true;
          break;
        }
      }

      if (!satisfied) return false;
    }
    return true;
  }
  @Override
  public Result execute(UIExecutionContext context) {
    final Result result;
    Project project = getSelectedProject(context.getUIContext());
    DependencyFacet deps = project.getFacet(DependencyFacet.class);

    String urlValue = url.getValue();
    DependencyRepository rep = deps.removeRepository(urlValue);
    if (rep != null) {
      result = Results.success("Removed repository [" + rep.getId() + "->" + rep.getUrl() + "]");
    } else {
      result = Results.fail("No repository with url [" + urlValue + "]");
    }
    return result;
  }
 private void addRequiredDependency() {
   boolean isInstalled = false;
   DependencyFacet dependencyFacet = origin.getFacet(DependencyFacet.class);
   for (Entry<Dependency, List<Dependency>> group : getRequiredDependencyOptions().entrySet()) {
     for (Dependency dependency : group.getValue()) {
       if (dependencyFacet.hasEffectiveDependency(dependency)) {
         isInstalled = true;
         break;
       }
     }
     if (!isInstalled) {
       installer.installManaged(origin, JREBORTH_DEPENDENCY);
       installer.install(origin, group.getKey());
     }
   }
 }
  @Override
  public boolean install() {
    final DependencyFacet depFacet = getProject().getFacet(DependencyFacet.class);
    final VersionFacet versionFacet = getProject().getFacet(VersionFacet.class);

    for (final DependencyBuilder dep : createDependencies()) {
      if (dep.getCoordinate().getVersion() == null || dep.getCoordinate().getVersion().equals("")) {
        dep.setVersion(
            versionFacet.resolveVersion(dep.getGroupId(), dep.getCoordinate().getArtifactId()));
      }
      if (!depFacet.hasDirectManagedDependency(dep)) {
        depFacet.addDirectManagedDependency(dep);
      }
    }

    return true;
  }
 // FIXME
 private Coordinate promptVersion(
     final DependencyFacet deps, final Coordinate dependency, Predicate<Dependency> filter) {
   Coordinate result = dependency;
   final List<Coordinate> versions =
       deps.resolveAvailableVersions(
           DependencyQueryBuilder.create(dependency)
               .setFilter(filter == null ? new NonSnapshotDependencyFilter() : filter));
   if (versions.size() > 0) {
     Coordinate deflt = versions.get(versions.size() - 1);
     result = deflt;
     // result = prompt.promptChoiceTyped("Use which version of '" + dependency.getArtifactId()
     // + "' ?", versions, deflt);
   }
   return result;
 }