Revert "Remove sourceFileExtensions input"
This reverts commit f81e49f210.
This commit is contained in:
-12
@@ -122,18 +122,6 @@ abstract class KaptGenerateStubsTask @Inject constructor(
|
|||||||
patternFilterable.include { it.isDirectory || it.file.isSourceRootAllowed() }
|
patternFilterable.include { it.isDirectory || it.file.isSourceRootAllowed() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@get:Internal
|
|
||||||
override val scriptSources: FileCollection = objectFactory.fileCollection()
|
|
||||||
|
|
||||||
override val incrementalProps: List<FileCollection>
|
|
||||||
get() = listOf(
|
|
||||||
sources,
|
|
||||||
javaSources,
|
|
||||||
commonSourceSet,
|
|
||||||
classpathSnapshotProperties.classpath,
|
|
||||||
classpathSnapshotProperties.classpathSnapshot
|
|
||||||
)
|
|
||||||
|
|
||||||
override val javaSources: FileCollection = super.javaSources
|
override val javaSources: FileCollection = super.javaSources
|
||||||
.asFileTree
|
.asFileTree
|
||||||
.matching { patternFilterable ->
|
.matching { patternFilterable ->
|
||||||
|
|||||||
+1
-5
@@ -164,11 +164,7 @@ internal fun addSourcesToKotlinCompileTask(
|
|||||||
// In this call, the super-implementation of `source` adds the directories files to the roots of the union file tree,
|
// In this call, the super-implementation of `source` adds the directories files to the roots of the union file tree,
|
||||||
// so it's OK to pass just the source roots.
|
// so it's OK to pass just the source roots.
|
||||||
setSource(Callable(sources))
|
setSource(Callable(sources))
|
||||||
with(sourceFileExtensions.toSet()) {
|
sourceFilesExtensions.addAll(sourceFileExtensions)
|
||||||
if (isNotEmpty()) {
|
|
||||||
include(flatMap { ext -> ext.fileExtensionCasePermutations().map { "**/*.$it" } })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The `commonSourceSet` is passed to the compiler as-is, converted with toList
|
// The `commonSourceSet` is passed to the compiler as-is, converted with toList
|
||||||
commonSourceSet.from(
|
commonSourceSet.from(
|
||||||
|
|||||||
+5
-1
@@ -59,7 +59,11 @@ class DefaultKotlinSourceSet(
|
|||||||
val intransitiveMetadataConfigurationName: String
|
val intransitiveMetadataConfigurationName: String
|
||||||
get() = lowerCamelCaseName(disambiguateName(INTRANSITIVE), METADATA_CONFIGURATION_NAME_SUFFIX)
|
get() = lowerCamelCaseName(disambiguateName(INTRANSITIVE), METADATA_CONFIGURATION_NAME_SUFFIX)
|
||||||
|
|
||||||
override val kotlin: SourceDirectorySet = createDefaultSourceDirectorySet(project, "$name Kotlin source")
|
override val kotlin: SourceDirectorySet = createDefaultSourceDirectorySet(project, "$name Kotlin source").apply {
|
||||||
|
filter.include("**/*.java")
|
||||||
|
filter.include("**/*.kt")
|
||||||
|
filter.include("**/*.kts")
|
||||||
|
}
|
||||||
|
|
||||||
override val languageSettings: LanguageSettingsBuilder = DefaultLanguageSettingsBuilder()
|
override val languageSettings: LanguageSettingsBuilder = DefaultLanguageSettingsBuilder()
|
||||||
|
|
||||||
|
|||||||
+34
-1
@@ -68,7 +68,7 @@ class ScriptingGradleSubplugin : Plugin<Project> {
|
|||||||
discoveryClasspathConfiguration.allDependencies.isEmpty() -> {
|
discoveryClasspathConfiguration.allDependencies.isEmpty() -> {
|
||||||
// skip further checks - user did not configured any discovery sources
|
// skip further checks - user did not configured any discovery sources
|
||||||
}
|
}
|
||||||
else -> task.scriptDefinitions.from(discoveryClasspathConfiguration)
|
else -> configureScriptsExtensions(project, javaPluginConvention, task.sourceSetName.get())
|
||||||
}
|
}
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
project.logger.warn("$SCRIPTING_LOG_PREFIX applied in the non-supported environment (error received: ${e.message})")
|
project.logger.warn("$SCRIPTING_LOG_PREFIX applied in the non-supported environment (error received: ${e.message})")
|
||||||
@@ -85,6 +85,39 @@ class ScriptingGradleSubplugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun configureScriptsExtensions(
|
||||||
|
project: Project,
|
||||||
|
javaPluginConvention: JavaPluginConvention,
|
||||||
|
sourceSetName: String
|
||||||
|
) {
|
||||||
|
javaPluginConvention.sourceSets.findByName(sourceSetName)?.let { sourceSet ->
|
||||||
|
|
||||||
|
val discoveryResultsConfigurationName = getDiscoveryResultsConfigurationName(sourceSetName)
|
||||||
|
|
||||||
|
val kotlinSourceSet = sourceSet.getConvention(KOTLIN_DSL_NAME) as? KotlinSourceSet
|
||||||
|
if (kotlinSourceSet == null) {
|
||||||
|
project.logger.warn("$SCRIPTING_LOG_PREFIX kotlin source set not found: $project.$sourceSet, $MISCONFIGURATION_MESSAGE_SUFFIX")
|
||||||
|
} else {
|
||||||
|
val extensions by lazy {
|
||||||
|
val discoveryResultsConfiguration = project.configurations.findByName(discoveryResultsConfigurationName)
|
||||||
|
if (discoveryResultsConfiguration == null) {
|
||||||
|
project.logger.warn("$SCRIPTING_LOG_PREFIX discovery results not found: $project.$discoveryResultsConfigurationName, $MISCONFIGURATION_MESSAGE_SUFFIX")
|
||||||
|
emptySet<String>()
|
||||||
|
} else {
|
||||||
|
discoveryResultsConfiguration.files.flatMapTo(HashSet()) {
|
||||||
|
it.readLines().filter(String::isNotBlank)
|
||||||
|
}.also {
|
||||||
|
kotlinSourceSet.addCustomSourceFilesExtensions(it.toList())
|
||||||
|
project.logger.debug("$SCRIPTING_LOG_PREFIX $project.$sourceSet: discovered script extensions: $it")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
kotlinSourceSet.kotlin.filter.include { it.file.extension in extensions }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val MAIN_CONFIGURATION_NAME = "kotlinScriptDef"
|
private const val MAIN_CONFIGURATION_NAME = "kotlinScriptDef"
|
||||||
|
|||||||
+10
-48
@@ -18,7 +18,6 @@ import org.gradle.api.model.ObjectFactory
|
|||||||
import org.gradle.api.provider.ListProperty
|
import org.gradle.api.provider.ListProperty
|
||||||
import org.gradle.api.provider.Property
|
import org.gradle.api.provider.Property
|
||||||
import org.gradle.api.provider.Provider
|
import org.gradle.api.provider.Provider
|
||||||
import org.gradle.api.provider.SetProperty
|
|
||||||
import org.gradle.api.services.BuildService
|
import org.gradle.api.services.BuildService
|
||||||
import org.gradle.api.services.BuildServiceParameters
|
import org.gradle.api.services.BuildServiceParameters
|
||||||
import org.gradle.api.specs.Spec
|
import org.gradle.api.specs.Spec
|
||||||
@@ -104,6 +103,12 @@ abstract class AbstractKotlinCompileTool<T : CommonToolArguments> @Inject constr
|
|||||||
{ sourceFiles.asFileTree.matching(patternFilterable) }
|
{ sourceFiles.asFileTree.matching(patternFilterable) }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Deprecated("Use PatternFilterable methods to configure sources")
|
||||||
|
@get:Input
|
||||||
|
val sourceFilesExtensions: ListProperty<String> = objectFactory
|
||||||
|
.listProperty(String::class.java)
|
||||||
|
.convention(DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the source for this task.
|
* Sets the source for this task.
|
||||||
* The given source object is evaluated as per [org.gradle.api.Project.files].
|
* The given source object is evaluated as per [org.gradle.api.Project.files].
|
||||||
@@ -742,7 +747,6 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
get() = listOf(
|
get() = listOf(
|
||||||
sources,
|
sources,
|
||||||
javaSources,
|
javaSources,
|
||||||
scriptSources,
|
|
||||||
commonSourceSet,
|
commonSourceSet,
|
||||||
classpathSnapshotProperties.classpath,
|
classpathSnapshotProperties.classpath,
|
||||||
classpathSnapshotProperties.classpathSnapshot
|
classpathSnapshotProperties.classpathSnapshot
|
||||||
@@ -787,47 +791,10 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
@get:Internal
|
@get:Internal
|
||||||
internal abstract val jvmTargetValidationMode: Property<PropertiesProvider.JvmTargetValidationMode>
|
internal abstract val jvmTargetValidationMode: Property<PropertiesProvider.JvmTargetValidationMode>
|
||||||
|
|
||||||
@get:Internal
|
|
||||||
internal val scriptDefinitions: ConfigurableFileCollection = objectFactory.fileCollection()
|
|
||||||
|
|
||||||
@get:Input
|
|
||||||
@get:Optional
|
|
||||||
internal val scriptExtensions: SetProperty<String> = objectFactory.setPropertyWithLazyValue {
|
|
||||||
scriptDefinitions
|
|
||||||
.map { definitionFile ->
|
|
||||||
definitionFile.readLines().filter(String::isNotBlank)
|
|
||||||
}
|
|
||||||
.flatten()
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ScriptFilterSpec(
|
|
||||||
private val scriptExtensions: SetProperty<String>
|
|
||||||
) : Spec<FileTreeElement> {
|
|
||||||
override fun isSatisfiedBy(element: FileTreeElement): Boolean {
|
|
||||||
val extensions = scriptExtensions.get()
|
|
||||||
return extensions.isNotEmpty() &&
|
|
||||||
(element.isDirectory || extensions.contains(element.file.extension))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val scriptSourceFiles = objectFactory.fileCollection()
|
|
||||||
|
|
||||||
@get:InputFiles
|
|
||||||
@get:SkipWhenEmpty
|
|
||||||
@get:IgnoreEmptyDirectories
|
|
||||||
@get:PathSensitive(PathSensitivity.RELATIVE)
|
|
||||||
internal open val scriptSources: FileCollection = scriptSourceFiles
|
|
||||||
.asFileTree
|
|
||||||
.matching { patternFilterable ->
|
|
||||||
patternFilterable.include(ScriptFilterSpec(scriptExtensions))
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
incremental = true
|
incremental = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun skipCondition(): Boolean = sources.isEmpty && scriptSources.isEmpty
|
|
||||||
|
|
||||||
override fun createCompilerArgs(): K2JVMCompilerArguments =
|
override fun createCompilerArgs(): K2JVMCompilerArguments =
|
||||||
K2JVMCompilerArguments()
|
K2JVMCompilerArguments()
|
||||||
|
|
||||||
@@ -862,7 +829,6 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
) {
|
) {
|
||||||
validateKotlinAndJavaHasSameTargetCompatibility(args, kotlinSources)
|
validateKotlinAndJavaHasSameTargetCompatibility(args, kotlinSources)
|
||||||
|
|
||||||
val scriptSources = scriptSources.asFileTree.files
|
|
||||||
val messageCollector = GradlePrintingMessageCollector(logger, args.allWarningsAsErrors)
|
val messageCollector = GradlePrintingMessageCollector(logger, args.allWarningsAsErrors)
|
||||||
val outputItemCollector = OutputItemsCollectorImpl()
|
val outputItemCollector = OutputItemsCollectorImpl()
|
||||||
val compilerRunner = compilerRunner.get()
|
val compilerRunner = compilerRunner.get()
|
||||||
@@ -890,14 +856,12 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
- (classpathSnapshotProperties.classpathSnapshotDir.orNull?.asFile?.let { setOf(it) } ?: emptySet()),
|
- (classpathSnapshotProperties.classpathSnapshotDir.orNull?.asFile?.let { setOf(it) } ?: emptySet()),
|
||||||
reportingSettings = reportingSettings(),
|
reportingSettings = reportingSettings(),
|
||||||
incrementalCompilationEnvironment = icEnv,
|
incrementalCompilationEnvironment = icEnv,
|
||||||
kotlinScriptExtensions = scriptExtensions.get().toTypedArray()
|
kotlinScriptExtensions = sourceFilesExtensions.get().toTypedArray()
|
||||||
)
|
)
|
||||||
logger.info("Kotlin source files: ${kotlinSources.joinToString()}")
|
logger.info("Kotlin source files: ${kotlinSources.joinToString()}")
|
||||||
logger.info("Java source files: ${javaSources.files.joinToString()}")
|
logger.info("Java source files: ${javaSources.files.joinToString()}")
|
||||||
logger.info("Script source files: ${scriptSources.joinToString()}")
|
|
||||||
logger.info("Script file extensions: ${scriptExtensions.get().joinToString()}")
|
|
||||||
compilerRunner.runJvmCompilerAsync(
|
compilerRunner.runJvmCompilerAsync(
|
||||||
(kotlinSources + scriptSources).toList(),
|
kotlinSources.toList(),
|
||||||
commonSourceSet.toList(),
|
commonSourceSet.toList(),
|
||||||
javaSources.files, // we need here only directories where Java sources are located
|
javaSources.files, // we need here only directories where Java sources are located
|
||||||
javaPackagePrefix,
|
javaPackagePrefix,
|
||||||
@@ -987,17 +951,15 @@ abstract class KotlinCompile @Inject constructor(
|
|||||||
.matching(::javaFilesPatternFilter)
|
.matching(::javaFilesPatternFilter)
|
||||||
)
|
)
|
||||||
|
|
||||||
// override setSource to track Java and script sources as well
|
// override setSource to track Java sources as well
|
||||||
override fun setSource(source: Any) {
|
override fun setSource(source: Any) {
|
||||||
javaSourceFiles.from(source)
|
javaSourceFiles.from(source)
|
||||||
scriptSourceFiles.from(source)
|
|
||||||
super.setSource(source)
|
super.setSource(source)
|
||||||
}
|
}
|
||||||
|
|
||||||
// override source to track Java and script sources as well
|
// override source to track Java sources as well
|
||||||
override fun setSource(vararg source: Any) {
|
override fun setSource(vararg source: Any) {
|
||||||
javaSourceFiles.from(*source)
|
javaSourceFiles.from(*source)
|
||||||
scriptSourceFiles.from(*source)
|
|
||||||
super.setSource(*source)
|
super.setSource(*source)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-9
@@ -15,7 +15,6 @@ import org.gradle.api.provider.Property
|
|||||||
import org.gradle.api.provider.Provider
|
import org.gradle.api.provider.Provider
|
||||||
import org.gradle.api.provider.SetProperty
|
import org.gradle.api.provider.SetProperty
|
||||||
import org.gradle.api.tasks.TaskProvider
|
import org.gradle.api.tasks.TaskProvider
|
||||||
import org.gradle.kotlin.dsl.setProperty
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.properties.ReadOnlyProperty
|
import kotlin.properties.ReadOnlyProperty
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
@@ -49,14 +48,6 @@ internal inline fun <reified T : Any?> ObjectFactory.property(initialValue: T) =
|
|||||||
|
|
||||||
internal inline fun <reified T : Any?> ObjectFactory.property(initialValue: Provider<T>) = property<T>().value(initialValue)
|
internal inline fun <reified T : Any?> ObjectFactory.property(initialValue: Provider<T>) = property<T>().value(initialValue)
|
||||||
|
|
||||||
internal inline fun <reified T : Any?> ObjectFactory.setPropertyWithValue(
|
|
||||||
initialValue: Provider<Iterable<T>>
|
|
||||||
) = setProperty<T>().value(initialValue)
|
|
||||||
|
|
||||||
internal inline fun <reified T : Any?> ObjectFactory.setPropertyWithLazyValue(
|
|
||||||
noinline lazyValue: () -> Iterable<T>
|
|
||||||
) = setPropertyWithValue(providerWithLazyConvention(lazyValue))
|
|
||||||
|
|
||||||
internal inline fun <reified T : Any?> ObjectFactory.propertyWithConvention(
|
internal inline fun <reified T : Any?> ObjectFactory.propertyWithConvention(
|
||||||
conventionValue: Provider<T>
|
conventionValue: Provider<T>
|
||||||
) = property<T>().convention(conventionValue)
|
) = property<T>().convention(conventionValue)
|
||||||
|
|||||||
Reference in New Issue
Block a user