本文整理了Java中org.gradle.api.plugins.Convention.findPlugin()
方法的一些代码示例,展示了Convention.findPlugin()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Convention.findPlugin()
方法的具体详情如下:
包路径:org.gradle.api.plugins.Convention
类名称:Convention
方法名:findPlugin
暂无
代码示例来源:origin: diffplug/spotless
/** 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);
}
}
代码示例来源:origin: diffplug/spotless
/** 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);
}
}
代码示例来源:origin: diffplug/spotless
/** 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;
}
steps.replaceAll(step -> {
if (LicenseHeaderStep.name().equals(step.getName())) {
return step.filterByFile(LicenseHeaderStep.unsupportedJvmFilesFilter());
} else {
return step;
}
});
super.setupTask(task);
}
}
代码示例来源:origin: gradle.plugin.life.expert/archidoc
/**
* get gradle main source set
*/
private static Set< SourceSet > sourceSetMain( Project project )
{
JavaPluginConvention convention = project.getConvention().findPlugin( JavaPluginConvention.class );
Set< SourceSet > sourceSets = convention.getSourceSets().stream().filter( sourceSet -> sourceSet.getName().equals( SourceSet.MAIN_SOURCE_SET_NAME ) ).collect( Collectors.toSet() );
return sourceSets;
}
代码示例来源:origin: typelead/gradle-eta
public static <T> T getConvention(Object conventionTarget, Class<T> conventionType) {
assertConventionObject(conventionTarget);
return ((HasConvention) conventionTarget).getConvention()
.findPlugin(conventionType);
}
代码示例来源:origin: gradle.plugin.com.google.cloud.tools/jib-gradle-plugin
@Nullable
static War getWarTask(Project project) {
WarPluginConvention warPluginConvention =
project.getConvention().findPlugin(WarPluginConvention.class);
if (warPluginConvention == null) {
return null;
}
return (War) warPluginConvention.getProject().getTasks().findByName("war");
}
代码示例来源:origin: gradle.plugin.net.winterly.dropwizard/dropwizard
private <T> T getPlugin(Class<T> type) {
return getProject().getConvention().findPlugin(type);
}
}
代码示例来源:origin: purplejs/purplejs
private void configureAppPlugin()
{
final ApplicationPluginConvention convention = this.project.getConvention().findPlugin( ApplicationPluginConvention.class );
convention.setMainClassName( "io.purplejs.boot.MainApp" );
final JavaExec runTask = (JavaExec) this.project.getTasks().getByName( ApplicationPlugin.TASK_RUN_NAME );
runTask.systemProperty( "io.purplejs.runMode", "dev" );
final String devDirs = new File( this.project.getProjectDir(), "src/main/resources" ).getAbsolutePath();
runTask.systemProperty( "io.purplejs.devSourceDirs", devDirs );
}
}
代码示例来源:origin: gradle.plugin.com.triplequote.gradle/hydra
private static String getDefaultSourcepath(Project project, ScalaCompile scalaCompile) {
// The source sets are configured in the JavaPlugin and ScalaPlugin and they use the JavaPluginConvention to store the source sets.
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
StringJoiner sourcepathJoiner = new StringJoiner(File.pathSeparator);
for (SourceSet set : sourceSets) {
if (set.getCompileTaskName("scala").equals(scalaCompile.getName())) {
Convention scalaConvention = (Convention) InvokerHelper.getProperty(set, "convention");
ScalaSourceSet scalaSourceSet = scalaConvention.findPlugin(ScalaSourceSet.class);
scalaSourceSet.getAllScala().getSourceDirectories().getFiles().forEach(file -> sourcepathJoiner.add(file.getAbsolutePath()));
}
}
LOGGER.debug("Hydra sourcepath: {}.", sourcepathJoiner);
return sourcepathJoiner.toString();
}
代码示例来源:origin: gradle.plugin.com.google.cloud.tools/jib-gradle-plugin
void validateAgainstDefaultBaseImageVersion(@Nullable String baseImage) {
if (!PluginConfigurationProcessor.usingDefaultBaseImage(baseImage)) {
return;
}
JavaVersion version = JavaVersion.current();
JavaPluginConvention javaPluginConvention =
project.getConvention().findPlugin(JavaPluginConvention.class);
if (javaPluginConvention != null) {
version = JavaVersion.toVersion(javaPluginConvention.getTargetCompatibility());
}
if (version.isJava9Compatible()) {
throw new GradleException(
"Jib's default base image uses Java 8, but project is using Java "
+ version.getMajorVersion()
+ "; perhaps you should configure a Java "
+ version.getMajorVersion()
+ "-compatible base image using the 'jib.from.image' parameter, or set targetCompatibility = 1.8 in your build configuration");
}
}
代码示例来源:origin: com.palantir.gradle.conjure/gradle-conjure
private static void addGeneratedToMainSourceSet(Project subproj) {
JavaPluginConvention javaPlugin = subproj.getConvention().findPlugin(JavaPluginConvention.class);
javaPlugin.getSourceSets().getByName("main").getJava().srcDir(subproj.files(JAVA_GENERATED_SOURCE_DIRNAME));
}
代码示例来源:origin: gradle.plugin.de.uni-passau.fim.prog1pa/GradlePlugin
/**
* Applies the {@link JavaPlugin}.
*
* @param project
* the {@link Project} that the {@link Plugin} is applied to
*/
private void applyJavaPlugin(Project project) {
project.getPluginManager().apply(JavaPlugin.class);
JavaPluginConvention javaPluginConv = project.getConvention().findPlugin(JavaPluginConvention.class);
javaPluginConv.setSourceCompatibility(JavaVersion.VERSION_1_8);
javaPluginConv.setTargetCompatibility(JavaVersion.VERSION_1_8);
project.getTasks().withType(JavaCompile.class).forEach(task -> task.getOptions().setEncoding("UTF-8"));
}
代码示例来源:origin: com.github.oehme.sobula/sobula
private Set<String> getGradlePluginDefinitions(final Project subProject) {
Convention _convention = subProject.getConvention();
final JavaPluginConvention java = _convention.<JavaPluginConvention>findPlugin(JavaPluginConvention.class);
boolean _notEquals = (!Objects.equal(java, null));
if (_notEquals) {
代码示例来源:origin: dsyer/spring-boot-thin-launcher
.getPomConfigurer();
MavenPluginConvention maven = getProject().getConvention()
.findPlugin(MavenPluginConvention.class);
if (maven != null) {
output.mkdirs();
代码示例来源:origin: gradle.plugin.de.uni-passau.fim.prog1pa/prog1pa
@Override
public void apply(Project project) {
project.getPluginManager().apply(JavaPlugin.class);
JavaPluginConvention javaPluginConv = project.getConvention().findPlugin(JavaPluginConvention.class);
javaPluginConv.setSourceCompatibility(JavaVersion.VERSION_1_8);
javaPluginConv.setTargetCompatibility(JavaVersion.VERSION_1_8);
project.getPluginManager().apply(IdeaPlugin.class);
project.getRepositories().mavenCentral();
project.getDependencies().add("testCompile", "junit:junit:4.12");
Wrapper wrapper = project.getTasks().create("wrapper", Wrapper.class);
wrapper.setGradleVersion("3.5");
Test test = (Test) project.getTasks().getByName("test");
TestLoggingContainer testLogging = test.getTestLogging();
testLogging.events("failed", "passed");
testLogging.setExceptionFormat(TestExceptionFormat.FULL);
testLogging.setShowStackTraces(false);
}
}
代码示例来源:origin: com.android.tools.build/gradle-core
.findPlugin(JavaPluginConvention.class);
if (convention == null) {
return null;
代码示例来源:origin: typelead/gradle-eta
private void configureInjectionTasks() {
if (isRootProject()) {
project.getGradle().projectsEvaluated
(gradle -> gradle.allprojects
(p -> {
JavaPluginConvention javaConvention =
p.getConvention().findPlugin(JavaPluginConvention.class);
EtaPlugin etaPlugin = p.getPlugins().findPlugin(EtaPlugin.class);
if (javaConvention != null && etaPlugin == null) {
javaConvention.getSourceSets().all
(sourceSet -> configureSourceSetInjection(p, sourceSet));
}
}));
}
}
代码示例来源:origin: typelead/gradle-eta
if (p.getConvention().findPlugin(EtaPluginConvention.class) != null) {
DependencyHandler dependencies = p.getDependencies();
for (Configuration c: p.getConfigurations()) {
if (p.getPlugins().findPlugin(EtaPlugin.class) == null
&& p.getConvention()
.findPlugin(JavaPluginConvention.class) != null) {
p.getTasks().withType(EtaInjectDependencies.class).all
(EtaInjectDependencies::injectDependencies);
代码示例来源:origin: gradle.plugin.de.esoco.gwt/gwt-gradle-plugin
private void addSourceSet(ConfigurableFileCollection sources, Project project, String sourceSet) {
JavaPluginConvention javaConvention = project.getConvention().findPlugin(JavaPluginConvention.class);
if (javaConvention != null) {
SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(sourceSet);
sources
.from(project.files(mainSourceSet.getOutput().getResourcesDir()))
.from(project.files(mainSourceSet.getOutput().getClassesDirs()))
.from(project.files(mainSourceSet.getAllSource().getSrcDirs()));
}
}
代码示例来源:origin: lesfurets/dOOv
JavaPluginConvention javaPluginConvention = target.getConvention().findPlugin(JavaPluginConvention.class);
SourceSet generated = javaPluginConvention.getSourceSets().maybeCreate("generated");
内容来源于网络,如有侵权,请联系作者删除!