Skip to content

Commit

Permalink
Readme.MD
Browse files Browse the repository at this point in the history
### What's done:
- fixed javadocs
- added a stub for README.md
  • Loading branch information
nulls committed Jul 31, 2023
1 parent 223e4fc commit b16bc66
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 3 deletions.
116 changes: 115 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,115 @@
# osv4k
# osv4k

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![GitHub release](https://img.shields.io/github/release/saveourtool/osv4k.svg)](https://github.com/saveourtool/osv4k/releases/)
[![Maven Central](https://img.shields.io/maven-central/v/com.saveourtool.osv4k/osv4k.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.saveourtool.osv4k%22)
[![javadoc](https://javadoc.io/badge2/com.saveourtool.osv4k/osv4k/javadoc.svg)](https://javadoc.io/doc/com.saveourtool.osv4k/osv4k)
[![Build](https://github.com/saveourtool/osv4k/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/saveourtool/osv4k/actions/workflows/build.yml?query=branch%3Amain)
[![Dependencies](https://github.com/saveourtool/osv4k/actions/workflows/dependencies.yml/badge.svg?branch=main)](https://github.com/saveourtool/osv4k/actions/workflows/dependencies.yml?query=branch%3Amain)

_Kotlin_ model for [OSV](https://ossf.github.io/osv-schema/) Schema.

This library is inspired by the tool [detekt/sarif4k](https://github.com/detekt/sarif4k).

See the [project website](https://saveourtool.github.io/osv4k/) for documentation and APIs.

## Features

- Support [_Kotlin Multiplatform_](https://kotlinlang.org/docs/multiplatform.html): _jvm_, _js_, _linuxX64_/_mingwX64_/_macosX64_.
- Support [_KotlinX Serialization_](https://github.com/Kotlin/kotlinx.serialization).
- Support [_Jackson annotations_](https://github.com/FasterXML/jackson-annotations) for _jvm_ target.

## Releases

The latest release is available from both _GitHub Packages_ and _Maven Central_.
For _GitHub Packages_, the repository can be added as follows.

For `build.gradle.kts`:

```kotlin
repositories {
maven {
name = "saveourtool/osv4k"
url = uri("https://maven.pkg.github.com/saveourtool/osv4k")
content {
includeGroup("com.saveourtool.osv4k")
}
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
}
```

For `settings.gradle.kts`:

```kotlin
dependencyResolutionManagement {
repositories {
maven {
name = "saveourtool/osv4k"
url = uri("https://maven.pkg.github.com/saveourtool/osv4k")
content {
includeGroup("com.saveourtool.osv4k")
}
credentials {
username = providers.gradleProperty("gpr.user").orNull
?: System.getenv("GITHUB_ACTOR")
password = providers.gradleProperty("gpr.key").orNull
?: System.getenv("GITHUB_TOKEN")
}
}
}
}
```

Then add the dependency as usual:
- Gradle
```kotlin
dependencies {
implementation("com.saveourtool.osv4k:osv4k:1.0.0")
}
```
- Maven
```xml
<dependency>
<groupId>com.saveourtool.osv4k</groupId>
<artifactId>osv4k-jvm</artifactId>
<version>1.0.0</version>
</dependency>
```

## Usage
### Kotlin using _Kotlinx Serialization_:

```kotlin
import com.saveourtool.osv4k.*
import java.nio.file.Path
import kotlin.io.path.readText
import kotlinx.serialization.json.Json

fun readFromFile(pathToFile: Path) {
val content = pathToFile.readText()
val schema: RawOsvSchema = Json.decodeFromString(content)
// do something with RawOsvSchema
}
```

### Java using _Jackson Annotations_:

```java
import com.fasterxml.jackson.databind.ObjectMapper;

import java.nio.file.Files;
import java.nio.file.Path;

class Test {
private static final ObjectMapper objectMapper = new ObjectMapper();

static void readFromFile(final Path pathToFile) {
final OsvSchema result = objectMapper.readValue(pathToFile.toFile(), OsvSchema.class);
// do something with OsvSchema
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.gradle.plugins.signing.Sign
import org.gradle.plugins.signing.SigningExtension
import org.gradle.plugins.signing.SigningPlugin
import org.jetbrains.dokka.gradle.DokkaPlugin

/**
* Configures all aspects of the publishing process.
Expand Down Expand Up @@ -139,11 +140,12 @@ fun Project.configureGitHubPublishing() {
*/
@Suppress("TOO_LONG_FUNCTION")
fun Project.configurePublications() {
apply<DokkaPlugin>()
@Suppress("GENERIC_VARIABLE_WRONG_DECLARATION")
val dokkaJarProvider = tasks.register<Jar>("dokkaJar") {
group = "documentation"
archiveClassifier.set("javadoc")
from(tasks.findByName("dokkaHtml"))
from(tasks.named("dokkaHtml"))
}
configure<PublishingExtension> {
publications.withType<MavenPublication>().configureEach {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.saveourtool.osv4k;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down

0 comments on commit b16bc66

Please sign in to comment.