Search in sources :

Example 56 with Configuration

use of org.gradle.api.artifacts.Configuration in project gradle by gradle.

the class BuildConfigurationRule method apply.

public void apply(String taskName) {
    if (taskName.startsWith(PREFIX)) {
        String configurationName = StringUtils.uncapitalize(taskName.substring(PREFIX.length()));
        Configuration configuration = configurations.findByName(configurationName);
        if (configuration != null) {
            Task task = tasks.create(taskName);
            task.dependsOn(configuration.getAllArtifacts());
            task.setDescription("Builds the artifacts belonging to " + configuration + ".");
        }
    }
}
Also used : Task(org.gradle.api.Task) Configuration(org.gradle.api.artifacts.Configuration)

Example 57 with Configuration

use of org.gradle.api.artifacts.Configuration in project gradle by gradle.

the class WarPlugin method configureConfigurations.

public void configureConfigurations(ConfigurationContainer configurationContainer) {
    Configuration provideCompileConfiguration = configurationContainer.create(PROVIDED_COMPILE_CONFIGURATION_NAME).setVisible(false).setDescription("Additional compile classpath for libraries that should not be part of the WAR archive.");
    Configuration provideRuntimeConfiguration = configurationContainer.create(PROVIDED_RUNTIME_CONFIGURATION_NAME).setVisible(false).extendsFrom(provideCompileConfiguration).setDescription("Additional runtime classpath for libraries that should not be part of the WAR archive.");
    configurationContainer.getByName(JavaPlugin.COMPILE_CONFIGURATION_NAME).extendsFrom(provideCompileConfiguration);
    configurationContainer.getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME).extendsFrom(provideRuntimeConfiguration);
}
Also used : Configuration(org.gradle.api.artifacts.Configuration)

Example 58 with Configuration

use of org.gradle.api.artifacts.Configuration in project gradle by gradle.

the class JsHintPlugin method addConfiguration.

public Configuration addConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final JsHintExtension extension) {
    Configuration configuration = configurations.create(JsHintExtension.CONFIGURATION_NAME);
    configuration.defaultDependencies(new Action<DependencySet>() {

        @Override
        public void execute(DependencySet configDependencies) {
            String notation = JsHintExtension.DEFAULT_DEPENDENCY_GROUP + ":" + JsHintExtension.DEFAULT_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js";
            Dependency dependency = dependencies.create(notation);
            configDependencies.add(dependency);
        }
    });
    return configuration;
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) DependencySet(org.gradle.api.artifacts.DependencySet) Dependency(org.gradle.api.artifacts.Dependency)

Example 59 with Configuration

use of org.gradle.api.artifacts.Configuration in project gradle by gradle.

the class RhinoPlugin method apply.

public void apply(Project project) {
    project.getPluginManager().apply(JavaScriptBasePlugin.class);
    JavaScriptExtension jsExtension = project.getExtensions().findByType(JavaScriptExtension.class);
    final RhinoExtension rhinoExtension = ((ExtensionAware) jsExtension).getExtensions().create(RhinoExtension.NAME, RhinoExtension.class);
    final Configuration configuration = addClasspathConfiguration(project.getConfigurations());
    configureDefaultRhinoDependency(configuration, project.getDependencies(), rhinoExtension);
    ConventionMapping conventionMapping = ((IConventionAware) rhinoExtension).getConventionMapping();
    conventionMapping.map("classpath", new Callable<Configuration>() {

        public Configuration call() {
            return configuration;
        }
    });
    conventionMapping.map("version", new Callable<String>() {

        public String call() {
            return RhinoExtension.DEFAULT_RHINO_DEPENDENCY_VERSION;
        }
    });
    project.getTasks().withType(RhinoShellExec.class, new Action<RhinoShellExec>() {

        public void execute(RhinoShellExec task) {
            task.getConventionMapping().map("classpath", new Callable<FileCollection>() {

                public FileCollection call() {
                    return rhinoExtension.getClasspath();
                }
            });
            task.getConventionMapping().map("main", new Callable<String>() {

                public String call() {
                    return RhinoExtension.RHINO_SHELL_MAIN;
                }
            });
            task.setClasspath(rhinoExtension.getClasspath());
        }
    });
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) JavaScriptExtension(org.gradle.plugins.javascript.base.JavaScriptExtension) ConventionMapping(org.gradle.api.internal.ConventionMapping) IConventionAware(org.gradle.api.internal.IConventionAware) Callable(java.util.concurrent.Callable)

Example 60 with Configuration

use of org.gradle.api.artifacts.Configuration in project gradle by gradle.

the class CoffeeScriptBasePlugin method apply.

public void apply(Project project) {
    project.getPluginManager().apply(RhinoPlugin.class);
    JavaScriptExtension jsExtension = project.getExtensions().getByType(JavaScriptExtension.class);
    ExtensionContainer extensionContainer = ((ExtensionAware) jsExtension).getExtensions();
    final CoffeeScriptExtension csExtension = extensionContainer.create(CoffeeScriptExtension.NAME, CoffeeScriptExtension.class);
    final Configuration jsConfiguration = addJsConfiguration(project.getConfigurations(), project.getDependencies(), csExtension);
    ConventionMapping conventionMapping = ((IConventionAware) csExtension).getConventionMapping();
    conventionMapping.map("js", new Callable<Configuration>() {

        @Override
        public Configuration call() {
            return jsConfiguration;
        }
    });
    conventionMapping.map("version", new Callable<String>() {

        @Override
        public String call() {
            return CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_VERSION;
        }
    });
    final RhinoExtension rhinoExtension = extensionContainer.getByType(RhinoExtension.class);
    project.getTasks().withType(CoffeeScriptCompile.class, new Action<CoffeeScriptCompile>() {

        @Override
        public void execute(CoffeeScriptCompile task) {
            task.getConventionMapping().map("rhinoClasspath", new Callable<FileCollection>() {

                public FileCollection call() {
                    return rhinoExtension.getClasspath();
                }
            });
            task.getConventionMapping().map("coffeeScriptJs", new Callable<FileCollection>() {

                public FileCollection call() {
                    return csExtension.getJs();
                }
            });
        }
    });
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) RhinoExtension(org.gradle.plugins.javascript.rhino.RhinoExtension) JavaScriptExtension(org.gradle.plugins.javascript.base.JavaScriptExtension) ConventionMapping(org.gradle.api.internal.ConventionMapping) ExtensionContainer(org.gradle.api.plugins.ExtensionContainer) Callable(java.util.concurrent.Callable) ExtensionAware(org.gradle.api.plugins.ExtensionAware) IConventionAware(org.gradle.api.internal.IConventionAware)

Aggregations

Configuration (org.gradle.api.artifacts.Configuration)85 Project (org.gradle.api.Project)11 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)11 File (java.io.File)10 Dependency (org.gradle.api.artifacts.Dependency)10 Callable (java.util.concurrent.Callable)9 ResolvedConfiguration (org.gradle.api.artifacts.ResolvedConfiguration)9 ResolvedProjectConfiguration (org.gradle.api.internal.artifacts.ivyservice.resolveengine.projectresult.ResolvedProjectConfiguration)9 DependencySet (org.gradle.api.artifacts.DependencySet)8 DefaultLenientConfiguration (org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration)7 LinkedHashSet (java.util.LinkedHashSet)6 Usage (org.gradle.api.attributes.Usage)6 Action (org.gradle.api.Action)5 ConventionMapping (org.gradle.api.internal.ConventionMapping)5 PublishArtifact (org.gradle.api.artifacts.PublishArtifact)4 IConventionAware (org.gradle.api.internal.IConventionAware)4 ArchivePublishArtifact (org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact)4 DefaultUsageContext (org.gradle.language.cpp.internal.DefaultUsageContext)4 Set (java.util.Set)3 FileCollectionDependency (org.gradle.api.artifacts.FileCollectionDependency)3