mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:32:53 +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
|
url: https://api.grasscutter.io/static/handbook.html
|
||||||
target: src/main/resources/html/
|
target: src/main/resources/html/
|
||||||
- name: Run Gradle
|
- name: Run Gradle
|
||||||
run: ./gradlew && ./gradlew jar
|
run: ./gradlew && ./gradlew jar -PskipHandbook=1
|
||||||
- name: Upload build
|
- name: Upload build
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
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
|
import org.gradle.plugins.ide.eclipse.model.SourceFolder
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -220,7 +221,7 @@ publishing {
|
|||||||
maven {
|
maven {
|
||||||
if (version.endsWith('-dev')) {
|
if (version.endsWith('-dev')) {
|
||||||
// Check if the action being ran is 'publish'.
|
// Check if the action being ran is 'publish'.
|
||||||
if (project.hasProperty('publish')) {
|
if (publish.state.executing) {
|
||||||
println('Publishing to Ben4J-Maven')
|
println('Publishing to Ben4J-Maven')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +233,7 @@ publishing {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Check if the action being ran is 'publish'.
|
// Check if the action being ran is 'publish'.
|
||||||
if (project.hasProperty('publish')) {
|
if (publish.state.executing) {
|
||||||
println('Publishing to Sonatype')
|
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 {
|
processResources {
|
||||||
dependsOn 'generateProto'
|
dependsOn 'generateProto'
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user