-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SourceSetUtils: Use plugin convention only when project is using Grad…
…le older than 7.1 (#362)
- Loading branch information
Showing
4 changed files
with
38 additions
and
13 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/groovy/com/netflix/nebula/lint/SourceSetUtils.groovy
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,25 @@ | ||
package com.netflix.nebula.lint | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.JavaPluginConvention | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
import org.gradle.api.tasks.SourceSetContainer | ||
import org.gradle.util.GradleVersion | ||
|
||
class SourceSetUtils { | ||
static boolean hasSourceSets(Project project) { | ||
if (isOlderThanGradle7_1(project)) { | ||
return project.convention.findPlugin(JavaPluginConvention) | ||
} else { | ||
return project.extensions.findByType(JavaPluginExtension) | ||
} | ||
} | ||
|
||
static SourceSetContainer getSourceSets(Project project) { | ||
return isOlderThanGradle7_1(project) ? project.convention.getPlugin(JavaPluginConvention).sourceSets : project.extensions.getByType(JavaPluginExtension).sourceSets | ||
} | ||
|
||
private static boolean isOlderThanGradle7_1(Project project) { | ||
return GradleVersion.version(project.gradle.gradleVersion).compareTo(GradleVersion.version("7.1")) < 0 | ||
} | ||
} |
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
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
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