/**
   * Output a message with the list of missing dependencies and info on how turn download on if it
   * was disabled.
   */
  private void reportMissingSources() {
    if (missingSourceDependencies.isEmpty()) {
      return;
    }

    StringBuffer msg = new StringBuffer();

    if (getDownloadSources()) {
      msg.append(Messages.getString("sourcesnotavailable")); // $NON-NLS-1$
    } else {
      msg.append(Messages.getString("sourcesnotdownloaded")); // $NON-NLS-1$
    }

    for (Iterator it = missingSourceDependencies.iterator(); it.hasNext(); ) {
      IdeDependency art = (IdeDependency) it.next();
      msg.append(Messages.getString("sourcesmissingitem", art.getId())); // $NON-NLS-1$
    }
    msg.append("\n"); // $NON-NLS-1$

    getLog().info(msg); // $NON-NLS-1$
  }
  /**
   * Resolve source artifacts and download them if <code>downloadSources</code> is <code>true</code>
   * . Source and javadocs artifacts will be attached to the <code>IdeDependency</code>
   *
   * @param deps resolved dependencies
   */
  private void resolveSourceArtifacts(IdeDependency[] deps) {

    ArtifactRepository localRepository = getLocalRepository();
    ArtifactResolver artifactResolver = getArtifactResolver();
    ArtifactFactory artifactFactory = getArtifactFactory();

    // if downloadSources is off, just check local repository for reporting missing jars
    List remoteRepos =
        getDownloadSources() ? getRemoteArtifactRepositories() : Collections.EMPTY_LIST;

    for (int j = 0; j < deps.length; j++) {
      IdeDependency dependency = deps[j];

      if (dependency.isReferencedProject() || dependency.isSystemScoped()) {
        // source artifact not needed
        continue;
      }

      // source artifact: use the "sources" classifier added by the source plugin
      Artifact sourceArtifact =
          IdeUtils.resolveArtifactWithClassifier(
              dependency.getGroupId(),
              dependency.getArtifactId(),
              dependency.getVersion(),
              "sources",
              localRepository,
              artifactResolver, //$NON-NLS-1$
              artifactFactory,
              remoteRepos,
              getLog());

      if (sourceArtifact.isResolved()) {
        dependency.setSourceAttachment(sourceArtifact.getFile());
      } else {
        // try using a plain javadoc jar if the source jar is not available
        Artifact javadocArtifact =
            IdeUtils.resolveArtifactWithClassifier(
                dependency.getGroupId(),
                dependency.getArtifactId(),
                dependency.getVersion(),
                "javadoc",
                localRepository,
                artifactResolver, //$NON-NLS-1$
                artifactFactory,
                remoteRepos,
                getLog());

        if (javadocArtifact.isResolved()) {
          dependency.setJavadocAttachment(javadocArtifact.getFile());
        }

        // @todo also report deps without a source attachment but with a javadoc one?
        missingSourceDependencies.add(dependency);
      }
    }
  }