本文整理汇总了Java中org.gradle.api.tasks.SourceSetContainer.getByName方法的典型用法代码示例。如果您正苦于以下问题:Java SourceSetContainer.getByName方法的具体用法?Java SourceSetContainer.getByName怎么用?Java SourceSetContainer.getByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gradle.api.tasks.SourceSetContainer
的用法示例。
在下文中一共展示了SourceSetContainer.getByName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.gradle.api.tasks.SourceSetContainer; //导入方法依赖的package包/类
@Override
public void apply(final Project project) {
Logger logger = project.getLogger();
logger.info("applying jsweet plugin");
if (!project.getPlugins().hasPlugin(JavaPlugin.class) && !project.getPlugins().hasPlugin(WarPlugin.class)) {
logger.error("No java or war plugin detected. Enable java or war plugin.");
throw new IllegalStateException("No java or war plugin detected. Enable java or war plugin.");
}
JSweetPluginExtension extension = project.getExtensions().create("jsweet", JSweetPluginExtension.class);
JavaPluginConvention javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
SourceSetContainer sourceSets = javaPluginConvention.getSourceSets();
SourceSet mainSources = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
JSweetTranspileTask task = project.getTasks().create("jsweet", JSweetTranspileTask.class);
task.setGroup("generate");
task.dependsOn(JavaPlugin.COMPILE_JAVA_TASK_NAME);
task.setConfiguration(extension);
task.setSources(mainSources.getAllJava());
task.setClasspath(mainSources.getCompileClasspath());
JSweetCleanTask cleanTask = project.getTasks().create("jsweetClean", JSweetCleanTask.class);
cleanTask.setConfiguration(extension);
}
示例2: establishSonarQubeSourceSet
import org.gradle.api.tasks.SourceSetContainer; //导入方法依赖的package包/类
public void establishSonarQubeSourceSet()
{
final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
final SourceSetContainer sourceSets = javaConvention.getSourceSets();
final ConfigurationContainer configs = project.getConfigurations();
final SourceSet testSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
final SourceSet sqSourceSet = sourceSets.create(BuildUtil.SONARQUBE_SOURCE_SET_NAME);
configs.getByName(testSourceSet.getImplementationConfigurationName()).extendsFrom(
configs.getByName(sqSourceSet.getImplementationConfigurationName()));
configs.getByName(testSourceSet.getRuntimeOnlyConfigurationName()).extendsFrom(
configs.getByName(sqSourceSet.getRuntimeOnlyConfigurationName()));
final TaskContainer tasks = project.getTasks();
tasks.getByName(JavaPlugin.COMPILE_TEST_JAVA_TASK_NAME).dependsOn(
tasks.getByName(sqSourceSet.getClassesTaskName()));
final FileCollection sqOutputs = sqSourceSet.getOutput().getClassesDirs().plus(
project.files(sqSourceSet.getOutput().getResourcesDir()));
testSourceSet.setCompileClasspath(testSourceSet.getCompileClasspath().plus(sqOutputs));
testSourceSet.setRuntimeClasspath(testSourceSet.getRuntimeClasspath().plus(sqOutputs));
}
示例3: getProjectLibraries
import org.gradle.api.tasks.SourceSetContainer; //导入方法依赖的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;
}
示例4: getSrcDirs
import org.gradle.api.tasks.SourceSetContainer; //导入方法依赖的package包/类
@Override
public List<String> getSrcDirs() {
SourceSetContainer sourceSets = javaConvention.getSourceSets();
SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
return mainSourceSet.getAllSource().getSrcDirs().stream().map(f -> {
try {
return f.getCanonicalPath();
} catch (IOException e) {
return "";
}
}).collect(Collectors.toList());
}
示例5: getSrcDirs
import org.gradle.api.tasks.SourceSetContainer; //导入方法依赖的package包/类
@Override
public List<String> getSrcDirs() {
SourceSetContainer sourceSets = javaConvention.getSourceSets();
SourceSet mainSourceSet = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
return mainSourceSet.getAllSource().getSrcDirs().stream().map(f -> {
try {
return f.getCanonicalPath();
} catch (IOException e) {
return "";
}
}).collect(Collectors.toList());
}
示例6: apply
import org.gradle.api.tasks.SourceSetContainer; //导入方法依赖的package包/类
@Override
public void apply(final Project project) {
project.getPlugins().apply(JavaPlugin.class);
// final JNAeratorPluginExtension extension = project.getExtensions().create(JNAeratorPluginExtension.NAME, JNAeratorPluginExtension.class);
// extension.setOutputDir(new File(project.getBuildDir(), "generated-sources/jnaerator"));
JNAeratorTask task = project.getTasks().create("jnaerator", JNAeratorTask.class);
task.setOutputDir(new File(project.getBuildDir(), "generated-sources/jnaerator"));
project.getTasks().getByName("compileJava").dependsOn(task);
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
final SourceSet mainSourceSet = sourceSets.getByName("main");
mainSourceSet.getJava().srcDir(task.getOutputDir());
}
示例7: getSourceSet
import org.gradle.api.tasks.SourceSetContainer; //导入方法依赖的package包/类
public SourceSet getSourceSet(SourceType sourceType) {
JavaPluginConvention javaPluginConvention;
try {
javaPluginConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
} catch (IllegalStateException e) {
throw new RuntimeException("Gradle project apparently isn't a Java project--it doesn't use the Java plugin");
}
SourceSetContainer sourceSets = javaPluginConvention.getSourceSets();
return sourceSets.getByName(getSourceSetName(sourceType));
}
示例8: getSourceSet
import org.gradle.api.tasks.SourceSetContainer; //导入方法依赖的package包/类
private SourceSetHelper getSourceSet(String name) {
SourceSetContainer sourceSets = (SourceSetContainer) this.project.getProperties().get("sourceSets");
SourceSet sourceSet = sourceSets.getByName(name);
return new SourceSetHelper(sourceSet);
}
示例9: SiteTask
import org.gradle.api.tasks.SourceSetContainer; //导入方法依赖的package包/类
/**
* Constructor.
*/
public SiteTask()
{
super();
final Project project = getProject();
buildUtil = new BuildUtil(project);
setDescription(buildUtil.getLongName() + ": Package documentation for publication on the website");
final TaskContainer tasks = project.getTasks();
for (final String predecTaskName : new String[]{//
"processResources", "siteCopyAllChecks", "siteCopyJavadoc", "siteCopyDownloadGuide"}) {
dependsOn(tasks.getByName(predecTaskName));
}
// Task Inputs: The markdown description files of our checks
final SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
final SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
final FileTree tree = project.fileTree(mainSourceSet.getResources().getSrcDirs().iterator().next(),
new Closure<Void>(this)
{
@Override
public Void call(final Object... pArgs)
{
PatternFilterable ft = (PatternFilterable) getDelegate();
ft.include("**/*.md");
return null;
}
});
getInputs().files(tree.getFiles());
// Task Outputs: the contents of the 'site' directory
final File siteDir = new File(project.getBuildDir(), "site");
getOutputs().dir(siteDir);
// perform the collection of files in execution phase
doLast(new Closure<Void>(this)
{
@Override
public Void call()
{
try {
collect(tree, siteDir);
}
catch (IOException e) {
throw new GradleException("error executing 'site' task", e);
}
return null;
}
});
}