-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: decouple
views-gradle-plugin
from dependency on `grails-gradle…
…-plugin` The decoupling is intended to mitigate potential circular dependency issues during releases.
- Loading branch information
Showing
3 changed files
with
51 additions
and
7 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
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
46 changes: 46 additions & 0 deletions
46
gradle-plugin/src/main/groovy/grails/views/gradle/util/SourceSets.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,46 @@ | ||
package grails.views.gradle.util | ||
|
||
import groovy.transform.CompileStatic | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
import org.gradle.api.tasks.SourceSet | ||
import org.gradle.api.tasks.SourceSetContainer | ||
|
||
/** | ||
* Copied from grails-gradle-plugin to remove the dependency on that plugin. | ||
* This is a possible candidate for a future "grails-common" module. | ||
* | ||
* @author Graeme Rocher | ||
* @since 3.0 | ||
*/ | ||
@CompileStatic | ||
class SourceSets { | ||
|
||
/** | ||
* Finds the main SourceSet for the project | ||
* @param project The project | ||
* @return The main source set or null if it can't be found | ||
*/ | ||
static SourceSet findMainSourceSet(Project project) { | ||
return findSourceSet(project, SourceSet.MAIN_SOURCE_SET_NAME) | ||
} | ||
|
||
/** | ||
* Finds the main SourceSet for the project | ||
* @param project The project | ||
* @return The main source set or null if it can't be found | ||
*/ | ||
static SourceSet findSourceSet(Project project, String name) { | ||
SourceSetContainer sourceSets = findSourceSets(project) | ||
return sourceSets?.find { SourceSet sourceSet -> | ||
sourceSet.name == name | ||
} as SourceSet | ||
} | ||
|
||
static SourceSetContainer findSourceSets(Project project) { | ||
JavaPluginExtension plugin = project.extensions.getByType(JavaPluginExtension) | ||
SourceSetContainer sourceSets = plugin?.sourceSets | ||
return sourceSets | ||
} | ||
} | ||
|