forked from uncle-novel/uncle-novel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
122 lines (106 loc) · 3.54 KB
/
build.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
plugins {
id "org.openjfx.javafxplugin" version "0.0.11" apply false
id "io.spring.dependency-management" version "1.0.9.RELEASE" apply false
id "com.unclezs.gradle.sass" version "1.0.10" apply false
}
ext {
jfxProject = ['app', 'app-framework']
jfxProject = subprojects.findAll { jfxProject.contains(it.name) }
}
allprojects {
group = "com.unclezs.novel.app"
version = property("app.version")
description = "Uncle Novel Project"
repositories {
maven { url("https://oss.sonatype.org/content/groups/public/") }
mavenCentral()
google()
}
}
subprojects { project ->
apply plugin: "java"
apply from: "${rootDir}/gradle/publications.gradle"
apply from: "${rootDir}/gradle/dependency-management.gradle"
sourceSets {
main {
output.resourcesDir = java.classesDirectory
resources {
exclude '**/*.scss'
}
}
}
ext.compilerArgs = []
ext.runtimeArgs = []
// 模块化编译参数
File vmArgs = file("$projectDir/${project.name}.modularity")
if (vmArgs.exists()) {
vmArgs.readLines().each {
if (!it.isBlank() && !it.startsWith("//")) {
if (!it.startsWith("--add-opens")) {
ext.compilerArgs.add(it)
}
ext.runtimeArgs.add(it)
}
}
}
tasks.withType(JavaCompile) {
options.fork = true
options.encoding = "UTF-8"
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
// 模块化编译参数
options.compilerArgs.addAll(compilerArgs)
}
dependencies {
compileOnly "org.projectlombok:lombok"
annotationProcessor "org.projectlombok:lombok"
testImplementation "org.junit.jupiter:junit-jupiter-api"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
}
test {
useJUnitPlatform()
include(["**/*Tests.class", "**/*Test.class"])
}
}
configure(jfxProject) { project ->
apply plugin: "org.openjfx.javafxplugin"
// 因为 jsass 不适配 mac m1,停用此插件,采用原生 saas 编译
// apply plugin: "com.unclezs.gradle.sass"
javafx {
version = "17.0.2"
modules = ["javafx.base", "javafx.controls", "javafx.fxml", "javafx.graphics", "javafx.media", "javafx.swing", "javafx.web"]
}
jar {
exclude "*.scss"
}
def compileScss = {
def scssDir = file("${sourceSets.main.resources.srcDirs[0]}/css")
for (final def file in fileTree(scssDir)) {
if (file.isDirectory()) {
continue
}
if (file.name.endsWith("scss") && !file.name.startsWith("_")) {
try {
exec(new Action<ExecSpec>() {
@Override
void execute(ExecSpec es) {
es.executable("sass")
es.args("--no-source-map", "--no-charset", file.absolutePath, file.absolutePath.replace("scss", "css"))
}
})
} catch (ignored) {
println "编译 scss 失败,请确认是否已经安装了 sass"
return
}
println "compile scss to css: $file.name"
} else if (file.name.endsWith(".map")) {
file.delete()
}
}
}
tasks.withType(JavaCompile) {
doFirst {
compileScss()
}
}
}