Skip to content

Commit

Permalink
Maven first publication (#13)
Browse files Browse the repository at this point in the history
* Added support for Maven publication

* Optimized signing order

* Added KodeView to versions

* Bumped to maven version

* Added more sections to README.md

* Corrected examples section
  • Loading branch information
tmaxxdd authored Sep 18, 2023
1 parent a5cc78b commit d3333e5
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 147 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
## [0.5.0]

### Added
- Maven publication

### Changed
- README sections
- KodeView dependency import style

## [0.4.0]

### Added
- Maven local publication

### Changed
- KodeView import model

## [0.3.1]

### Added

- Web section to README

## [0.3.0]
Expand Down
148 changes: 58 additions & 90 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
![kodeview_banner_opaque](https://github.com/SnipMeDev/KodeView/assets/8405055/59c6a2af-1b32-4a02-998f-ecae2296363a)

[![Maven Central](https://img.shields.io/maven-central/v/dev.snipme/kodeview)](https://mvnrepository.com/artifact/dev.snipme)
[![Kotlin](https://img.shields.io/badge/kotlin-1.9.10-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![GitHub License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0)

# KodeView

Kotlin Compose Multiplatform components for syntax highlighting based on
[Highlights](https://github.com/SnipMeDev/Highlights/blob/main/CHANGELOG.md) library.
[Highlights](https://github.com/SnipMeDev/Highlights) library.

## Preview

<img width="1680" alt="iShot_2023-09-14_08 19 21" src="https://github.com/SnipMeDev/KodeView/assets/8405055/adb205e4-ea16-41f7-aacb-de1085d6d5f5">

## Installation
TBD
## Installation ⬇️
```shell
repositories {
mavenCentral()
}
```

## Components
```shell
implementation("dev.snipme:kodeview:0.5.0")
```

### CodeTextView
The basic component that takes instance of Highlights and applies coloring on text.
## Features ✨
- CodeTextView UI view
- Code component analysis (Keyword, comment, etc.)
- Multiple syntax languages (Java, Swift, Kotlin, C, ...)
- Themes
- Text bolding (emphasis)
- Written in pure Kotlin, so available for many platforms 📱 💻 🖥️

## Support ☕
Kotlin Multiplatform is a fresh environment and developing for it is neither fast nor easy 🥲

If you feel that any of our project has saved you a time or effort, then consider supporting us via:
[🧋 Buy Me A Coffee](https://bmc.link/SnipMeDev)

#### Android
## Components 🧩

### CodeTextView
The basic component that takes instance of Highlights and applies coloring on a text.

```kotlin
@Composable
Expand All @@ -40,92 +64,36 @@ fun MyApp() {
}
```

#### iOS
## Run examples 🏎️

```swift
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
Not all examples can be executed from command line, so recommended way is to use pre-created configurations:

struct ContentView: View {
@State var highlights = Highlights.companion.default()

init() {
highlights.setCode(code: "public static void main(String[] args) {}")
}

var body: some View {
VStack {
CodeTextView(newHighlights: $highlights)
.ignoresSafeArea(.keyboard)
.padding()
}
}
}
```
<img width="270" alt="iShot_2023-09-18_08 19 44" src="https://github.com/SnipMeDev/KodeView/assets/8405055/be660f49-5a77-445e-a717-6aaec9b5c28a">

#### Desktop
## TODO 🚧
- [ ] CodeEditText

```kotlin
private val windowSize = 500.dp

fun main() = application {
Window(
onCloseRequest = ::exitApplication,
state = rememberWindowState(
width = windowSize,
height = windowSize,
)
) {
val highlights = remember {
mutableStateOf(
Highlights
.default()
.getBuilder()
.code("public static void main(String[] args) {}")
.build()
)
}

MaterialTheme {
Column {
CodeTextView(highlights = highlights.value)
}
}
}
}
```
## Contribution 💻
Any form of support is very welcomed.
Bugs, problems and new feature requests should be placed in the `Issues` tab with proper labeling.
New feature can be also submitted via `Pull Requests`.
Then make sure:
- CHANGELOG and README have been updated
- New code matches library's vision and code style

#### Web
License 🖋️
=======

```kotlin
@ExperimentalComposeUiApi
fun main() {
onWasmReady {
CanvasBasedWindow(
canvasElementId = "ComposeTarget",
applyDefaultStyles = true,
) {
val highlights = remember {
mutableStateOf(
Highlights
.default()
.getBuilder()
.code("public static void main(String[] args) {}")
.build()
)
}

MaterialTheme {
Column {
CodeTextView(highlights = highlights.value)
}
}
}
}
}
```
Copyright 2023 Tomasz Kądziołka.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2 changes: 1 addition & 1 deletion androidExample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ dependencies {
implementation("androidx.compose.ui:ui-tooling-preview")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
implementation("dev.snipme:kodeview:0.4.0")
implementation(libs.kodeview)
}
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ plugins {
id("com.android.library") apply false
id("org.jetbrains.compose") apply false
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
}
}

apply(from = "publish-root.gradle")
2 changes: 1 addition & 1 deletion desktopExample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
implementation(compose.desktop.currentOs)
implementation("dev.snipme:kodeview:0.4.0")
implementation(libs.kodeview)
}

compose.desktop {
Expand Down
4 changes: 4 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ kotlinMultiplatform = "1.9.10"
compose = "1.5.1"
composeCompiler = "1.5.1"
androidLibrary = "8.0.0"
kodeview = "0.5.0"

[libraries]
kodeview = { group = "dev.snipme", name = "kodeview", version.ref = "kodeview" }

[plugins]
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
Expand Down
125 changes: 72 additions & 53 deletions kodeview/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.compose)
id("maven-publish")
id("signing")
}

group = "dev.snipme"
version = "0.4.0"
version = "0.5.0"

android {
namespace = "dev.snipme.kodeview"
Expand Down Expand Up @@ -44,58 +45,6 @@ kotlin {
}
}

publishing {
val emptyJar = tasks.register<Jar>("emptyJar") {
archiveAppendix.set("empty")
}

publications.forEach {
val publication = it as? MavenPublication ?: return@forEach

publication.artifact(emptyJar) {
classifier = "javadoc"
}

publication.pom.withXml {
val root = asNode()
root.appendNode("name", "kodeview")
root.appendNode(
"description",
"Kotlin Multiplatform syntax highlighting views"
)
root.appendNode("url", "https://github.com/SnipMeDev/KodeView")

root.appendNode("licenses").apply {
appendNode("license").apply {
appendNode("name", "The Apache Software License, Version 2.0")
appendNode("url", "https://www.apache.org/licenses/LICENSE-2.0.txt")
appendNode("distribution", "repo")
}
}

root.appendNode("developers").apply {
appendNode("developer").apply {
appendNode("id", "tkadziolka")
appendNode("name", "Tomasz Kądziołka")
appendNode("email", "[email protected]")
}
}

root.appendNode("scm").apply {
appendNode(
"connection",
"scm:git:ssh://[email protected]:SnipMeDev/KodeView.git"
)
appendNode(
"developerConnection",
"scm:git:ssh://[email protected]:SnipMeDev/KodeView.git",
)
appendNode("url", "https://github.com/SnipMeDev/KodeView")
}
}
}
}

sourceSets {
// Common
val commonMain by getting {
Expand Down Expand Up @@ -135,3 +84,73 @@ kotlin {
}
}
}

signing {
useInMemoryPgpKeys(
rootProject.ext["signing.keyId"] as String,
rootProject.ext["signing.key"] as String,
rootProject.ext["signing.password"] as String
)
sign(publishing.publications)
}

publishing {
val emptyJar = tasks.register<Jar>("emptyJar") {
archiveAppendix.set("empty")
}

publications.forEach {
val publication = it as? MavenPublication ?: return@forEach

publication.artifact(emptyJar) {
classifier = "javadoc"
}

publication.pom.withXml {
val root = asNode()
root.appendNode("name", "kodeview")
root.appendNode(
"description",
"Kotlin Multiplatform syntax highlighting views"
)
root.appendNode("url", "https://github.com/SnipMeDev/KodeView")

root.appendNode("licenses").apply {
appendNode("license").apply {
appendNode("name", "The Apache Software License, Version 2.0")
appendNode("url", "https://www.apache.org/licenses/LICENSE-2.0.txt")
appendNode("distribution", "repo")
}
}

root.appendNode("developers").apply {
appendNode("developer").apply {
appendNode("id", "tkadziolka")
appendNode("name", "Tomasz Kądziołka")
appendNode("email", "[email protected]")
}
}

root.appendNode("scm").apply {
appendNode(
"connection",
"scm:git:ssh://[email protected]:SnipMeDev/KodeView.git"
)
appendNode(
"developerConnection",
"scm:git:ssh://[email protected]:SnipMeDev/KodeView.git",
)
appendNode("url", "https://github.com/SnipMeDev/KodeView")
}
}
}
}

tasks.withType<PublishToMavenRepository> {
dependsOn(":kodeview:signIosSimulatorArm64Publication")
dependsOn(":kodeview:signIosArm64Publication")
dependsOn(":kodeview:signIosX64Publication")
dependsOn(":kodeview:signJvmPublication")
dependsOn(":kodeview:signJsPublication")
dependsOn(":kodeview:signKotlinMultiplatformPublication")
}
Loading

0 comments on commit d3333e5

Please sign in to comment.