Publish the sources properly

Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
shedaniel
2021-06-20 20:35:42 +08:00
parent 9f1809ce33
commit d1e8d82ddb
5 changed files with 50 additions and 21 deletions

View File

@@ -87,6 +87,10 @@ allprojects {
return changes.toString()
}
}
java {
withSourcesJar()
}
}
task licenseFormatAll

View File

@@ -14,20 +14,22 @@ architectury {
common(false)
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
afterEvaluate {
remapJar {
remapAccessWidener.set false
}
}
publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = rootProject.archivesBaseName
artifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}.jar")) {
builtBy build
}
artifact(sourcesJar) {
builtBy remapSourcesJar
artifact(remapJar)
afterEvaluate {
artifact(remapSourcesJar.output) {
builtBy remapSourcesJar
classifier "sources"
}
}
}
}

View File

@@ -1,7 +0,0 @@
{
"_comment": "This file is here to make fabric loader load this on the Knot classloader.",
"schemaVersion": 1,
"id": "architectury-common",
"version": "0.0.1",
"accessWidener": "architectury.accessWidener"
}

View File

@@ -61,13 +61,28 @@ remapJar {
archiveClassifier = "fabric"
}
sourcesJar {
afterEvaluate {
[":common"].forEach {
def depSources = project(it).sourcesJar
dependsOn depSources
from(depSources.archiveFile.map { zipTree(it) }) {
exclude "architectury.accessWidener"
}
}
}
}
publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archivesBaseName + "-fabric"
artifact(remapJar.archivePath) {
builtBy build
classifier null
artifact(remapJar) { classifier null }
afterEvaluate {
artifact(remapSourcesJar.output) {
builtBy remapSourcesJar
classifier "sources"
}
}
}
}

View File

@@ -58,13 +58,28 @@ remapJar {
archiveClassifier = "forge"
}
sourcesJar {
afterEvaluate {
[":common"].forEach {
def depSources = project(it).sourcesJar
dependsOn depSources
from(depSources.archiveFile.map { zipTree(it) }) {
exclude "architectury.accessWidener"
}
}
}
}
publishing {
publications {
mavenForge(MavenPublication) {
artifactId = rootProject.archivesBaseName + "-forge"
artifact(remapJar.archivePath) {
builtBy build
classifier null
artifact(remapJar) { classifier null }
afterEvaluate {
artifact(remapSourcesJar.output) {
builtBy remapSourcesJar
classifier "sources"
}
}
}
}