<commit_before>package org.xtext.gradle;

import javax.inject.Inject;

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.internal.file.FileResolver
import org.gradle.api.plugins.BasePlugin
import org.xtext.gradle.tasks.XtextExtension
import org.xtext.gradle.tasks.XtextGenerate

class XtextPlugin implements Plugin<Project> {

	FileResolver fileResolver

	@Inject
	XtextPlugin(FileResolver fileResolver) {
		this.fileResolver = fileResolver
	}

	def void apply(Project project) {
		project.plugins.apply(BasePlugin)
		def XtextExtension xtext = project.extensions.create("xtext", XtextExtension, project, fileResolver);
		project.configurations.create("xtext")
		project.afterEvaluate{
			def XtextGenerate generatorTask = project.tasks.create("xtextGenerate", XtextGenerate)
			generatorTask.configure(xtext)
			project.tasks[BasePlugin.ASSEMBLE_TASK_NAME].dependsOn(generatorTask)
			project.dependencies.add("xtext", "org.eclipse.xtext:org.eclipse.xtext:${xtext.version}")
		}
	}
}<commit_msg>Add main java sources to Xtext sources if a language needs Java and the Java plugin is found<commit_after>package org.xtext.gradle;

import javax.inject.Inject;

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.internal.file.FileResolver
import org.gradle.api.plugins.BasePlugin
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSet;
import org.xtext.gradle.tasks.XtextExtension
import org.xtext.gradle.tasks.XtextGenerate

class XtextPlugin implements Plugin<Project> {

	FileResolver fileResolver

	@Inject
	XtextPlugin(FileResolver fileResolver) {
		this.fileResolver = fileResolver
	}

	def void apply(Project project) {
		project.plugins.apply(BasePlugin)
		def XtextExtension xtext = project.extensions.create("xtext", XtextExtension, project, fileResolver);
		project.configurations.create("xtext")
		project.afterEvaluate{
			def XtextGenerate generatorTask = project.tasks.create("xtextGenerate", XtextGenerate)
			def java = project.convention.findPlugin(JavaPluginConvention)
			def needJava = xtext.languages.any {it.consumesJava}
			if (needJava && java != null) {
				xtext.sources.source(java.sourceSets.main.java)
			}
			generatorTask.configure(xtext)
			project.tasks[BasePlugin.ASSEMBLE_TASK_NAME].dependsOn(generatorTask)
			project.dependencies.add("xtext", "org.eclipse.xtext:org.eclipse.xtext:${xtext.version}")
		}
	}
}
{'fraction_non_alphanumeric': 0.10362903225806451, 'fraction_numerical': 0.0, 'mean_word_length': 5.778688524590164, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6015531', 'n_tokens_mistral': 819, 'n_tokens_neox': 755, 'n_words': 135}