本文整理汇总了Java中org.gradle.api.artifacts.ConfigurationContainer.getByName方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationContainer.getByName方法的具体用法?Java ConfigurationContainer.getByName怎么用?Java ConfigurationContainer.getByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gradle.api.artifacts.ConfigurationContainer
的用法示例。
在下文中一共展示了ConfigurationContainer.getByName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listProjectDepsSrcDirs
import org.gradle.api.artifacts.ConfigurationContainer; //导入方法依赖的package包/类
private Collection<File> listProjectDepsSrcDirs(Project project) {
ConfigurationContainer configs = project.getConfigurations();
Configuration compileConf = configs.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME);
DependencySet depSet = compileConf.getAllDependencies();
List<File> result = Lists.newArrayList();
for (Dependency dep : depSet) {
if (dep instanceof ProjectDependency) {
Project projectDependency = ((ProjectDependency) dep).getDependencyProject();
if (projectDependency.getPlugins().hasPlugin(PwtLibPlugin.class)) {
JavaPluginConvention javaConvention = projectDependency.getConvention().getPlugin(JavaPluginConvention.class);
SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
result.addAll(mainSourceSet.getAllSource().getSrcDirs());
}
}
}
return result;
}
示例2: configure
import org.gradle.api.artifacts.ConfigurationContainer; //导入方法依赖的package包/类
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());
}
示例3: findProjectConfiguration
import org.gradle.api.artifacts.ConfigurationContainer; //导入方法依赖的package包/类
@Override
public Configuration findProjectConfiguration() {
ConfigurationContainer dependencyConfigurations = getDependencyProject().getConfigurations();
String declaredConfiguration = getTargetConfiguration();
Configuration selectedConfiguration = dependencyConfigurations.getByName(GUtil.elvis(declaredConfiguration, Dependency.DEFAULT_CONFIGURATION));
if (!selectedConfiguration.isCanBeConsumed()) {
throw new ConfigurationNotConsumableException(dependencyProject.getDisplayName(), selectedConfiguration.getName());
}
return selectedConfiguration;
}
示例4: configureConfigurations
import org.gradle.api.artifacts.ConfigurationContainer; //导入方法依赖的package包/类
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);
}
示例5: getProjectLibraries
import org.gradle.api.artifacts.ConfigurationContainer; //导入方法依赖的package包/类
public Set<File> getProjectLibraries() {
Set<File> classpath = new HashSet<>();
SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
if (sourceSets != null) {
SortedSet<String> availableSourceSetNames = sourceSets.getNames();
for (String sourceSetName : Arrays.asList("main", "test", "integrationTest")) {
if (availableSourceSetNames.contains(sourceSetName)) {
SourceSet sourceSet = sourceSets.getByName(sourceSetName);
classpath.add(sourceSet.getOutput().getClassesDir());
}
}
}
// add dependencies from configured gradle configuration to url (usually test or integrationTest)
TSGeneratorConfig generatorConfiguration = project.getExtensions().getByType(TSGeneratorConfig.class);
String configurationName = generatorConfiguration.getRuntime().getConfiguration();
ConfigurationContainer configurations = project.getConfigurations();
Configuration runtimeConfiguration = configurations.findByName(configurationName + "Runtime");
if (runtimeConfiguration == null) {
runtimeConfiguration = configurations.getByName(configurationName);
}
classpath.addAll(runtimeConfiguration.getFiles());
for (File file : classpath) {
LOGGER.debug("classpath entry: {}", file);
}
return classpath;
}
示例6: run
import org.gradle.api.artifacts.ConfigurationContainer; //导入方法依赖的package包/类
@TaskAction
public void run() {
SortedSet<String> dependencies = new TreeSet<String>();
ConfigurationContainer container = getProject().getBuildscript().getConfigurations();
for (File file : container.getByName(ScriptHandler.CLASSPATH_CONFIGURATION))
dependencies.add(file.getName());
for (String dependency : dependencies)
System.out.println(dependency);
}
示例7: appendDependenciesOf
import org.gradle.api.artifacts.ConfigurationContainer; //导入方法依赖的package包/类
protected void appendDependenciesOf(@Nonnull String configurationName, @Nonnull Collection<GolangDependency> to) {
final Project project = _settings.getProject();
final ConfigurationContainer configurations = project.getConfigurations();
final Configuration configuration = configurations.getByName(configurationName);
appendDependenciesOf(configuration, to);
}
示例8: configureCompileTask
import org.gradle.api.artifacts.ConfigurationContainer; //导入方法依赖的package包/类
/**
* Configure the compile tasks
*
* @param javaCompile Compile task to configure
* @param project Project context
* @param javaConfig Java configuration
* @param configurations Configurations containing compiler configuration
*/
@Mutate
public void configureCompileTask(@Each JavaCompile javaCompile, ProjectContext project, JavaConfig javaConfig,
ConfigurationContainer configurations) {
File propertiesFile = new File(project.getBuildDir(),
"tmp/" + javaCompile.getName() + "/eclipseJavaCompiler.prefs");
javaCompile.doFirst(t -> {
propertiesFile.getParentFile().mkdirs();
Properties properties = Classes.loadProperties(JavaConfigPlugin.class, "eclipseJavaCompiler.prefs");
properties.putAll(javaConfig.getEclipseCompilerProperties());
try (FileWriter out = new FileWriter(propertiesFile)) {
properties.store(out, "Eclipse Java Compiler options for task " + t.getName());
}
catch (IOException e) {
throw new GradleException(String.format("Could not write properties file '%s'", propertiesFile), e);
}
});
Configuration compilerConfiguration = configurations.getByName(ECLIPSE_JAVA_COMPILER_CONFIGURATION);
CompileOptions options = javaCompile.getOptions();
List<String> compilerArgs = new ArrayList<>();
compilerArgs.add("-properties");
compilerArgs.add(propertiesFile.getPath());
if (Boolean.TRUE.equals(javaConfig.isOptimize())) {
compilerArgs.add("-o");
}
if (Boolean.TRUE.equals(javaConfig.isDebug())) {
compilerArgs.add("-g:lines,vars,source");
}
else {
compilerArgs.add("-g:none");
}
options.setCompilerArgs(compilerArgs);
options.setFork(true);
String[] jvmArgs = new String[] { "-classpath", compilerConfiguration.getAsPath(),
"org.eclipse.jdt.internal.compiler.batch.Main" };
ForkOptions forkOptions = options.getForkOptions();
forkOptions.setExecutable("java");
forkOptions.setJvmArgs(Arrays.asList(jvmArgs));
}
示例9: createPublications
import org.gradle.api.artifacts.ConfigurationContainer; //导入方法依赖的package包/类
/**
* Create the default Maven publication
*
* @param publishingExtension Publishing extension where the publication is created
* @param projectContext Project context to access project information
* @param projectConfig Project configuration
* @param mavenConfig Maven configuration
* @param configurations Container to access configurations
* @param services Service manager to obtain service objects
*/
@Mutate
public void createPublications(PublishingExtension publishingExtension, ProjectContext projectContext,
ProjectConfig projectConfig, MavenConfig mavenConfig, ConfigurationContainer configurations,
ServiceRegistry services) {
SoftwareComponentContainer components = services.get(SoftwareComponentContainer.class);
JavaLibrary javaComponent = components.withType(JavaLibrary.class).getByName("java");
for (MavenPublicationConfig publicationConfig : mavenConfig.getPublications()) {
Configuration configuration = configurations
.getByName(publicationConfig.getArchivesConfiguration());
publishingExtension.getPublications().create(publicationConfig.getName(), MavenPublication.class,
p -> {
p.setArtifactId(publicationConfig.getArtifactId());
List<@NonNull Configuration> runtimeConfigurations = publicationConfig
.getRuntimeConfigurations().stream().map(c -> configurations.getByName(c))
.collect(Collectors.toList());
List<@NonNull Configuration> compileConfigurations = publicationConfig
.getCompileConfigurations().stream().map(c -> configurations.getByName(c))
.collect(Collectors.toList());
List<@NonNull PublishArtifact> artifacts = Collections.emptyList();
if (publicationConfig.isAddProjectArtifacts()) {
artifacts = javaComponent.getUsages().stream()
.flatMap(u -> u.getArtifacts().stream()).collect(Collectors.toList());
}
PomConfigurator configurator = new PomConfigurator(projectContext, projectConfig,
Validate.notNull(runtimeConfigurations),
Validate.notNull(compileConfigurations));
p.pom(pom -> pom.withXml(xml -> configurator.configurePom(Validate.notNull(xml))));
for (PublishArtifact a : configuration.getArtifacts()) {
p.artifact(a);
}
});
}
}
示例10: configure
import org.gradle.api.artifacts.ConfigurationContainer; //导入方法依赖的package包/类
public void configure(Project project, DevOption devOption, Collection<String> modules) {
ConfigurationContainer configs = project.getConfigurations();
Configuration sdmConf = configs.getByName(PwtLibPlugin.CONF_GWT_SDM);
PutnamiExtension putnami = project.getExtensions().getByType(PutnamiExtension.class);
SourceSet mainSourceSet = project.getConvention()
.getPlugin(JavaPluginConvention.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
FileCollection sources = project.files(mainSourceSet.getAllJava().getSrcDirs());
configureJavaArgs(devOption);
addClassPath(mainSourceSet.getOutput().getAsPath());
addClassPath(mainSourceSet.getAllJava().getSrcDirs());
addClassPath(mainSourceSet.getCompileClasspath().getAsPath());
addClassPath(sdmConf.getAsPath());
addSrc(sources);
addSrc(listProjectDepsSrcDirs(project));
addArg("-bindAddress", devOption.getBindAddress());
addArgIf(devOption.getFailOnError(), "-failOnError", "-nofailOnError");
addArgIf(devOption.getPrecompile(), "-precompile", "-noprecompile");
addArg("-port", devOption.getPort());
addArgIf(devOption.getStrict(), "-strict");
addArgIf(devOption.getEnforceStrictResources(), "-XenforceStrictResources ", "-XnoenforceStrictResources");
addArg("-workDir", ResourceUtils.ensureDir(devOption.getWorkDir()));
addArgIf(devOption.getIncremental(), "-incremental", "-noincremental");
addArg("-sourceLevel", devOption.getSourceLevel());
if (!putnami.getGwtVersion().startsWith("2.6")) {
addArg("-logLevel", devOption.getLogLevel());
}
addArg("-XmethodNameDisplayMode", devOption.getMethodNameDisplayMode());
addArg("-XjsInteropMode", devOption.getJsInteropMode());
addArgIf(devOption.getGenerateJsInteropExports(), "-generateJsInteropExports");
if (devOption.getExtraArgs() != null) {
for (String arg : devOption.getExtraArgs()) {
if (arg != null && arg.length() > 0) {
addArg(arg);
}
}
}
for (String module : modules) {
addArg(module);
}
}