From 1e975bef94fe3851744052896faec9e48b7f4078 Mon Sep 17 00:00:00 2001 From: Robin Verduijn Date: Fri, 31 May 2019 13:39:32 -0700 Subject: [PATCH] Fix deprecation warning `The DefaultSourceDirectorySet constructor has been deprecated`. - Fixed by using the ObjectFactory service to create the source directory set This fixes the following deprecation warning seen in any projects that apply the gradle-css-plugin: ``` The DefaultSourceDirectorySet constructor has been deprecated. This is scheduled to be removed in Gradle 6.0. Please use the ObjectFactory service to create instances of SourceDirectorySet instead. ``` --- .../gradle/css/source/internal/DefaultCssSourceSet.groovy | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/eriwen/gradle/css/source/internal/DefaultCssSourceSet.groovy b/src/main/groovy/com/eriwen/gradle/css/source/internal/DefaultCssSourceSet.groovy index cede97b..60da3ce 100644 --- a/src/main/groovy/com/eriwen/gradle/css/source/internal/DefaultCssSourceSet.groovy +++ b/src/main/groovy/com/eriwen/gradle/css/source/internal/DefaultCssSourceSet.groovy @@ -24,7 +24,9 @@ class DefaultCssSourceSet implements CssSourceSet { DefaultCssSourceSet(String name, Project project, Instantiator instantiator, FileResolver fileResolver) { this.name = name this.displayName = GUtil.toWords(name) - if (GradleVersion.current().compareTo(GradleVersion.version("2.12")) >= 0) { + if (GradleVersion.current().compareTo(GradleVersion.version("5.0")) >= 0) { + this.css = project.objects.sourceDirectorySet(name, String.format("%s CSS source", displayName)) + } else if (GradleVersion.current().compareTo(GradleVersion.version("2.12")) >= 0) { Class fileTreeFactory = Class.forName("org.gradle.api.internal.file.collections.DefaultDirectoryFileTreeFactory") def directoryFileTreeFactory = fileTreeFactory.getConstructor().newInstance() this.css = new DefaultSourceDirectorySet(name, String.format("%s CSS source", displayName), fileResolver, directoryFileTreeFactory)