15 Star 91 Fork 28

Ahoo-Wang / CoSky

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
build.gradle.kts 8.15 KB
一键复制 编辑 原始数据 按行查看 历史
Ahoo-Wang 提交于 2024-02-20 10:24 . add package-lock.json (#339)
/*
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import io.gitlab.arturbosch.detekt.DetektPlugin
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
plugins {
alias(libs.plugins.publishPlugin)
alias(libs.plugins.detekt)
alias(libs.plugins.kotlin)
alias(libs.plugins.dokka)
alias(libs.plugins.jmhPlugin)
jacoco
}
val dependenciesProject = project(":cosky-dependencies")
val bomProjects = setOf(
project(":cosky-bom"),
dependenciesProject,
)
val coreProjects = setOf(
project(":cosky-config"),
project(":cosky-discovery"),
)
val restApiProject = project(":cosky-rest-api")
val serverProjects = setOf(restApiProject)
val exampleProjects = setOf(
project(":cosky-service-provider"),
project(":cosky-service-provider-api"),
project(":cosky-service-consumer"),
)
val testProject = project(":cosky-test")
val codeCoverageReportProject = project(":code-coverage-report")
val publishProjects = subprojects - serverProjects - exampleProjects - codeCoverageReportProject
val libraryProjects = publishProjects - bomProjects
ext.set("libraryProjects", libraryProjects)
allprojects {
repositories {
mavenLocal()
mavenCentral()
}
}
configure(bomProjects) {
apply<JavaPlatformPlugin>()
configure<JavaPlatformExtension> {
allowDependencies()
}
}
configure(libraryProjects) {
apply<DetektPlugin>()
configure<DetektExtension> {
config.setFrom(files("${rootProject.rootDir}/config/detekt/detekt.yml"))
buildUponDefaultConfig = true
autoCorrect = true
}
apply<DokkaPlugin>()
apply<JacocoPlugin>()
apply<JavaLibraryPlugin>()
configure<JavaPluginExtension> {
withJavadocJar()
withSourcesJar()
}
apply(plugin = "org.jetbrains.kotlin.jvm")
configure<KotlinJvmProjectExtension> {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xjvm-default=all-compatibility")
}
}
apply<me.champeau.jmh.JMHPlugin>()
configure<me.champeau.jmh.JmhParameters> {
val delimiter = ','
val jmhIncludesKey = "jmhIncludes"
val jmhExcludesKey = "jmhExcludes"
val jmhThreadsKey = "jmhThreads"
val jmhModeKey = "jmhMode"
if (project.hasProperty(jmhIncludesKey)) {
val jmhIncludes = project.properties[jmhIncludesKey].toString().split(delimiter)
includes.set(jmhIncludes)
}
if (project.hasProperty(jmhExcludesKey)) {
val jmhExcludes = project.properties[jmhExcludesKey].toString().split(delimiter)
excludes.set(jmhExcludes)
}
warmupIterations.set(1)
iterations.set(1)
resultFormat.set("json")
var jmhMode = listOf(
"thrpt",
)
if (project.hasProperty(jmhModeKey)) {
jmhMode = project.properties[jmhModeKey].toString().split(delimiter)
}
benchmarkMode.set(jmhMode)
var jmhThreads = 1
if (project.hasProperty(jmhThreadsKey)) {
jmhThreads = Integer.valueOf(project.properties[jmhThreadsKey].toString())
}
threads.set(jmhThreads)
fork.set(1)
jvmArgs.set(listOf("-Dlogback.configurationFile=${rootProject.rootDir}/config/logback-jmh.xml"))
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
exceptionFormat = TestExceptionFormat.FULL
}
// fix logging missing code for JacocoPlugin
jvmArgs = listOf("-Dlogback.configurationFile=${rootProject.rootDir}/config/logback.xml")
}
dependencies {
api(platform(dependenciesProject))
detektPlugins(platform(dependenciesProject))
jmh(platform(dependenciesProject))
implementation("org.slf4j:slf4j-api")
testImplementation("ch.qos.logback:logback-classic")
testImplementation("org.hamcrest:hamcrest")
testImplementation("io.mockk:mockk") {
exclude(group = "org.slf4j", module = "slf4j-api")
}
testImplementation("org.junit.jupiter:junit-jupiter-api")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting")
jmh("org.openjdk.jmh:jmh-core")
jmh("org.openjdk.jmh:jmh-generator-annprocess")
}
}
configure(publishProjects) {
val isBom = bomProjects.contains(this)
apply<MavenPublishPlugin>()
apply<SigningPlugin>()
configure<PublishingExtension> {
repositories {
maven {
name = "projectBuildRepo"
url = uri(layout.buildDirectory.dir("repos"))
}
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/Ahoo-Wang/CoSky")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
publications {
val publishName = if (isBom) "mavenBom" else "mavenLibrary"
val publishComponentName = if (isBom) "javaPlatform" else "java"
create<MavenPublication>(publishName) {
from(components[publishComponentName])
pom {
name.set(rootProject.name)
description.set(getPropertyOf("description"))
url.set(getPropertyOf("website"))
issueManagement {
system.set("GitHub")
url.set(getPropertyOf("issues"))
}
scm {
url.set(getPropertyOf("website"))
connection.set(getPropertyOf("vcs"))
}
licenses {
license {
name.set(getPropertyOf("license_name"))
url.set(getPropertyOf("license_url"))
distribution.set("repo")
}
}
developers {
developer {
id.set("ahoo-wang")
name.set("ahoo wang")
organization {
url.set(getPropertyOf("website"))
}
}
}
}
}
}
}
configure<SigningExtension> {
val isInCI = null != System.getenv("CI")
if (isInCI) {
val signingKeyId = System.getenv("SIGNING_KEYID")
val signingKey = System.getenv("SIGNING_SECRETKEY")
val signingPassword = System.getenv("SIGNING_PASSWORD")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
}
if (isBom) {
sign(extensions.getByType(PublishingExtension::class).publications.get("mavenBom"))
} else {
sign(extensions.getByType(PublishingExtension::class).publications.get("mavenLibrary"))
}
}
}
nexusPublishing {
this.repositories {
sonatype {
username.set(System.getenv("MAVEN_USERNAME"))
password.set(System.getenv("MAVEN_PASSWORD"))
}
}
}
fun getPropertyOf(name: String) = project.properties[name]?.toString()
Kotlin
1
https://gitee.com/AhooWang/CoSky.git
git@gitee.com:AhooWang/CoSky.git
AhooWang
CoSky
CoSky
main

搜索帮助