build: 优化构建脚本
优化构建脚本
This commit is contained in:
15
build.gradle
15
build.gradle
@@ -18,6 +18,11 @@ subprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
api.extendsFrom apiShade
|
||||||
|
implementation.extendsFrom implementationShade
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly group: 'org.jetbrains', name: 'annotations', version: '21.0.1'
|
compileOnly group: 'org.jetbrains', name: 'annotations', version: '21.0.1'
|
||||||
}
|
}
|
||||||
@@ -38,14 +43,10 @@ subprojects {
|
|||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
|
||||||
destinationDir(rootProject.buildDir)
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
from getProject().getComponents().java
|
from project.components.java
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
@@ -56,8 +57,8 @@ subprojects {
|
|||||||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
||||||
|
|
||||||
credentials {
|
credentials {
|
||||||
username rootProject.getProperties().getOrDefault("maven_username", "")
|
username rootProject.properties.getOrDefault("maven_username", "")
|
||||||
password rootProject.getProperties().getOrDefault("maven_password", "")
|
password rootProject.properties.getOrDefault("maven_password", "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,13 +2,10 @@ setArchivesBaseName("HamsterCore-Bukkit")
|
|||||||
|
|
||||||
evaluationDependsOn(':hamster-core-common')
|
evaluationDependsOn(':hamster-core-common')
|
||||||
|
|
||||||
configurations {
|
|
||||||
api.extendsFrom apiShade
|
|
||||||
implementation.extendsFrom implementationShade
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly project(":hamster-core-common")
|
apiShade(project(":hamster-core-common")) {
|
||||||
|
exclude group: "*"
|
||||||
|
}
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT'
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/com.zaxxer/HikariCP
|
// https://mvnrepository.com/artifact/com.zaxxer/HikariCP
|
||||||
@@ -34,24 +31,13 @@ processResources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task addSource {
|
tasks.compileJava.dependsOn(":hamster-core-common:build")
|
||||||
doLast {
|
tasks.create("shadowJar", Jar) {
|
||||||
sourceSets {
|
dependsOn("jar")
|
||||||
main {
|
|
||||||
java.srcDirs += [
|
|
||||||
project(':hamster-core-common').sourceSets.main.java
|
|
||||||
]
|
|
||||||
resources.srcDirs += [
|
|
||||||
project(':hamster-core-common').sourceSets.main.resources
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
classes.dependsOn(addSource)
|
|
||||||
|
|
||||||
jar {
|
|
||||||
from([
|
from([
|
||||||
|
tasks.jar.outputs.files.collect {
|
||||||
|
it.isDirectory() ? it : zipTree(it)
|
||||||
|
},
|
||||||
configurations.implementationShade.collect {
|
configurations.implementationShade.collect {
|
||||||
it.isDirectory() ? it : zipTree(it)
|
it.isDirectory() ? it : zipTree(it)
|
||||||
},
|
},
|
||||||
@@ -59,4 +45,6 @@ jar {
|
|||||||
it.isDirectory() ? it : zipTree(it)
|
it.isDirectory() ? it : zipTree(it)
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
destinationDir(getRootProject().buildDir)
|
||||||
}
|
}
|
||||||
|
tasks.build.dependsOn(shadowJar)
|
||||||
|
@@ -2,13 +2,10 @@ setArchivesBaseName("HamsterCore-Proxy")
|
|||||||
|
|
||||||
evaluationDependsOn(':hamster-core-common')
|
evaluationDependsOn(':hamster-core-common')
|
||||||
|
|
||||||
configurations {
|
|
||||||
api.extendsFrom apiShade
|
|
||||||
implementation.extendsFrom implementationShade
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly project(":hamster-core-common")
|
apiShade(project(":hamster-core-common")) {
|
||||||
|
exclude group: "*"
|
||||||
|
}
|
||||||
//noinspection GradlePackageUpdate
|
//noinspection GradlePackageUpdate
|
||||||
compileOnly('net.md-5:bungeecord-api:1.17-R0.1-SNAPSHOT')
|
compileOnly('net.md-5:bungeecord-api:1.17-R0.1-SNAPSHOT')
|
||||||
|
|
||||||
@@ -35,24 +32,13 @@ processResources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task addSource {
|
tasks.compileJava.dependsOn(":hamster-core-common:build")
|
||||||
doLast {
|
tasks.create("shadowJar", Jar) {
|
||||||
sourceSets {
|
dependsOn("jar")
|
||||||
main {
|
|
||||||
java.srcDirs += [
|
|
||||||
project(':hamster-core-common').sourceSets.main.java
|
|
||||||
]
|
|
||||||
resources.srcDirs += [
|
|
||||||
project(':hamster-core-common').sourceSets.main.resources
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
classes.dependsOn(addSource)
|
|
||||||
|
|
||||||
jar {
|
|
||||||
from([
|
from([
|
||||||
|
tasks.jar.outputs.files.collect {
|
||||||
|
it.isDirectory() ? it : zipTree(it)
|
||||||
|
},
|
||||||
configurations.implementationShade.collect {
|
configurations.implementationShade.collect {
|
||||||
it.isDirectory() ? it : zipTree(it)
|
it.isDirectory() ? it : zipTree(it)
|
||||||
},
|
},
|
||||||
@@ -60,4 +46,6 @@ jar {
|
|||||||
it.isDirectory() ? it : zipTree(it)
|
it.isDirectory() ? it : zipTree(it)
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
destinationDir(getRootProject().buildDir)
|
||||||
}
|
}
|
||||||
|
tasks.build.dependsOn(shadowJar)
|
||||||
|
Reference in New Issue
Block a user