Java Code Examples for org.gradle.api.artifacts.ConfigurationContainer

The following examples show how to use org.gradle.api.artifacts.ConfigurationContainer. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: native-samples   Source File: CppPublicMacrosPlugin.java    License: Apache License 2.0 6 votes vote down vote up
private static Configuration createConfiguration(ConfigurationContainer configurations, ObjectFactory objectFactory) {
    return configurations.create("cppPublicMacros", new Action<Configuration>() {
        @Override
        public void execute(Configuration configuration) {
            configurations.all(new Action<Configuration>() {
                @Override
                public void execute(Configuration it) {
                    if (it.getName().toLowerCase().endsWith("implementation")) {
                        configuration.extendsFrom(it);
                    }
                }
            });
            configuration.setCanBeConsumed(false);
            configuration.setCanBeResolved(true);
            configuration.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, objectFactory.named(Usage.class, "cpp-public-macros"));
        }
    });
}
 
Example 2
Source Project: native-samples   Source File: CppPublicMacrosPlugin.java    License: Apache License 2.0 6 votes vote down vote up
private static Configuration createElementsConfiguration(ConfigurationContainer configurations, ObjectFactory objectFactory) {
    return configurations.create("cppPublicMacrosElements", new Action<Configuration>() {
        @Override
        public void execute(Configuration configuration) {
            configurations.all(new Action<Configuration>() {
                @Override
                public void execute(Configuration it) {
                    if (it.getName().toLowerCase().endsWith("implementation")) {
                        configuration.extendsFrom(it);
                    }
                }
            });
            configuration.setCanBeConsumed(true);
            configuration.setCanBeResolved(false);
            configuration.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, objectFactory.named(Usage.class, "cpp-public-macros"));
        }
    });
}
 
Example 3
@Override
public void apply(Project project) {
    final ConfigurationContainer configurations = project.getConfigurations();
    configurations.maybeCreate("test");
    configurations.maybeCreate("build");
    configurations.maybeCreate("tool");

    final ExtensionContainer extensions = project.getExtensions();
    final ExtensionAware golang = (ExtensionAware) extensions.create("golang", GolangSettings.class, true, project);
    golang.getExtensions().create("build", BuildSettings.class, true, project);
    golang.getExtensions().create("toolchain", ToolchainSettings.class, true, project);
    golang.getExtensions().create("dependencies", DependenciesSettings.class, true, project);
    golang.getExtensions().create("testing", TestingSettings.class, true, project);

    extensions.create(INSTANCE_PROPERTY_NAME, Reference.class, this);

    final TaskContainer tasks = project.getTasks();
    addTasks(tasks);
}
 
Example 4
private void createCompileTask(final Project project) {
	project.getTasks().create(GwtCompileTask.NAME, GwtCompileTask.class);
	final PutnamiExtension extension = project.getExtensions().getByType(PutnamiExtension.class);
	final War warTask = project.getTasks().withType(War.class).getByName("war");
	warTask.dependsOn(GwtCompileTask.NAME);
	project.getTasks().withType(GwtCompileTask.class, new Action<GwtCompileTask>() {
		@Override
		public void execute(final GwtCompileTask task) {
			task.configure(project, extension);
			warTask.from(extension.getCompile().getWar());
		}
	});

	ConfigurationContainer configurationContainer = project.getConfigurations();
	//		Configuration gwtConfig = configurationContainer.getByName(PwtLibPlugin.CONF_GWT_SDM);
	//		FileCollection warClasspath = warTask.getClasspath().minus(gwtConfig);
	//		warTask.setClasspath(warClasspath);
}
 
Example 5
public void configure(Project project, JettyOption jettyOption, File jettyConf) {
	ConfigurationContainer configs = project.getConfigurations();

	Configuration runtimeConf = configs.getByName(WarPlugin.PROVIDED_RUNTIME_CONFIGURATION_NAME);
	Configuration jettyClassPath = configs.getByName(PwtLibPlugin.CONF_JETTY);

	configureJavaArgs(jettyOption);

	addClassPath(jettyClassPath.getAsPath());
	addClassPath(runtimeConf.getAsPath());

	if (jettyOption.getLogRequestFile() != null) {
		ResourceUtils.ensureDir(jettyOption.getLogRequestFile().getParentFile());
		addArg("--log", jettyOption.getLogRequestFile());
	}
	if (jettyOption.getLogFile() != null) {
		ResourceUtils.ensureDir(jettyOption.getLogFile().getParentFile());
		addArg("--out", jettyOption.getLogFile());
	}
	addArg("--host", jettyOption.getBindAddress());
	addArg("--port", jettyOption.getPort());
	addArg("--stop-port", jettyOption.getStopPort());
	addArg("--stop-key", jettyOption.getStopKey());

	addArg(jettyConf.getAbsolutePath());
}
 
Example 6
Source Project: Pushjet-Android   Source File: EarPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureConfigurations(final Project project) {

        ConfigurationContainer configurations = project.getConfigurations();
        Configuration moduleConfiguration = configurations.create(DEPLOY_CONFIGURATION_NAME).setVisible(false)
                .setTransitive(false).setDescription("Classpath for deployable modules, not transitive.");
        Configuration earlibConfiguration = configurations.create(EARLIB_CONFIGURATION_NAME).setVisible(false)
                .setDescription("Classpath for module dependencies.");

        configurations.getByName(Dependency.DEFAULT_CONFIGURATION)
                .extendsFrom(moduleConfiguration, earlibConfiguration);
    }
 
Example 7
public DefaultMavenPomFactory(ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer conf2ScopeMappingContainer, PomDependenciesConverter pomDependenciesConverter,
                              FileResolver fileResolver) {
    this.configurationContainer = configurationContainer;
    this.conf2ScopeMappingContainer = conf2ScopeMappingContainer;
    this.pomDependenciesConverter = pomDependenciesConverter;
    this.fileResolver = fileResolver;
}
 
Example 8
public DefaultMavenPom(ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer scopeMappings, PomDependenciesConverter pomDependenciesConverter,
                       FileResolver fileResolver) {
    this.configurations = configurationContainer;
    this.scopeMappings = scopeMappings;
    this.pomDependenciesConverter = pomDependenciesConverter;
    this.fileResolver = fileResolver;
    mavenProject.setModelVersion("4.0.0");
}
 
Example 9
public DefaultDeployerFactory(MavenFactory mavenFactory, Factory<LoggingManagerInternal> loggingManagerFactory, FileResolver fileResolver, MavenPomMetaInfoProvider pomMetaInfoProvider,
                              ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer scopeMapping) {
    this.mavenFactory = mavenFactory;
    this.loggingManagerFactory = loggingManagerFactory;
    this.fileResolver = fileResolver;
    this.pomMetaInfoProvider = pomMetaInfoProvider;
    this.configurationContainer = configurationContainer;
    this.scopeMapping = scopeMapping;
}
 
Example 10
Source Project: pushfish-android   Source File: EarPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureConfigurations(final Project project) {

        ConfigurationContainer configurations = project.getConfigurations();
        Configuration moduleConfiguration = configurations.create(DEPLOY_CONFIGURATION_NAME).setVisible(false)
                .setTransitive(false).setDescription("Classpath for deployable modules, not transitive.");
        Configuration earlibConfiguration = configurations.create(EARLIB_CONFIGURATION_NAME).setVisible(false)
                .setDescription("Classpath for module dependencies.");

        configurations.getByName(Dependency.DEFAULT_CONFIGURATION)
                .extendsFrom(moduleConfiguration, earlibConfiguration);
    }
 
Example 11
public DefaultDependencyHandler(ConfigurationContainer configurationContainer, DependencyFactory dependencyFactory,
                                ProjectFinder projectFinder, ComponentMetadataHandler metadataHandler,
                                ArtifactResolutionQueryFactory resolutionQueryFactory) {
    this.configurationContainer = configurationContainer;
    this.dependencyFactory = dependencyFactory;
    this.projectFinder = projectFinder;
    this.metadataHandler = metadataHandler;
    this.resolutionQueryFactory = resolutionQueryFactory;
}
 
Example 12
public AbstractScriptHandler(RepositoryHandler repositoryHandler,
                             DependencyHandler dependencyHandler, ScriptSource scriptSource,
                             ConfigurationContainer configContainer) {
    this.repositoryHandler = repositoryHandler;
    this.dependencyHandler = dependencyHandler;
    this.scriptSource = scriptSource;
    this.configContainer = configContainer;
    classpathConfiguration = configContainer.create(CLASSPATH_CONFIGURATION);
}
 
Example 13
public ScriptHandler create(ScriptSource scriptSource, ClassLoaderScope classLoaderScope, DomainObjectContext context) {
    DependencyResolutionServices services = dependencyManagementServices.create(fileResolver, dependencyMetaDataProvider, projectFinder, context);
    RepositoryHandler repositoryHandler = services.getResolveRepositoryHandler();
    ConfigurationContainer configurationContainer = services.getConfigurationContainer();
    DependencyHandler dependencyHandler = services.getDependencyHandler();
    return new DefaultScriptHandler(scriptSource, repositoryHandler, dependencyHandler, configurationContainer, new ScriptHandlerClassLoaderFactory(scriptSource, classLoaderScope));
}
 
Example 14
public AbstractScriptHandler(RepositoryHandler repositoryHandler,
                             DependencyHandler dependencyHandler, ScriptSource scriptSource,
                             ConfigurationContainer configContainer) {
    this.repositoryHandler = repositoryHandler;
    this.dependencyHandler = dependencyHandler;
    this.scriptSource = scriptSource;
    this.configContainer = configContainer;
    classpathConfiguration = configContainer.create(CLASSPATH_CONFIGURATION);
}
 
Example 15
Source Project: Pushjet-Android   Source File: WarPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example 16
void configureConfigurations(Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    Configuration compileConfiguration = configurations.getByName(COMPILE_CONFIGURATION_NAME);
    Configuration runtimeConfiguration = configurations.getByName(RUNTIME_CONFIGURATION_NAME);

    Configuration compileTestsConfiguration = configurations.getByName(TEST_COMPILE_CONFIGURATION_NAME);
    compileTestsConfiguration.extendsFrom(compileConfiguration);

    configurations.getByName(TEST_RUNTIME_CONFIGURATION_NAME).extendsFrom(runtimeConfiguration, compileTestsConfiguration);

    configurations.getByName(Dependency.DEFAULT_CONFIGURATION).extendsFrom(runtimeConfiguration);
}
 
Example 17
Source Project: pushfish-android   Source File: WarPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
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);
}
 
Example 18
public DefaultMavenPomFactory(ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer conf2ScopeMappingContainer, PomDependenciesConverter pomDependenciesConverter,
                              FileResolver fileResolver) {
    this.configurationContainer = configurationContainer;
    this.conf2ScopeMappingContainer = conf2ScopeMappingContainer;
    this.pomDependenciesConverter = pomDependenciesConverter;
    this.fileResolver = fileResolver;
}
 
Example 19
public DefaultDeployerFactory(MavenFactory mavenFactory, Factory<LoggingManagerInternal> loggingManagerFactory, FileResolver fileResolver, MavenPomMetaInfoProvider pomMetaInfoProvider,
                              ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer scopeMapping) {
    this.mavenFactory = mavenFactory;
    this.loggingManagerFactory = loggingManagerFactory;
    this.fileResolver = fileResolver;
    this.pomMetaInfoProvider = pomMetaInfoProvider;
    this.configurationContainer = configurationContainer;
    this.scopeMapping = scopeMapping;
}
 
Example 20
public DefaultMavenPom(ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer scopeMappings, PomDependenciesConverter pomDependenciesConverter,
                       FileResolver fileResolver) {
    this.configurations = configurationContainer;
    this.scopeMappings = scopeMappings;
    this.pomDependenciesConverter = pomDependenciesConverter;
    this.fileResolver = fileResolver;
    mavenProject.setModelVersion("4.0.0");
}
 
Example 21
private void configureJavaScopeMappings(ConfigurationContainer configurations, Conf2ScopeMappingContainer mavenScopeMappings) {
    mavenScopeMappings.addMapping(COMPILE_PRIORITY, configurations.getByName(JavaPlugin.COMPILE_CONFIGURATION_NAME),
            Conf2ScopeMappingContainer.COMPILE);
    mavenScopeMappings.addMapping(RUNTIME_PRIORITY, configurations.getByName(JavaPlugin.RUNTIME_CONFIGURATION_NAME),
            Conf2ScopeMappingContainer.RUNTIME);
    mavenScopeMappings.addMapping(TEST_COMPILE_PRIORITY, configurations.getByName(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME),
            Conf2ScopeMappingContainer.TEST);
    mavenScopeMappings.addMapping(TEST_RUNTIME_PRIORITY, configurations.getByName(JavaPlugin.TEST_RUNTIME_CONFIGURATION_NAME),
            Conf2ScopeMappingContainer.TEST);
}
 
Example 22
Source Project: pushfish-android   Source File: EarPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureConfigurations(final Project project) {

        ConfigurationContainer configurations = project.getConfigurations();
        Configuration moduleConfiguration = configurations.create(DEPLOY_CONFIGURATION_NAME).setVisible(false)
                .setTransitive(false).setDescription("Classpath for deployable modules, not transitive.");
        Configuration earlibConfiguration = configurations.create(EARLIB_CONFIGURATION_NAME).setVisible(false)
                .setDescription("Classpath for module dependencies.");

        configurations.getByName(Dependency.DEFAULT_CONFIGURATION)
                .extendsFrom(moduleConfiguration, earlibConfiguration);
    }
 
Example 23
public AbstractScriptHandler(RepositoryHandler repositoryHandler,
                             DependencyHandler dependencyHandler, ScriptSource scriptSource,
                             ConfigurationContainer configContainer) {
    this.repositoryHandler = repositoryHandler;
    this.dependencyHandler = dependencyHandler;
    this.scriptSource = scriptSource;
    this.configContainer = configContainer;
    classpathConfiguration = configContainer.create(CLASSPATH_CONFIGURATION);
}
 
Example 24
void configureConfigurations(Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    Configuration compileConfiguration = configurations.getByName(COMPILE_CONFIGURATION_NAME);
    Configuration runtimeConfiguration = configurations.getByName(RUNTIME_CONFIGURATION_NAME);

    Configuration compileTestsConfiguration = configurations.getByName(TEST_COMPILE_CONFIGURATION_NAME);
    compileTestsConfiguration.extendsFrom(compileConfiguration);

    configurations.getByName(TEST_RUNTIME_CONFIGURATION_NAME).extendsFrom(runtimeConfiguration, compileTestsConfiguration);

    configurations.getByName(Dependency.DEFAULT_CONFIGURATION).extendsFrom(runtimeConfiguration);
}
 
Example 25
Source Project: Pushjet-Android   Source File: JavaPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
void configureConfigurations(Project project) {
    ConfigurationContainer configurations = project.getConfigurations();
    Configuration compileConfiguration = configurations.getByName(COMPILE_CONFIGURATION_NAME);
    Configuration runtimeConfiguration = configurations.getByName(RUNTIME_CONFIGURATION_NAME);

    Configuration compileTestsConfiguration = configurations.getByName(TEST_COMPILE_CONFIGURATION_NAME);
    compileTestsConfiguration.extendsFrom(compileConfiguration);

    configurations.getByName(TEST_RUNTIME_CONFIGURATION_NAME).extendsFrom(runtimeConfiguration, compileTestsConfiguration);

    configurations.getByName(Dependency.DEFAULT_CONFIGURATION).extendsFrom(runtimeConfiguration);
}
 
Example 26
Source Project: javaide   Source File: JavaBasePlugin.java    License: GNU General Public License v3.0 5 votes vote down vote up
private BridgedBinaries configureSourceSetDefaults(final JavaPluginConvention pluginConvention) {
    final Project project = pluginConvention.getProject();
    final List<ClassDirectoryBinarySpecInternal> binaries = Lists.newArrayList();
    pluginConvention.getSourceSets().all(new Action<SourceSet>() {
        public void execute(final SourceSet sourceSet) {
            ConventionMapping outputConventionMapping = ((IConventionAware) sourceSet.getOutput()).getConventionMapping();

            ConfigurationContainer configurations = project.getConfigurations();

            defineConfigurationsForSourceSet(sourceSet, configurations);
            definePathsForSourceSet(sourceSet, outputConventionMapping, project);

            createProcessResourcesTaskForBinary(sourceSet, sourceSet.getResources(), project);
            createCompileJavaTaskForBinary(sourceSet, sourceSet.getJava(), project);
            createBinaryLifecycleTask(sourceSet, project);

            DefaultComponentSpecIdentifier binaryId = new DefaultComponentSpecIdentifier(project.getPath(), sourceSet.getName());
            ClassDirectoryBinarySpecInternal binary = instantiator.newInstance(DefaultClassDirectoryBinarySpec.class, binaryId, sourceSet, javaToolChain, DefaultJavaPlatform.current(), instantiator, taskFactory);

            Classpath compileClasspath = new SourceSetCompileClasspath(sourceSet);
            DefaultJavaSourceSet javaSourceSet = instantiator.newInstance(DefaultJavaSourceSet.class, binaryId.child("java"), sourceSet.getJava(), compileClasspath);
            JvmResourceSet resourceSet = instantiator.newInstance(DefaultJvmResourceSet.class, binaryId.child("resources"), sourceSet.getResources());

            binary.addSourceSet(javaSourceSet);
            binary.addSourceSet(resourceSet);

            attachTasksToBinary(binary, sourceSet, project);
            binaries.add(binary);
        }
    });
    return new BridgedBinaries(binaries);
}
 
Example 27
public DefaultMavenPomFactory(ConfigurationContainer configurationContainer, Conf2ScopeMappingContainer conf2ScopeMappingContainer, PomDependenciesConverter pomDependenciesConverter,
                              FileResolver fileResolver) {
    this.configurationContainer = configurationContainer;
    this.conf2ScopeMappingContainer = conf2ScopeMappingContainer;
    this.pomDependenciesConverter = pomDependenciesConverter;
    this.fileResolver = fileResolver;
}
 
Example 28
Source Project: Pushjet-Android   Source File: EarPlugin.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void configureConfigurations(final Project project) {

        ConfigurationContainer configurations = project.getConfigurations();
        Configuration moduleConfiguration = configurations.create(DEPLOY_CONFIGURATION_NAME).setVisible(false)
                .setTransitive(false).setDescription("Classpath for deployable modules, not transitive.");
        Configuration earlibConfiguration = configurations.create(EARLIB_CONFIGURATION_NAME).setVisible(false)
                .setDescription("Classpath for module dependencies.");

        configurations.getByName(Dependency.DEFAULT_CONFIGURATION)
                .extendsFrom(moduleConfiguration, earlibConfiguration);
    }
 
Example 29
Source Project: javaide   Source File: BaseExtension.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void createConfiguration(
        @NonNull ConfigurationContainer configurations,
        @NonNull String configurationName,
        @NonNull String configurationDescription) {
    logger.info("Creating configuration {}", configurationName);

    Configuration configuration = configurations.findByName(configurationName);
    if (configuration == null) {
        configuration = configurations.create(configurationName);
    }
    configuration.setVisible(false);
    configuration.setDescription(configurationDescription);
}
 
Example 30
public DefaultScriptHandler(
        ScriptSource scriptSource, RepositoryHandler repositoryHandler,
        DependencyHandler dependencyHandler, ConfigurationContainer configContainer,
        Factory<ClassLoader> classLoaderFactory
) {
    this.repositoryHandler = repositoryHandler;
    this.dependencyHandler = dependencyHandler;
    this.scriptSource = scriptSource;
    this.configContainer = configContainer;
    this.classLoaderFactory = classLoaderFactory;
    classpathConfiguration = configContainer.create(CLASSPATH_CONFIGURATION);
}