forked from liferay/liferay-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-themes.gradle
150 lines (118 loc) · 3.21 KB
/
build-themes.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
configurations {
portalToolsBuildThumbnails
portalToolsBuildThumbnails.extendsFrom portalTools
}
dependencies {
portalToolsBuildThumbnails group: "com.liferay", name: "org.monte", version: "0.7.7"
if (exists("docroot/WEB-INF/src")) {
compile configurations.pluginRequiredLibraries
compile project(":shared:portal-compat-shared")
}
else {
providedCompile configurations.pluginRequiredLibraries
}
}
task buildThumbnails
task compileTheme
buildCss {
dependsOn compileTheme
}
buildThumbnails << {
FileTree screenshotsFileTree = fileTree(dir: "docroot/_diffs/images", include: "**/screenshot.png")
screenshotsFileTree.each {
File screenshotFile ->
File thumbnailFile = file(screenshotFile.absolutePath.replace("screenshot.png", "thumbnail.png"))
javaexec {
args(
"thumbnail.original.file=${screenshotFile.absolutePath}",
"thumbnail.thumbnail.file=${thumbnailFile}",
"thumbnail.height=120",
"thumbnail.width=160",
"thumbnail.overwrite=false"
)
classpath configurations.portalToolsBuildThumbnails
main "com.liferay.portal.tools.ThumbnailBuilder"
}
}
}
classes {
dependsOn compileTheme
}
compileTheme {
ext.docrootDir = file("docroot")
ext.diffsDir = file("docroot/_diffs")
afterEvaluate {
if (!project.hasProperty("themeParent")) {
project.ext.themeParent = null
}
if (!project.hasProperty("themeType")) {
project.ext.themeType = "vm"
}
if (themeParent && !(project.themeParent in ["_styled", "_unstyled", "classic", "control_panel"])) {
File themeParentDir = file(themeParent)
if (themeParentDir.exists()) {
themeParent = themeParentDir.name
}
dependsOn ":themes:${themeParent}:compileTheme"
themeParentDir.eachDir {
if (!(it.name in ["_diffs", "WEB-INF"])) {
inputs.dir it
}
}
}
}
dependsOn buildThumbnails
if (diffsDir.exists()) {
inputs.dir diffsDir
docrootDir.eachDir {
if (!(it.name in ["_diffs", "WEB-INF"])) {
outputs.dir it
}
}
}
}
compileTheme << {
Closure copyPortalThemeDir
copyPortalThemeDir = {
String theme, String include, List<String> excludes = [] ->
ant.unzip(dest: docrootDir, src: configurations.portalWeb.singleFile) {
ant.cutdirsmapper(dirs: 3)
ant.patternset() {
excludes.each {
ant.exclude(name: "html/themes/${theme}/${it}")
}
ant.include(name: "html/themes/${theme}/${include}")
}
}
}
if (themeParent in ["_styled", "_unstyled"]) {
copyPortalThemeDir("_unstyled", "**", ["templates/**"])
copyPortalThemeDir("_unstyled", "templates/**/*.${themeType}", ["templates/init.${themeType}"])
}
if (themeParent == "_styled") {
copyPortalThemeDir("_styled", "**")
}
else if (themeParent in ["classic", "control_panel"]) {
copyPortalThemeDir(themeParent, "**", ["**/.sass-cache/**", "_diffs/**", "templates/**"])
copyPortalThemeDir(themeParent, "templates/*.${themeType}")
}
else if (themeParent && (themeParent != "_unstyled")) {
copy {
exclude "**/.sass-cache/**"
exclude "_diffs/**"
exclude "WEB-INF/*.properties"
exclude "WEB-INF/*.xml"
from project(":themes:" + themeParent).file("docroot")
into docrootDir
}
}
if (diffsDir.exists()) {
copy {
from diffsDir
into docrootDir
}
}
}
war {
exclude "_diffs.*", "_diffs/**"
}