Set<Artifact> getResolvedArtifactsFromUnresolvedDependencies(
      List<Dependency> unresolvedDependencies, boolean resolveTransitively)
      throws MojoExecutionException {
    final Set<Artifact> resolvedArtifacts = new HashSet<Artifact>();
    //    Artifact mojoArtifact = this.artifactFactory.createBuildArtifact(project.getGroupId(),
    // project.getArtifactId(), project.getVersion(), "pom");

    /*
     * Resolve each artifact.  This will get all transitive artifacts AND eliminate conflicts.
     */
    final Set<Artifact> unresolvedArtifacts;

    //    for (Dependency d : unresolvedDependencies)
    //      System.out.println("dependency: " + d.toString());

    try {
      unresolvedArtifacts =
          MavenMetadataSource.createArtifacts(
              this.artifactFactory, unresolvedDependencies, null, null, null);
      //      for (Artifact artifact : unresolvedArtifacts) {
      //        System.out.println("unresolved " + artifact.toString());
      //      }

      if (resolveTransitively) {
        ArtifactResolutionResult artifacts =
            artifactResolver.resolveTransitively(
                unresolvedArtifacts,
                project.getArtifact(),
                remoteRepositories,
                localRepository,
                artifactMetadataSource);
        resolvedArtifacts.addAll(artifacts.getArtifacts());
      } else {
        // resolve each artifact individually
        for (Artifact artifact : unresolvedArtifacts) {
          artifactResolver.resolve(artifact, remoteRepositories, localRepository);

          resolvedArtifacts.add(artifact);
        }
      }

    } catch (Exception e) {
      throw new MojoExecutionException("Unable to complete configuring the build settings", e);
    }

    for (Artifact artifact : resolvedArtifacts) {
      System.out.println("matched " + artifact.toString());
    }

    return resolvedArtifacts;
  }