Skip to content
This repository has been archived by the owner on Jul 17, 2022. It is now read-only.

Commit

Permalink
Fix deprecation warning `The DefaultSourceDirectorySet constructor ha…
Browse files Browse the repository at this point in the history
…s 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.
```
  • Loading branch information
robinverduijn committed Oct 6, 2019
1 parent 28a0953 commit a52f13f
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a52f13f

Please sign in to comment.