private Set<Artifact> processTransitiveDependencies(
      Dependency dependency, boolean sharedLibraries) throws MojoExecutionException {
    log.debug("Processing transitive dependencies for : " + dependency);

    try {
      final Set<Artifact> artifacts = new LinkedHashSet<Artifact>();

      final List<String> exclusionPatterns = new ArrayList<String>();
      if (dependency.getExclusions() != null && !dependency.getExclusions().isEmpty()) {
        for (final Exclusion exclusion : dependency.getExclusions()) {
          exclusionPatterns.add(exclusion.getGroupId() + ":" + exclusion.getArtifactId());
        }
      }
      final ArtifactFilter optionalFilter =
          new ArtifactFilter() {
            @Override
            public boolean include(Artifact artifact) {
              return !artifact.isOptional();
            }
          };

      final AndArtifactFilter filter = new AndArtifactFilter();
      filter.add(new ExcludesArtifactFilter(exclusionPatterns));
      filter.add(
          new OrArtifactFilter(
              Arrays.<ArtifactFilter>asList(
                  new ScopeArtifactFilter("compile"),
                  new ScopeArtifactFilter("runtime"),
                  new ScopeArtifactFilter("test"))));
      filter.add(optionalFilter);

      final DependencyNode node = dependencyGraphBuilder.buildDependencyGraph(project, filter);
      final CollectingDependencyNodeVisitor collectingVisitor =
          new CollectingDependencyNodeVisitor();
      node.accept(collectingVisitor);

      final List<DependencyNode> dependencies = collectingVisitor.getNodes();
      for (final DependencyNode dep : dependencies) {
        final boolean isNativeLibrary =
            isNativeLibrary(sharedLibraries, dep.getArtifact().getType());
        log.debug("Processing library : " + dep.getArtifact() + " isNative=" + isNativeLibrary);
        if (isNativeLibrary) {
          artifacts.add(dep.getArtifact());
        }
      }

      return artifacts;
    } catch (Exception e) {
      throw new MojoExecutionException("Error while processing transitive dependencies", e);
    }
  }
  private void addDependencies(Archiver archiver) throws ArchiverException, MojoExecutionException {

    Log log = getLog();
    AndArtifactFilter filter = new AndArtifactFilter();
    filter.add(new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME));
    filter.add(
        new ArtifactFilter() {
          public boolean include(Artifact artifact) {
            return !artifact.isOptional();
          }
        });
    filter.add(new TypeArtifactFilter("jar"));
    filter.add(buildSynapseRuntimeArtifactFilter());
    for (Artifact artifact : filterArtifacts((Set<Artifact>) project.getArtifacts(), filter)) {
      String targetFileName =
          artifact.getArtifactId()
              + "-"
              + artifact.getVersion()
              + "."
              + artifact.getArtifactHandler().getExtension();
      log.info("Adding " + targetFileName + " (scope " + artifact.getScope() + ")");
      archiver.addFile(artifact.getFile(), "lib/" + targetFileName);
    }
  }