-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbuild.gradle
More file actions
165 lines (137 loc) · 4.89 KB
/
Copy pathbuild.gradle
File metadata and controls
165 lines (137 loc) · 4.89 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
plugins {
id 'java'
id 'checkstyle'
alias(libs.plugins.springboot)
alias(libs.plugins.springboot.dependency)
alias(libs.plugins.spotless)
}
def version_number = new File(rootDir.getAbsolutePath(), 'VERSION').readLines()[0].trim()
allprojects {
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java-library'
apply plugin: 'checkstyle'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
group = 'com.isxcode.torch'
version = version_number
repositories {
mavenLocal()
mavenCentral()
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url "https://plugins.gradle.org/m2/" }
}
configurations.configureEach {
exclude group: "org.apache.logging.log4j", module: "log4j-slf4j-impl"
exclude group: "org.slf4j", module: "slf4j-reload4j"
exclude group: "org.slf4j", module: "slf4j-simple"
}
dependencies {
implementation libs.spring.web
implementation libs.spring.aop
implementation libs.spring.validation
annotationProcessor libs.spring.configuration.processor
testImplementation libs.spring.test
compileOnly libs.lombok
annotationProcessor libs.lombok
implementation libs.fastjson
implementation libs.swagger
implementation libs.junit.jupiter
testImplementation libs.junit.jupiter.api
implementation libs.mapstruct.main
implementation libs.mapstruct.processor
annotationProcessor libs.mapstruct.processor
testAnnotationProcessor libs.mapstruct.processor
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
tasks.withType(Checkstyle).configureEach {
maxWarnings = 100
maxErrors = 0
ignoreFailures = false
config resources.text.fromFile(rootDir.getAbsolutePath() + '/.checkstyle/checkstyle.xml')
reports {
xml.required = false
html.required = true
html.stylesheet resources.text.fromFile(rootDir.getAbsolutePath() + '/.checkstyle/checkstyle-simple.xsl')
}
}
}
spotless {
java {
target '*/**/*.java'
targetExclude('*/build/**/*.java', 'torch-yun-dist/**/*.java')
eclipse().configFile(rootDir.getAbsolutePath() + '/.spotless/eclipse-java-google-style.xml')
removeUnusedImports()
}
}
tasks.register("format") {
dependsOn(":torch-yun-dist:copy_version", ":spotlessApply", ":checkstyleMain")
}
tasks.register('package', GradleBuild) {
tasks = ["install", "clean", ":torch-yun-dist:make"]
}
tasks.register('start', Exec) {
commandLine 'sh', '-c', '''
rm -rf torch-yun-dist/build/distributions/zhishuyun
tar -zxf torch-yun-dist/build/distributions/zhishuyun.tar.gz -C torch-yun-dist/build/distributions/
cd torch-yun-dist/build/distributions/zhishuyun/bin
bash start.sh
'''
}
tasks.register('website', Exec) {
commandLine 'sh', '-c', '''
cd docs
pnpm install --force
pnpm run dev
'''
}
tasks.register('frontend', Exec) {
commandLine 'sh', '-c', '''
cd torch-yun-frontend
pnpm install --force
pnpm run dev --host
'''
}
tasks.register('backend') {
dependsOn(":torch-yun-backend:torch-yun-main:bootRun")
}
tasks.register('install', Exec) {
if (!System.properties['os.name'].toString().contains('Mac OS X')) {
doFirst {
exec {
commandLine 'sh', '-c', "sed -i 's/\\r\$//' download.sh && sed -i 's/\\r\$//' install.sh"
}
}
}
commandLine 'sh', '-c', 'bash download.sh && bash install.sh'
}
tasks.register('docker', Exec) {
commandLine 'sh', '-c', '''
docker buildx uninstall
docker build -t isxcode/zhishuyun:''' + version_number + ''' -f ./Dockerfile .
'''
}
tasks.register('upload-ali-oss', Exec) {
commandLine 'sh', '-c', '''
ssh-copy-id root@zhishuyun.isxcode.com
scp torch-yun-dist/build/distributions/zhishuyun.tar.gz root@zhishuyun.isxcode.com:/data/file/
'''
}
tasks.register('upload-docker-hub', Exec) {
commandLine 'sh', '-c', '''
docker buildx install
docker buildx build --platform linux/amd64,linux/arm64/v8 -t isxcode/zhishuyun:''' + version_number + ''' -f ./Dockerfile . --push
'''
}
tasks.register('upload-ali-hub', Exec) {
commandLine 'sh', '-c', '''
docker buildx install
docker buildx build --platform linux/amd64 -t registry.cn-shanghai.aliyuncs.com/isxcode/zhishuyun:''' + version_number + '''-amd64 -f ./Dockerfile . --push
docker buildx build --platform linux/arm64/v8 -t registry.cn-shanghai.aliyuncs.com/isxcode/zhishuyun:''' + version_number + '''-arm64 -f ./Dockerfile . --push
'''
}