mirror of
https://github.com/Eyre-S/Coeur-Morny-Cono.git
synced 2024-11-23 19:47:38 +08:00
Eyre_S
02819a9069
- ShareToolBilibili now searches all the urls in query string, include b23.tv share url, av/BV id, video url, then rewrites them all and outputs. - ShareToolTwitter now searches all the urls instead of matches in the query string. - ShareToolXhs now uses searchUrls, instead of old match url or search share text. Also supported multiple urls match in one query.
253 lines
8.4 KiB
Groovy
253 lines
8.4 KiB
Groovy
plugins {
|
|
id 'scala'
|
|
id 'java-library'
|
|
id 'application'
|
|
id 'maven-publish'
|
|
id "io.github.ysohda.scalatest" version "0.32.1"
|
|
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
|
id 'com.github.gmazzo.buildconfig' version '4.1.2'
|
|
id 'org.ajoberstar.grgit' version '5.2.0'
|
|
id "me.champeau.jmh" version "0.7.2"
|
|
}
|
|
|
|
import org.ajoberstar.grgit.Status
|
|
|
|
import java.nio.charset.Charset
|
|
import java.nio.charset.StandardCharsets
|
|
|
|
final boolean proj_git = grgit != null
|
|
final String proj_store = MORNY_CODE_STORE
|
|
final String proj_commit = proj_git ? grgit.head().id : null
|
|
final String proj_commit_path = MORNY_COMMIT_PATH
|
|
final boolean proj_clean = isCleanBuild()
|
|
if (!proj_git)
|
|
println "[MornyBuild] git repository not available for current working space! git version tag will be disabled."
|
|
else if (isCleanBuild()) {
|
|
println "git: clean build at ${grgit.head().id}"
|
|
}
|
|
else {
|
|
final Status status = grgit.status()
|
|
println "git: non-clean-build"
|
|
if (!status.unstaged.allChanges.empty) {
|
|
println "git: unstaged changes"
|
|
listChanges(status.unstaged)
|
|
}
|
|
if (!status.staged.allChanges.empty) {
|
|
println "git: staged changes"
|
|
listChanges(status.staged)
|
|
}
|
|
}
|
|
|
|
final String proj_group = 'cc.sukazyo'
|
|
final String proj_package = "${proj_group}.cono.morny"
|
|
final String proj_archive_name = MORNY_ARCHIVE_NAME
|
|
final String proj_application_main = "${proj_package}.ServerMain"
|
|
|
|
final String proj_version_base = VERSION
|
|
final String proj_version_delta = VERSION_DELTA
|
|
final boolean proj_version_use_delta = Boolean.parseBoolean(USE_DELTA)
|
|
final String proj_version = proj_version_base + (proj_version_use_delta ? "-δ${proj_version_delta}" : "")
|
|
final String proj_version_full = proj_version + (proj_git ?
|
|
"+git.${proj_commit.substring(0, 8)}" + (proj_clean ? "" : ".δ") : "")
|
|
final String proj_version_codename = CODENAME
|
|
final long proj_code_time = proj_clean ? grgit.head().dateTime.toInstant().toEpochMilli() : System.currentTimeMillis()
|
|
|
|
final JavaVersion proj_java = JavaVersion.VERSION_17
|
|
final Charset proj_file_encoding = StandardCharsets.UTF_8
|
|
final proj_scala_api = 3
|
|
//final proj_scala_lib = proj_scala_api+'.4.0-RC1-bin-20230901-89e8dba-NIGHTLY'
|
|
final proj_scala_lib = proj_scala_api + '.3.1'
|
|
String publish_local_url = null
|
|
String publish_remote_url = null
|
|
String publish_remote_username = null
|
|
String publish_remote_password = null
|
|
if (project.hasProperty("publishLocalArchiveRepoUrl")) publish_local_url = publishLocalArchiveRepoUrl
|
|
if (project.hasProperty("publishMvnRepoUrl")) {
|
|
publish_remote_url = publishMvnRepoUrl
|
|
publish_remote_username = publishMvnRepoUsername
|
|
publish_remote_password = publishMvnRepoPassword
|
|
}
|
|
|
|
group proj_group
|
|
version proj_version_full
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
maven { name '-ws'; url 'https://mvn.sukazyo.cc/releases' }
|
|
}
|
|
|
|
dependencies {
|
|
|
|
api group: 'org.scala-lang', name: 'scala3-library_3', version: proj_scala_lib
|
|
final scala = (String name) -> "${name}_$proj_scala_api"
|
|
compileOnlyApi group: 'com.github.spotbugs', name: 'spotbugs-annotations', version: lib_spotbugs_v
|
|
|
|
implementation group: 'cc.sukazyo', name: 'messiva', version: lib_messiva_v
|
|
implementation group: 'cc.sukazyo', name: 'resource-tools', version: lib_resourcetools_v
|
|
|
|
implementation group: 'com.github.pengrad', name: 'java-telegram-bot-api', version: lib_javatelegramapi_v
|
|
implementation group: 'com.softwaremill.sttp.client3', name: scala('core'), version: lib_sttp_v
|
|
implementation group: 'com.softwaremill.sttp.client3', name: scala('okhttp-backend'), version: lib_sttp_v
|
|
runtimeOnly group: 'com.squareup.okhttp3', name: 'okhttp', version: lib_okhttp_v
|
|
runtimeOnly group: 'com.squareup.okio', name: 'okio-jvm', version: lib_okio_v
|
|
implementation group: 'com.google.code.gson', name: 'gson', version: lib_gson_v
|
|
implementation group: 'io.circe', name: scala('circe-core'), version: lib_circe_v
|
|
implementation group: 'io.circe', name: scala('circe-generic'), version: lib_circe_v
|
|
implementation group: 'io.circe', name: scala('circe-parser'), version: lib_circe_v
|
|
implementation group: 'io.circe', name: scala('circe-yaml-v12'), version: '0.16.0'
|
|
implementation group: 'org.jsoup', name: 'jsoup', version: lib_jsoup_v
|
|
implementation group: 'com.cronutils', name: 'cron-utils', version: lib_cron_utils_v
|
|
|
|
// used for disable slf4j
|
|
// due to the slf4j api have been used in the following libraries:
|
|
// - cron-utils
|
|
runtimeOnly group: 'org.slf4j', name: 'slf4j-nop', version: lib_slf4j_v
|
|
testRuntimeOnly group: 'org.slf4j', name: 'slf4j-nop', version: lib_slf4j_v
|
|
|
|
testImplementation group: 'cc.sukazyo', name: 'resource-tools', version: lib_resourcetools_v
|
|
testImplementation group: 'org.scalatest', name: scala('scalatest'), version: lib_scalatest_v
|
|
testImplementation group: 'org.scalatest', name: scala('scalatest-freespec'), version: lib_scalatest_v
|
|
testRuntimeOnly group: 'org.scala-lang.modules', name: scala('scala-xml'), version: lib_scalamodule_xml_v
|
|
// for generating HTML report: required by gradle-scalatest plugin
|
|
testRuntimeOnly group: 'com.vladsch.flexmark', name: 'flexmark-all', version: '0.64.8'
|
|
|
|
}
|
|
|
|
java {
|
|
withSourcesJar()
|
|
}
|
|
|
|
sourceSets {
|
|
|
|
main {
|
|
java { destinationDirectory.set file("build/classes/main") }
|
|
scala { destinationDirectory.set file("build/classes/main") }
|
|
}
|
|
|
|
test {
|
|
java { destinationDirectory.set file("build/classes/test") }
|
|
scala { destinationDirectory.set file("build/classes/test") }
|
|
}
|
|
|
|
}
|
|
|
|
tasks.withType(JavaCompile).configureEach {
|
|
|
|
sourceCompatibility proj_java.getMajorVersion()
|
|
targetCompatibility proj_java.getMajorVersion()
|
|
|
|
options.encoding = proj_file_encoding.name()
|
|
|
|
}
|
|
|
|
tasks.withType(ScalaCompile).configureEach {
|
|
|
|
sourceCompatibility proj_java.getMajorVersion()
|
|
targetCompatibility proj_java.getMajorVersion()
|
|
|
|
scalaCompileOptions.additionalParameters.add "-language:postfixOps"
|
|
scalaCompileOptions.additionalParameters.addAll ("-Xmax-inlines", "256")
|
|
|
|
scalaCompileOptions.encoding = proj_file_encoding.name()
|
|
options.encoding = proj_file_encoding.name()
|
|
|
|
}
|
|
|
|
tasks.withType(Javadoc).configureEach {
|
|
options.encoding = proj_file_encoding.name()
|
|
}
|
|
|
|
//tasks.withType(ScalaDoc).configureEach {
|
|
//}
|
|
|
|
test {
|
|
}
|
|
|
|
application {
|
|
mainClass = proj_application_main
|
|
}
|
|
|
|
buildConfig {
|
|
|
|
packageName(proj_package)
|
|
|
|
buildConfigField('String', 'VERSION', "\"${proj_version}\"")
|
|
buildConfigField('String', 'VERSION_FULL', "\"${proj_version_full}\"")
|
|
buildConfigField('String', 'VERSION_BASE', "\"${proj_version_base}\"")
|
|
buildConfigField('String', 'VERSION_DELTA', proj_version_use_delta ? "\"${proj_version_delta}\"" : "null")
|
|
buildConfigField('String', 'CODENAME', "\"${proj_version_codename}\"")
|
|
buildConfigField('long', 'CODE_TIMESTAMP', "${proj_code_time}L")
|
|
buildConfigField('String', 'COMMIT', proj_git ? "\"${proj_commit}\"" : "null")
|
|
buildConfigField('boolean', 'CLEAN_BUILD', "${proj_clean}")
|
|
buildConfigField('String', 'CODE_STORE', proj_store == "" ? "null" : "\"${proj_store}\"")
|
|
buildConfigField('String', 'COMMIT_PATH', proj_commit_path == "" ? "null" : "\"${proj_commit_path}\"")
|
|
|
|
}
|
|
|
|
tasks.withType(Jar).configureEach {
|
|
archiveBaseName.set proj_archive_name
|
|
}
|
|
|
|
shadowJar {
|
|
|
|
archiveClassifier.set "fat"
|
|
|
|
if (project.hasProperty("dockerBuild")) {
|
|
println "shadow-jar: using docker build name"
|
|
archiveVersion.set ""
|
|
archiveClassifier.set "docker-build"
|
|
}
|
|
|
|
}
|
|
|
|
@SuppressWarnings('GrMethodMayBeStatic')
|
|
boolean isCleanBuild () {
|
|
if (grgit == null) return false
|
|
Set<String> changes = grgit.status().unstaged.allChanges + grgit.status().staged.allChanges
|
|
for (String file in changes) {
|
|
if (file.startsWith("src/")) return false
|
|
if (file == "build.gradle") return false
|
|
if (file == "gradle.properties") return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
void listChanges (Status.Changes listing) {
|
|
for (String file in listing.added)
|
|
println " add: ${file}"
|
|
for (String file in listing.modified)
|
|
println " mod: ${file}"
|
|
for (String file in listing.removed)
|
|
println " del: ${file}"
|
|
}
|
|
|
|
publishing {
|
|
repositories {
|
|
if (publish_local_url != null) maven {
|
|
name 'archives'
|
|
url publish_local_url
|
|
}
|
|
if (publish_remote_url != null) maven {
|
|
name '-ws-'
|
|
url publish_remote_url
|
|
credentials {
|
|
username publish_remote_username
|
|
password publish_remote_password
|
|
}
|
|
}
|
|
}
|
|
publications {
|
|
//noinspection GroovyAssignabilityCheck
|
|
main(MavenPublication) {
|
|
//noinspection GroovyAssignabilityCheck
|
|
from components.java
|
|
//noinspection GroovyAssignabilityCheck
|
|
groupId = proj_group
|
|
//noinspection GroovyAssignabilityCheck
|
|
artifactId = proj_archive_name
|
|
//noinspection GroovyAssignabilityCheck
|
|
version = proj_version
|
|
}
|
|
}
|
|
}
|