All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.shrinkwrap.resolver.impl.gradle.GradleEffectiveDependencies Maven / Gradle / Ivy

There is a newer version: 3.3.2
Show newest version
package org.jboss.shrinkwrap.resolver.impl.gradle;

import org.gradle.tooling.model.idea.IdeaSingleEntryLibraryDependency;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Class that groups dependencies by scope.
 */
public class GradleEffectiveDependencies {

   private final Map> effectiveModelGroupedByScope = new HashMap<>();

   public void addDependency(IdeaSingleEntryLibraryDependency ideaSingleEntryLibraryDependency) {
      addDependenciesByScope(ideaSingleEntryLibraryDependency);
   }

   public List getDependenciesByScope(final ScopeType scopeType) {
      if (effectiveModelGroupedByScope.containsKey(scopeType)) {
         return Collections.unmodifiableList(effectiveModelGroupedByScope.get(scopeType));
      } else {
         return Collections.unmodifiableList(new ArrayList());
      }
   }

   private void addDependenciesByScope(final IdeaSingleEntryLibraryDependency ideaSingleEntryLibraryDependency) {
      final List dependenciesByScope;
      final ScopeType scopeType = ScopeType.valueOf(ideaSingleEntryLibraryDependency.getScope().getScope());
      if (effectiveModelGroupedByScope.containsKey(scopeType)) {
         dependenciesByScope = effectiveModelGroupedByScope.get(scopeType);
      } else {
         dependenciesByScope = new ArrayList<>();
      }

      dependenciesByScope.add(ideaSingleEntryLibraryDependency.getFile());
      effectiveModelGroupedByScope.put(scopeType, dependenciesByScope);
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy