1- import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2-
31plugins {
42 alias(libs.plugins.android.library)
5- alias(libs.plugins.kotlin.android)
63 alias(libs.plugins.kotlin.compose)
74 alias(libs.plugins.kotlin.serialization)
5+ alias(libs.plugins.jetbrains.dokka)
86
97 id(" maven-publish" )
108
@@ -26,7 +24,6 @@ android {
2624 kotlin {
2725 compilerOptions {
2826 freeCompilerArgs.addAll(" -Xcontext-sensitive-resolution" )
29- jvmTarget = JvmTarget .fromTarget(libs.versions.jvmTarget.get())
3027 }
3128 }
3229
@@ -38,26 +35,6 @@ android {
3835 dataBinding = false
3936 }
4037
41- sourceSets[" main" ].java {
42- srcDirs(
43- " src/main/kotlin" ,
44- " src/common/kotlin" ,
45- " src/debug/kotlin" ,
46- " src/release/kotlin" ,
47- " src/staging/kotlin" ,
48- " src/preproduction/kotlin"
49- )
50- }
51-
52- // Add this to your android block to generate Javadoc from Kotlin sources
53- // (if you are using Dokka, the setup is different)
54- // For basic Javadoc with KDoc:
55- tasks.withType<Javadoc > {
56- source(android.sourceSets[" main" ].java.srcDirs)
57- classpath + = project.files(android.bootClasspath.joinToString(File .pathSeparator))
58- // Exclude generated files if necessary
59- exclude(" **/R.class" , " **/BuildConfig.class" )
60- }
6138
6239 publishing {
6340 singleVariant(" release" ) {
@@ -83,80 +60,70 @@ dependencies {
8360 implementation(libs.kotlin.extensions.library)
8461}
8562
86- afterEvaluate {
87- publishing {
88- publications {
89- // Configure the "release" publication that AGP's `singleVariant("release")` creates.
90- // The name of the publication created by AGP for singleVariant("release")
91- // is conventionally the name of the variant itself, so "release".
92- // However, it's safer to configure all MavenPublications of type MavenPublication if you only have one.
93- // Or, if you know the name is 'release' (which it should be for singleVariant("release")).
94-
95- // Option A: Configure the specific publication if you are sure of its name
96- // (AGP creates one named after the variant, so "release" in this case)
97- // AGP creates a publication named after the variant, so "release" in this case.
98- create<MavenPublication >(" release" ) {
99- // The `from(components["release"])` is often handled automatically by singleVariant,
100- // but explicitly adding it inside afterEvaluate can sometimes help ensure timing.
101- // If you still have issues, you can try re-adding it here.
102- from(components[" release" ]) // Already handled by singleVariant("release") usually
103-
104-
105- groupId = " com.github.forteanjo"
106- artifactId = " compose-extensions"
107- version = " 1.0.0"
108-
109- // Add these for sources and Javadoc
110- // artifact(tasks.named("sourcesJar")) // Assumes you have a sourcesJar task (see below)
111- // artifact(tasks.named("javadocJar")) // Assumes you have a javadocJar task (see below)
112-
113- pom {
114- name.set(project.name) // Or a custom name
115- description.set(" Useful Jetpack compose extensions for Android development." ) // Example description
116- url.set(" https://github.com/Forteanjo/Compose_Extensions_Library" ) // Example URL
117-
118- licenses {
119- license {
120- name.set(" The MIT License" ) // Or your chosen license
121- url.set(" http://opensource.org/licenses/MIT" )
122- }
123- }
63+ // Creates a JAR file from the output of the dokkaHtml task.
64+ // This is used to publish the documentation along with the library.
65+ tasks.register<Jar >(" javadocJar" ) {
66+ dependsOn(tasks.named(" dokkaHtml" ))
67+ from(tasks.named< org.jetbrains.dokka.gradle.DokkaTask > (" dokkaHtml" ).flatMap { it.outputDirectory })
68+ archiveClassifier.set(" javadoc" )
69+ }
70+
71+ publishing {
72+ publications {
73+ // Configure the "release" publication that AGP's `singleVariant("release")` creates.
74+ // The name of the publication created by AGP for singleVariant("release")
75+ // is conventionally the name of the variant itself, so "release".
76+ // However, it's safer to configure all MavenPublications of type MavenPublication if you only have one.
77+ // Or, if you know the name is 'release' (which it should be for singleVariant("release")).
78+
79+ // Option A: Configure the specific publication if you are sure of its name
80+ // (AGP creates one named after the variant, so "release" in this case)
81+ // AGP creates a publication named after the variant, so "release" in this case.
82+ create<MavenPublication >(" release" ) {
83+ groupId = " com.github.forteanjo"
84+ artifactId = " compose-extensions"
85+ version = " 1.0.1"
86+
87+ afterEvaluate {
88+ from(components[" release" ])
89+ }
12490
125- developers {
126- developer {
127- id.set(" forteanjo" )
128- name.set(" Donald McCaskey" )
129- email.set(" forteanjo@sky.com" )
130- }
91+ // Include the JAR generated by the javadocJar task in the publication.
92+ artifact(tasks.named(" javadocJar" ))
93+
94+ pom {
95+ name.set(project.name) // Or a custom name
96+ description.set(" Useful Jetpack compose extensions for Android development." ) // Example description
97+ url.set(" https://github.com/Forteanjo/Compose_Extensions_Library" ) // Example URL
98+
99+ licenses {
100+ license {
101+ name.set(" The MIT License" ) // Or your chosen license
102+ url.set(" http://opensource.org/licenses/MIT" )
131103 }
104+ }
132105
133- scm {
134- connection.set(" scm:git:git://github.com/forteanjo/Compose_Extensions_Library.git" )
135- developerConnection.set(" scm:git:ssh://github.com/forteanjo/Compose_Extensions_Library.git" )
136- url.set(" https://github.com/forteanjo/Compose_Extensions_Library/tree/main" )
106+ developers {
107+ developer {
108+ id.set(" forteanjo" )
109+ name.set(" Donald McCaskey" )
110+ email.set(" forteanjo@sky.com" )
137111 }
138112 }
139- }
140113
141- // Option B (Safer if you're unsure of the exact auto-generated publication name,
142- // but assumes you only have ONE publication being created by android.publishing):
143- // withType<MavenPublication>().configureEach {
144- // // This will apply to ANY MavenPublication. Be careful if you have others.
145- // if (name == "release") { // Double-check the name if using this more general approach
146- // groupId = "com.github.forteanjo"
147- // artifactId = "extensions"
148- // version = "1.0.0"
149- //
150- // pom { /* ... as above ... */ }
151- // }
152- // }
114+ scm {
115+ connection.set(" scm:git:git://github.com/forteanjo/Compose_Extensions_Library.git" )
116+ developerConnection.set(" scm:git:ssh://github.com/forteanjo/Compose_Extensions_Library.git" )
117+ url.set(" https://github.com/forteanjo/Compose_Extensions_Library/tree/main" )
118+ }
119+ }
153120 }
121+ }
154122
155- repositories {
156- maven {
157- name = " localRelease"
158- url = uri(" ${layout.buildDirectory} /repo" )
159- }
123+ repositories {
124+ maven {
125+ name = " localRelease"
126+ url = uri(" ${layout.buildDirectory} /repo" )
160127 }
161128 }
162129}
0 commit comments