Skip to content

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 May 31, 2019
1 parent 21fecd4 commit 1e975be
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

2 comments on commit 1e975be

@edgargs
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear Robin. I try use this version in my project.

  1. Clone this branch
  2. Change version (2.15.0)
  3. Build
  4. Publish to Local Repo
  5. Add configuration "buildscript"
    But, i have the same error with original css plugin.
    Please, you help with a example for that.

@robinverduijn
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only fixed the other remaining deprecation warning, but you would also need to get the fixes from an as-yet-unmerged pull request at eriwen#52 to be completely warning-free, I think.

Please sign in to comment.