当前位置: 首页>>代码示例>>Java>>正文


Java JavaPluginConvention.getSourceSets方法代码示例

本文整理汇总了Java中org.gradle.api.plugins.JavaPluginConvention.getSourceSets方法的典型用法代码示例。如果您正苦于以下问题:Java JavaPluginConvention.getSourceSets方法的具体用法?Java JavaPluginConvention.getSourceSets怎么用?Java JavaPluginConvention.getSourceSets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.gradle.api.plugins.JavaPluginConvention的用法示例。


在下文中一共展示了JavaPluginConvention.getSourceSets方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import org.gradle.api.plugins.JavaPluginConvention; //导入方法依赖的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);
}
 
开发者ID:lgrignon,项目名称:jsweet-gradle-plugin,代码行数:27,代码来源:JSweetPlugin.java

示例2: setupTask

import org.gradle.api.plugins.JavaPluginConvention; //导入方法依赖的package包/类
/** If the user hasn't specified the files yet, we'll assume he/she means all of the kotlin files. */
@Override
protected void setupTask(SpotlessTask task) {
	if (target == null) {
		JavaPluginConvention javaPlugin = getProject().getConvention().findPlugin(JavaPluginConvention.class);
		if (javaPlugin == null) {
			throw new GradleException("You must either specify 'target' manually or apply a kotlin plugin.");
		}
		FileCollection union = getProject().files();
		for (SourceSet sourceSet : javaPlugin.getSourceSets()) {
			union = union.plus(sourceSet.getAllSource().filter(file -> {
				String name = file.getName();
				return name.endsWith(".kt") || name.endsWith(".kts");
			}));
		}
		target = union;
	}
	super.setupTask(task);
}
 
开发者ID:diffplug,项目名称:spotless,代码行数:20,代码来源:KotlinExtension.java

示例3: setupTask

import org.gradle.api.plugins.JavaPluginConvention; //导入方法依赖的package包/类
/** If the user hasn't specified the files yet, we'll assume he/she means all of the java files. */
@Override
protected void setupTask(SpotlessTask task) {
	if (target == null) {
		JavaPluginConvention javaPlugin = getProject().getConvention().findPlugin(JavaPluginConvention.class);
		if (javaPlugin == null) {
			throw new GradleException("You must apply the java plugin before the spotless plugin if you are using the java extension.");
		}
		FileCollection union = getProject().files();
		for (SourceSet sourceSet : javaPlugin.getSourceSets()) {
			union = union.plus(sourceSet.getAllJava());
		}
		target = union;
	}
	// LicenseHeaderStep completely blows apart package-info.java - this common-sense check ensures that
	// it skips package-info.java. See https://github.com/diffplug/spotless/issues/1
	steps.replaceAll(step -> {
		if (LicenseHeaderStep.name().equals(step.getName())) {
			return step.filterByFile(SerializableFileFilter.skipFilesNamed("package-info.java"));
		} else {
			return step;
		}
	});
	super.setupTask(task);
}
 
开发者ID:diffplug,项目名称:spotless,代码行数:26,代码来源:JavaExtension.java

示例4: setupTask

import org.gradle.api.plugins.JavaPluginConvention; //导入方法依赖的package包/类
/** If the user hasn't specified the files yet, we'll assume he/she means all of the kotlin files. */
@Override
protected void setupTask(SpotlessTask task) {
	if (target == null) {
		JavaPluginConvention javaPlugin = getProject().getConvention().findPlugin(JavaPluginConvention.class);
		if (javaPlugin == null) {
			throw new GradleException("You must either specify 'target' manually or apply the 'scala' plugin.");
		}
		FileCollection union = getProject().files();
		for (SourceSet sourceSet : javaPlugin.getSourceSets()) {
			union = union.plus(sourceSet.getAllSource().filter(file -> {
				String name = file.getName();
				return name.endsWith(".scala") || name.endsWith(".sc");
			}));
		}
		target = union;
	}
	super.setupTask(task);
}
 
开发者ID:diffplug,项目名称:spotless,代码行数:20,代码来源:ScalaExtension.java

示例5: establishSonarQubeSourceSet

import org.gradle.api.plugins.JavaPluginConvention; //导入方法依赖的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));
}
 
开发者ID:checkstyle-addons,项目名称:checkstyle-addons,代码行数:24,代码来源:TaskCreator.java

示例6: getJavaSourceSets

import org.gradle.api.plugins.JavaPluginConvention; //导入方法依赖的package包/类
private static Iterable<SourceSet> getJavaSourceSets(Project project) {
	JavaPluginConvention plugin = project.getConvention()
			.getPlugin(JavaPluginConvention.class);
	if (plugin == null) {
		return Collections.emptyList();
	}
	return plugin.getSourceSets();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:SourceSets.java

示例7: setupTask

import org.gradle.api.plugins.JavaPluginConvention; //导入方法依赖的package包/类
/** If the user hasn't specified the files yet, we'll assume he/she means all of the groovy files. */
@Override
protected void setupTask(SpotlessTask task) {
	if (target == null) {
		JavaPluginConvention convention = getProject().getConvention().getPlugin(JavaPluginConvention.class);
		if (convention == null || !getProject().getPlugins().hasPlugin(GroovyBasePlugin.class)) {
			throw new GradleException("You must apply the groovy plugin before the spotless plugin if you are using the groovy extension.");
		}
		//Add all Groovy files (may contain Java files as well)

		FileCollection union = getProject().files();
		for (SourceSet sourceSet : convention.getSourceSets()) {
			GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class);
			if (excludeJava) {
				union = union.plus(groovySourceSet.getAllGroovy());
			} else {
				union = union.plus(groovySourceSet.getGroovy());
			}
		}
		target = union;
	} else if (excludeJava) {
		throw new IllegalArgumentException("'excludeJava' is not supported in combination with a custom 'target'.");
	}
	// LicenseHeaderStep completely blows apart package-info.java/groovy - this common-sense check
	// ensures that it skips both. See https://github.com/diffplug/spotless/issues/1
	steps.replaceAll(step -> {
		if (LicenseHeaderStep.name().equals(step.getName())) {
			return step.filterByFile(SerializableFileFilter.skipFilesNamed("package-info.java", "package-info.groovy"));
		} else {
			return step;
		}
	});
	super.setupTask(task);
}
 
开发者ID:diffplug,项目名称:spotless,代码行数:35,代码来源:GroovyExtension.java

示例8: getSourceSet

import org.gradle.api.plugins.JavaPluginConvention; //导入方法依赖的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));
}
 
开发者ID:juniversal,项目名称:juniversal,代码行数:12,代码来源:GradleProject.java

示例9: establishGeneralCompileOnlyCfg

import org.gradle.api.plugins.JavaPluginConvention; //导入方法依赖的package包/类
public void establishGeneralCompileOnlyCfg()
{
    final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    final SourceSetContainer sourceSets = javaConvention.getSourceSets();
    final ConfigurationContainer configs = project.getConfigurations();

    final Configuration generalCompileOnly = configs.create(GENERAL_COMPILE_ONLY_CONFIG_NAME);

    Arrays.asList(SourceSet.MAIN_SOURCE_SET_NAME, BuildUtil.SONARQUBE_SOURCE_SET_NAME,
        SourceSet.TEST_SOURCE_SET_NAME).forEach((@Nonnull final String pSourceSetName) -> {
        final SourceSet sourceSet = sourceSets.getByName(pSourceSetName);
        configs.getByName(sourceSet.getCompileOnlyConfigurationName()).extendsFrom(generalCompileOnly);
    });
}
 
开发者ID:checkstyle-addons,项目名称:checkstyle-addons,代码行数:15,代码来源:TaskCreator.java

示例10: BuildUtil

import org.gradle.api.plugins.JavaPluginConvention; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param pProject the Gradle project
 */
public BuildUtil(@Nonnull final Project pProject)
{
    super();
    project = pProject;
    final JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class);
    sourceSets = javaConvention.getSourceSets();
}
 
开发者ID:checkstyle-addons,项目名称:checkstyle-addons,代码行数:13,代码来源:BuildUtil.java


注:本文中的org.gradle.api.plugins.JavaPluginConvention.getSourceSets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。