Skip to content

Commit

Permalink
Add publish to maven repository
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedRejeb committed May 2, 2023
1 parent 99d907f commit 5894ac8
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 26 deletions.
83 changes: 81 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group "com.mocoding"
version "1.0-SNAPSHOT"
group = "com.mohamedrejeb.richeditor"
version = "0.1.0"

buildscript {
repositories {
Expand All @@ -20,4 +20,83 @@ allprojects {
mavenCentral()
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}

group = "com.mohamedrejeb.richeditor"
version = "0.1.0"

// apply(plugin = "org.jetbrains.dokka")
apply(plugin = "maven-publish")
apply(plugin = "signing")

extensions.configure<PublishingExtension> {
repositories {
maven {
val isSnapshot = version.toString().endsWith("SNAPSHOT")
url = uri(
if (!isSnapshot) "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2"
else "https://s01.oss.sonatype.org/content/repositories/snapshots"
)

credentials {
username = System.getenv("OssrhUsername")
password = System.getenv("OssrhPassword")
}
}
}

val javadocJar = tasks.register<Jar>("javadocJar") {
// dependsOn(tasks.dokkaHtml)
archiveClassifier.set("javadoc")
// from("$buildDir/dokka")
}

publications {
withType<MavenPublication> {
artifact(javadocJar)

pom {
name.set("Compose Rich Editor")
description.set("A Compose multiplatform library that provides a rich text editor.")
licenses {
license {
name.set("Apache-2.0")
url.set("https://opensource.org/licenses/Apache-2.0")
}
}
url.set("https://github.com/MohamedRejeb/Compose-Rich-Editor")
issueManagement {
system.set("Github")
url.set("https://github.com/MohamedRejeb/Compose-Rich-Editor/issues")
}
scm {
connection.set("https://github.com/MohamedRejeb/Compose-Rich-Editor.git")
url.set("https://github.com/MohamedRejeb/Compose-Rich-Editor")
}
developers {
developer {
name.set("Mohamed Rejeb")
email.set("mohamedrejeb445@gmail.com")
}
}
}
}
}
}

val publishing = extensions.getByType<PublishingExtension>()
extensions.configure<SigningExtension> {
useInMemoryPgpKeys(
System.getenv("SigningKeyId"),
System.getenv("SigningKey"),
System.getenv("SigningPassword"),
)

sign(publishing.publications)
}

// TODO: remove after https://youtrack.jetbrains.com/issue/KT-46466 is fixed
// project.tasks.withType(AbstractPublishToMaven::class.java).configureEach {
// dependsOn(project.tasks.withType(Sign::class.java))
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugins {
id("com.android.library")
}

group = "com.mocoding"
version = "1.0-SNAPSHOT"
group = "com.mohamedrejeb.richeditor"
version = "0.1.0"

kotlin {
android()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mohamedrejeb.richeditor.model

data class RichTextPart(
internal data class RichTextPart(
val fromIndex: Int,
val toIndex: Int,
val styles: Set<RichTextStyle>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ import kotlin.math.min

@Immutable
data class RichTextValue internal constructor(
val textFieldValue: TextFieldValue,
internal val textFieldValue: TextFieldValue,
val currentStyles: Set<RichTextStyle> = emptySet(),
val parts: List<RichTextPart> = emptyList(),
internal val parts: List<RichTextPart> = emptyList(),
) {

val visualTransformation
internal val visualTransformation
get() = VisualTransformation {
TransformedText(
text = annotatedString,
offsetMapping = OffsetMapping.Identity
)
}

val annotatedString
internal val annotatedString
get() = AnnotatedString(
text = textFieldValue.text,
spanStyles = parts.map { part ->
Expand All @@ -44,11 +44,10 @@ data class RichTextValue internal constructor(
constructor(
text: String = "",
currentStyles: Set<RichTextStyle> = emptySet(),
parts: List<RichTextPart> = emptyList(),
) : this(
textFieldValue = TextFieldValue(text = text),
currentStyles = currentStyles,
parts = parts,
parts = emptyList(),
)

fun addStyle(vararg style: RichTextStyle): RichTextValue {
Expand All @@ -75,7 +74,7 @@ data class RichTextValue internal constructor(
return copy(currentStyles = newStyles)
}

fun updateTextFieldValue(newTextFieldValue: TextFieldValue): RichTextValue {
internal fun updateTextFieldValue(newTextFieldValue: TextFieldValue): RichTextValue {
val newParts = parts.toMutableList()

if (newTextFieldValue.text.length > textFieldValue.text.length) {
Expand Down
3 changes: 0 additions & 3 deletions sample/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ plugins {
kotlin("android")
}

group "com.mocoding"
version "1.0-SNAPSHOT"

android {
namespace = "com.mocoding.richeditor.android"
compileSdk = (findProperty("android.compileSdk") as String).toInt()
Expand Down
14 changes: 8 additions & 6 deletions sample/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ plugins {
id("com.android.library")
}

group = "com.mocoding"
version = "1.0-SNAPSHOT"

kotlin {
android()
jvm("desktop") {
Expand Down Expand Up @@ -43,7 +40,8 @@ kotlin {
api(compose.materialIconsExtended)

implementation(libs.kotlinx.serialization.json)
implementation(project(":richeditor"))
implementation("com.mohamedrejeb.richeditor:richeditor-compose:0.1.0")
// implementation(project(":richeditor-compose"))
}
}

Expand All @@ -61,7 +59,9 @@ kotlin {

val jsMain by getting {
dependsOn(commonMain)
dependencies {}
dependencies {

}
}

val iosX64Main by getting
Expand All @@ -72,7 +72,9 @@ kotlin {
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
dependencies {}
dependencies {

}
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions sample/desktop/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ plugins {
id("org.jetbrains.compose")
}

group = "com.mocoding"
version = "1.0-SNAPSHOT"


kotlin {
jvm {
jvmToolchain(11)
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ include(
":sample:desktop",
":sample:web",
":sample:common",
":richeditor"
":richeditor-compose"
)

0 comments on commit 5894ac8

Please sign in to comment.