Skip to content

Commit

Permalink
fix build to populate sources jar
Browse files Browse the repository at this point in the history
  • Loading branch information
erdo committed Apr 11, 2024
1 parent 503c77c commit 5a22faf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
10 changes: 4 additions & 6 deletions n8-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ android {
kotlinCompilerExtensionVersion = libs.versions.composeCompilerVersion.get()
}

// register (not create) - we want this to run after the rest of the android
// block has been configured in the individual build files as they add files
// to the source sets
project.tasks.register("androidSourcesJar", Jar::class.java) {
archiveClassifier.set("sources")
from(sourceSets.getByName("main").java.srcDirs)
publishing {
singleVariant("release") {
withSourcesJar()
}
}
}

Expand Down
27 changes: 2 additions & 25 deletions publish-android-lib.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ project.afterEvaluate {
publications {
create<MavenPublication>("release") {

from(components["release"])

groupId = "${Shared.Publish.LIB_GROUP}"
artifactId = LIB_ARTIFACT_ID
version = "${Shared.Publish.LIB_VERSION_NAME}"

artifact(tasks["bundleReleaseAar"])
artifact(project.tasks["androidSourcesJar"])

pom {
name.set("${Shared.Publish.PROJ_NAME}")
description.set(LIB_DESCRIPTION)
Expand All @@ -49,28 +48,6 @@ project.afterEvaluate {
developerConnection.set("${Shared.Publish.POM_SCM_CONNECTION}")
url.set("${Shared.Publish.POM_SCM_URL}")
}

withXml {
val dependenciesNode = asNode().appendNode("dependencies")

// List all compile dependencies and write to POM
fun addDependency(dep: Dependency, scope: String) {
if (dep.group == null || dep.version == null || dep.name == "unspecified") {
return
} // Ignore invalid dependencies.

val dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", dep.group)
dependencyNode.appendNode("artifactId", dep.name)
dependencyNode.appendNode("version", dep.version)
dependencyNode.appendNode("scope", scope)
}

// List all "api" dependencies (for new Gradle) as "compile" dependencies.
configurations.getByName("api").dependencies.forEach { addDependency(it, "compile") }
// List all "implementation" dependencies (for new Gradle) as "runtime" dependencies.
configurations.getByName("implementation").dependencies.forEach { addDependency(it, "runtime") }
}
}
}
}
Expand Down

0 comments on commit 5a22faf

Please sign in to comment.