Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.netflix.graphql.dgs.codegen.JacksonVersion
import com.netflix.graphql.dgs.codegen.Language
import org.gradle.api.DefaultTask
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.FileCollection
import org.gradle.api.model.ObjectFactory
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.provider.ListProperty
Expand All @@ -39,7 +40,7 @@ import javax.inject.Inject
open class GenerateJavaTask
@Inject
constructor(
objectFactory: ObjectFactory,
private val objectFactory: ObjectFactory,
private val providerFactory: ProviderFactory,
) : DefaultTask() {
@Input
Expand All @@ -48,8 +49,22 @@ open class GenerateJavaTask
.get()
.asFile.absolutePath

@InputFiles
var schemaPaths = mutableListOf<Any>("${project.projectDir}/src/main/resources/schema")
@get:Internal
var schemaPaths: MutableList<Any> = mutableListOf("${project.projectDir}/src/main/resources/schema")

fun setSchemaPaths(paths: FileCollection) {
schemaPaths = mutableListOf(paths)
}

fun setSchemaPaths(paths: Provider<out Iterable<Any>>) {
schemaPaths = mutableListOf(paths)
}

/** The actual Gradle-tracked input: built fresh from schemaPaths every time. */
@get:InputFiles
@get:PathSensitive(PathSensitivity.RELATIVE)
val schemaFiles: FileCollection
get() = objectFactory.fileCollection().from(schemaPaths)

@Input
var packageName = "com.netflix.dgs.codegen.generated"
Expand Down Expand Up @@ -207,19 +222,19 @@ open class GenerateJavaTask
@TaskAction
fun generate() {
val schemaJarFilesFromDependencies = dgsCodegenClasspath.files.toList()
val schemaPaths = schemaPaths.map { Paths.get(it.toString()).toFile() }.sorted().toSet()
schemaPaths.filter { !it.exists() }.forEach {
val resolvedSchemaFiles = schemaFiles.files.sorted().toSet()
resolvedSchemaFiles.filter { !it.exists() }.forEach {
logger.warn("Schema location ${it.absolutePath} does not exist")
}
logger.info("Processing schema files:")
schemaPaths.forEach {
resolvedSchemaFiles.forEach {
logger.info("Processing $it")
}

val config =
CodeGenConfig(
schemas = emptySet(),
schemaFiles = schemaPaths,
schemaFiles = resolvedSchemaFiles,
schemaJarFilesFromDependencies = schemaJarFilesFromDependencies,
outputDir = getOutputDir().toPath(),
examplesOutputDir = getExampleOutputDir().toPath(),
Expand Down
Loading