Search in sources :

Example 1 with GeneratedIdeaScope

use of org.gradle.plugins.ide.idea.model.internal.GeneratedIdeaScope in project gradle by gradle.

the class IdeaPlugin method setupScopes.

private void setupScopes(GenerateIdeaModule ideaModule) {
    Map<String, Map<String, Collection<Configuration>>> scopes = Maps.newLinkedHashMap();
    for (GeneratedIdeaScope scope : GeneratedIdeaScope.values()) {
        Map<String, Collection<Configuration>> plusMinus = Maps.newLinkedHashMap();
        plusMinus.put(IdeaDependenciesProvider.SCOPE_PLUS, Lists.<Configuration>newArrayList());
        plusMinus.put(IdeaDependenciesProvider.SCOPE_MINUS, Lists.<Configuration>newArrayList());
        scopes.put(scope.name(), plusMinus);
    }
    Project project = ideaModule.getProject();
    ConfigurationContainer configurations = project.getConfigurations();
    Collection<Configuration> provided = scopes.get(GeneratedIdeaScope.PROVIDED.name()).get(IdeaDependenciesProvider.SCOPE_PLUS);
    provided.add(configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME));
    Collection<Configuration> runtime = scopes.get(GeneratedIdeaScope.RUNTIME.name()).get(IdeaDependenciesProvider.SCOPE_PLUS);
    runtime.add(configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
    Collection<Configuration> test = scopes.get(GeneratedIdeaScope.TEST.name()).get(IdeaDependenciesProvider.SCOPE_PLUS);
    test.add(configurations.getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME));
    test.add(configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME));
    ideaModule.getModule().setScopes(scopes);
}
Also used : Project(org.gradle.api.Project) IdeaProject(org.gradle.plugins.ide.idea.model.IdeaProject) Configuration(org.gradle.api.artifacts.Configuration) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) Collection(java.util.Collection) FileCollection(org.gradle.api.file.FileCollection) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) GeneratedIdeaScope(org.gradle.plugins.ide.idea.model.internal.GeneratedIdeaScope)

Example 2 with GeneratedIdeaScope

use of org.gradle.plugins.ide.idea.model.internal.GeneratedIdeaScope in project gradle by gradle.

the class IdeaPlugin method setupScopes.

private void setupScopes(Project project) {
    Map<String, Map<String, Collection<Configuration>>> scopes = Maps.newLinkedHashMap();
    for (GeneratedIdeaScope scope : GeneratedIdeaScope.values()) {
        Map<String, Collection<Configuration>> plusMinus = Maps.newLinkedHashMap();
        plusMinus.put(IdeaDependenciesProvider.SCOPE_PLUS, Lists.<Configuration>newArrayList());
        plusMinus.put(IdeaDependenciesProvider.SCOPE_MINUS, Lists.<Configuration>newArrayList());
        scopes.put(scope.name(), plusMinus);
    }
    ConfigurationContainer configurations = project.getConfigurations();
    Collection<Configuration> provided = scopes.get(GeneratedIdeaScope.PROVIDED.name()).get(IdeaDependenciesProvider.SCOPE_PLUS);
    provided.add(configurations.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME));
    Collection<Configuration> runtime = scopes.get(GeneratedIdeaScope.RUNTIME.name()).get(IdeaDependenciesProvider.SCOPE_PLUS);
    runtime.add(configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME));
    Collection<Configuration> test = scopes.get(GeneratedIdeaScope.TEST.name()).get(IdeaDependenciesProvider.SCOPE_PLUS);
    test.add(configurations.getByName(JavaPlugin.TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME));
    test.add(configurations.getByName(JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME));
    ideaModel.getModule().setScopes(scopes);
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) Collection(java.util.Collection) FileCollection(org.gradle.api.file.FileCollection) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) GeneratedIdeaScope(org.gradle.plugins.ide.idea.model.internal.GeneratedIdeaScope)

Aggregations

Collection (java.util.Collection)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Configuration (org.gradle.api.artifacts.Configuration)2 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)2 FileCollection (org.gradle.api.file.FileCollection)2 GeneratedIdeaScope (org.gradle.plugins.ide.idea.model.internal.GeneratedIdeaScope)2 Project (org.gradle.api.Project)1 IdeaProject (org.gradle.plugins.ide.idea.model.IdeaProject)1