forked from ajoberstar/gradle-git-publish
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ObjectFactory.directoryProperty() if possible
ProjectLayout.directoryProperty() was deprecated in Gradle 5.0 and replaced with ObjectFactory.directoryProperty(). In order to stay backward compatible with Gradle 4.x, the latter is now called first and the former is used as a fallback. Resolves ajoberstar#64.
- Loading branch information
1 parent
1c2ea1f
commit 5706d17
Showing
3 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/org/ajoberstar/gradle/git/publish/tasks/DirectoryPropertyFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.ajoberstar.gradle.git.publish.tasks; | ||
|
||
import org.gradle.api.Project; | ||
import org.gradle.api.file.DirectoryProperty; | ||
import org.gradle.api.file.ProjectLayout; | ||
import org.gradle.api.model.ObjectFactory; | ||
|
||
/** | ||
* For backward compatibility with Gradle 4.x | ||
*/ | ||
public class DirectoryPropertyFactory { | ||
|
||
private DirectoryPropertyFactory() { | ||
} | ||
|
||
public static DirectoryProperty create(Project project) { | ||
return create(project.getLayout(), project.getObjects()); | ||
} | ||
|
||
public static DirectoryProperty create(ProjectLayout layout, ObjectFactory objectFactory) { | ||
try { | ||
return objectFactory.directoryProperty(); | ||
} catch (NoSuchMethodError e) { | ||
return layout.directoryProperty(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters