mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-09 03:42:57 +08:00
Build the handbook with Gradle
This commit is contained in:
parent
2107866787
commit
77796aa8b6
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -43,7 +43,7 @@ jobs:
|
||||
url: https://api.grasscutter.io/static/handbook.html
|
||||
target: src/main/resources/html/
|
||||
- name: Run Gradle
|
||||
run: ./gradlew && ./gradlew jar
|
||||
run: ./gradlew && ./gradlew jar -PskipHandbook=1
|
||||
- name: Upload build
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
|
42
build.gradle
42
build.gradle
@ -1,3 +1,4 @@
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
||||
|
||||
/*
|
||||
@ -220,7 +221,7 @@ publishing {
|
||||
maven {
|
||||
if (version.endsWith('-dev')) {
|
||||
// Check if the action being ran is 'publish'.
|
||||
if (project.hasProperty('publish')) {
|
||||
if (publish.state.executing) {
|
||||
println('Publishing to Ben4J-Maven')
|
||||
}
|
||||
|
||||
@ -232,7 +233,7 @@ publishing {
|
||||
}
|
||||
} else {
|
||||
// Check if the action being ran is 'publish'.
|
||||
if (project.hasProperty('publish')) {
|
||||
if (publish.state.executing) {
|
||||
println('Publishing to Sonatype')
|
||||
}
|
||||
|
||||
@ -323,6 +324,43 @@ public final class BuildConfig {
|
||||
}"""
|
||||
}
|
||||
|
||||
tasks.register('generateHandbook') {
|
||||
if (project.hasProperty('skipHandbook')) {
|
||||
println('Skipping handbook generation.')
|
||||
return
|
||||
}
|
||||
|
||||
def nodeVersion = {
|
||||
try {
|
||||
return 'node --version'.execute().text.trim()
|
||||
} catch (ignored) {
|
||||
return 'NODE_NOT_FOUND'
|
||||
}
|
||||
}
|
||||
|
||||
// Check if Node is installed.
|
||||
if (nodeVersion() == 'NODE_NOT_FOUND') {
|
||||
println('Node is not installed. Skipping handbook generation.')
|
||||
} else {
|
||||
// Build the handbook.
|
||||
var npm = 'npm'
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS))
|
||||
npm = 'npm.cmd'
|
||||
|
||||
exec {
|
||||
workingDir 'src/handbook'
|
||||
commandLine npm, 'run', 'build'
|
||||
}
|
||||
|
||||
// Copy the handbook from /dist to /src/main/resources.
|
||||
copy {
|
||||
from 'src/handbook/dist/index.html'
|
||||
into 'src/main/resources'
|
||||
rename 'index.html', 'handbook.html'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
dependsOn 'generateProto'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user