Coeur-Morny-Cono/build.gradle
Eyre_S e3c273b370
将 GradleProjectConfigures 变更为使用 BuildConfig 工具,添加了 version_delta
- archiveBaseName 更名为 'morny-coeur'
- 现在在 getJarMd5 时遇到文件读写错误不会再输出错误堆栈信息了
- gradle 基本的参数化
2022-11-06 20:07:11 +08:00

119 lines
2.9 KiB
Groovy

import java.nio.charset.Charset
import java.nio.charset.StandardCharsets
plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id 'application'
id 'com.github.johnrengelman.shadow' version '7.1.0'
id 'com.github.gmazzo.buildconfig' version '3.1.0'
}
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_version_base = VERSION
final String proj_version_delta = VERSION_DELTA
final String proj_version_use_delta = Boolean.parseBoolean(VERSION_DELTA)
final String proj_version = proj_version_base + (proj_version_use_delta ? "-δ${proj_version_delta}" : "")
final String proj_version_codename = CODENAME
final JavaVersion proj_java = JavaVersion.VERSION_17
final Charset proj_file_encoding = StandardCharsets.UTF_8
group proj_group
version proj_version
project.ext.archiveBaseName = proj_archive_name
project.ext.artifactId = proj_archive_name
mainClassName = "${proj_package}.ServerMain"
repositories {
mavenCentral()
maven { name '-ws'; url 'https://mvn.sukazyo.cc/releases' }
}
dependencies {
compileOnlyApi "com.github.spotbugs:spotbugs-annotations:${libSpotbugsVersion}"
api "cc.sukazyo:messiva:${libMessivaVersion}"
implementation "com.github.pengrad:java-telegram-bot-api:${libJavaTelegramBotApiVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-api:${libJunitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${libJunitVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${libJunitVersion}"
}
test {
useJUnitPlatform()
}
java {
sourceCompatibility proj_java
targetCompatibility proj_java
withSourcesJar()
}
tasks.withType(JavaCompile) {
options.encoding = proj_file_encoding.name()
}
tasks.withType(Javadoc) {
options.encoding = proj_file_encoding.name()
options.docEncoding = proj_file_encoding.name()
options.charSet = proj_file_encoding.name()
}
tasks.test {
useJUnitPlatform()
}
buildConfig {
packageName(proj_package)
buildConfigField('String', 'VERSION', "\"${proj_version}\"")
buildConfigField('String', 'VERSION_DELTA', "\"${proj_version_delta}\"")
buildConfigField('String', 'CODENAME', "\"${proj_version_codename}\"")
buildConfigField('long', 'COMPILE_TIMESTAMP', "${System.currentTimeMillis()}L")
}
shadowJar {
archiveBaseName.set("${project.ext.archiveBaseName}")
archiveVersion.set("${project.version}")
archiveClassifier.set("fat")
}
publishing {
repositories{
maven {
name 'builds'
url publishLocalArchiveRepoUrl
}
maven {
name '-ws-'
url publishMvnRepoUrl
credentials {
username publishMvnRepoUsername
password publishMvnRepoPassword
}
}
}
publications {
main (MavenPublication) {
from components.java
groupId = project.group
artifactId = project.ext.artifactId
version = project.version
}
}
}