78 lines
1.6 KiB
Groovy
78 lines
1.6 KiB
Groovy
plugins {
|
|
id 'java'
|
|
id 'java-library'
|
|
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
|
id 'maven-publish'
|
|
}
|
|
|
|
group = project_group
|
|
version = project_version
|
|
|
|
java {
|
|
toolchain {
|
|
languageVersion = JavaLanguageVersion.of(17)
|
|
}
|
|
}
|
|
|
|
base {
|
|
archivesName = "${project_name}-${common_suffix}"
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
// Common 依赖 CommonApi
|
|
api project(':CommonApi')
|
|
}
|
|
|
|
// Sources JAR
|
|
task sourcesJar(type: Jar) {
|
|
from sourceSets.main.allSource
|
|
archiveClassifier = 'sources'
|
|
}
|
|
|
|
// Javadoc JAR
|
|
task javadocJar(type: Jar) {
|
|
dependsOn javadoc
|
|
from javadoc.destinationDir
|
|
archiveClassifier = 'javadoc'
|
|
}
|
|
|
|
// Shadow JAR: 只把 CommonApi 打包进 Common
|
|
shadowJar {
|
|
// 只把 CommonApi 的源代码 + Common 自己的源代码打包
|
|
from sourceSets.main.output // Common 自己的代码
|
|
from project(':CommonApi').sourceSets.main.output // CommonApi 的代码
|
|
|
|
// 不要包含 runtimeClasspath 的依赖
|
|
configurations = [] // 空数组,不包含其它依赖
|
|
|
|
mergeServiceFiles()
|
|
archiveClassifier.set('') // 覆盖默认 jar
|
|
}
|
|
|
|
|
|
// 将 shadowJar 绑定到 build
|
|
build.dependsOn shadowJar
|
|
|
|
// Javadoc 配置
|
|
javadoc {
|
|
options.encoding = 'UTF-8'
|
|
}
|
|
|
|
// 发布配置
|
|
publishing {
|
|
publications {
|
|
mavenJava(MavenPublication) {
|
|
artifact shadowJar
|
|
artifact sourcesJar
|
|
artifact javadocJar
|
|
groupId = project.group.toString()
|
|
artifactId = base.archivesName.get()
|
|
version = project.version.toString()
|
|
}
|
|
}
|
|
}
|