-
Notifications
You must be signed in to change notification settings - Fork 20
/
theme.gradle
36 lines (31 loc) · 1.07 KB
/
theme.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
apply plugin: ThemePlugin
class ThemePlugin implements Plugin<Project> {
@Override
void apply(Project project) {
def themes = project.container(Theme)
project.extensions.themes = themes
themes.all { theme ->
theme.cssFiles = project.sourceSets.main.resources.matching {
include "com/gluonhq/otn/${theme.name}*.css"
}
def copyTask = project.task("theme${theme.name.capitalize()}", type: Copy) {
from theme.cssFiles
into project.sourceSets.main.output.resourcesDir
rename { String fileName ->
fileName.replace("${theme.name}", "javaone")
}
}
copyTask.dependsOn project.tasks.classes
def task = project.task("theme${theme.name.capitalize()}Run")
task.dependsOn copyTask, project.tasks.run
project.tasks.run.mustRunAfter copyTask
}
}
}
class Theme {
final String name
FileCollection cssFiles
Theme(String name) {
this.name = name
}
}