Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
push:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java-version: ['11', '17', '21', '25']
name: Test (Java ${{ matrix.java-version }})
steps:
- uses: actions/checkout@v4

- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'

- name: Run tests
run: mvn test
27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish to GitHub Packages

on:
release:
types: [created]

permissions:
contents: read
packages: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
server-id: github

- name: Publish package
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@ Java implementation of the [NSV (Newline-Separated Values)](https://nsv-format.o

## Installation

Maven Central publishing is planned. For now, the package is available via [GitHub Packages](https://github.com/nsv-format/nsv-java/packages), which requires a GitHub account and a personal access token with `read:packages` scope.

### Maven

Add the repository to your `pom.xml` or `~/.m2/settings.xml`:

```xml
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/nsv-format/nsv-java</url>
</repository>
```

Then add the dependency:

```xml
<dependency>
<groupId>org.nsv-format</groupId>
Expand All @@ -17,7 +30,19 @@ Java implementation of the [NSV (Newline-Separated Values)](https://nsv-format.o
### Gradle

```groovy
implementation 'org.nsv-format:nsv-java:0.2.0'
repositories {
maven {
url = uri("https://maven.pkg.github.com/nsv-format/nsv-java")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}

dependencies {
implementation 'org.nsv-format:nsv-java:0.2.0'
}
```

## Usage
Expand Down
24 changes: 24 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@

<name>nsv-java</name>
<description>Java implementation of NSV (Newline-Separated Values) format</description>
<url>https://github.com/nsv-format/nsv-java</url>

<licenses>
<license>
<name>MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<connection>scm:git:git://github.com/nsv-format/nsv-java.git</connection>
<developerConnection>scm:git:ssh://github.com:nsv-format/nsv-java.git</developerConnection>
<url>https://github.com/nsv-format/nsv-java</url>
</scm>

<!-- TODO: update developers with real maintainer info before publishing to Central -->
<developers>
<developer>
<name>nsv-format</name>
<organization>nsv-format</organization>
<organizationUrl>https://github.com/nsv-format</organizationUrl>
</developer>
</developers>

<properties>
<maven.compiler.source>11</maven.compiler.source>
Expand Down
9 changes: 5 additions & 4 deletions src/test/java/org/nsvformat/EscapeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.*;

public class EscapeTest {
Expand Down Expand Up @@ -82,13 +83,13 @@ public void testEscapeSeqseqUsingMap() {
);

List<List<String>> result = seqseq.stream()
.map(row -> row.stream().map(Nsv::escape).toList())
.toList();
.map(row -> row.stream().map(Nsv::escape).collect(Collectors.toList()))
.collect(Collectors.toList());
assertEquals(expected, result);

List<List<String>> recovered = result.stream()
.map(row -> row.stream().map(Nsv::unescape).toList())
.toList();
.map(row -> row.stream().map(Nsv::unescape).collect(Collectors.toList()))
.collect(Collectors.toList());
assertEquals(seqseq, recovered);
}
}