Skip to content

Commit af3429a

Browse files
authored
Add examples for Maven project into README (#281)
This PR adds examples of how the library can be added to the Maven project as a dependency. Resolves #280
1 parent 5ae9fc4 commit af3429a

File tree

2 files changed

+75
-6
lines changed

2 files changed

+75
-6
lines changed

Diff for: .github/workflows/release.yml

+4
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,13 @@ jobs:
129129
- name: Prepare next dev version
130130
id: prepare_next_dev
131131
run: |
132+
# gradle
132133
sed -i -e 's/${{ needs.version.outputs.CURRENT_VERSION }}/${{ needs.version.outputs.NEXT_VERSION }}/g' gradle.properties
133134
sed -i -E -e 's/json-schema-validator((-[a-z]+)?:|\/)[0-9]+\.[0-9]+\.[0-9]+/json-schema-validator\1${{ needs.version.outputs.RELEASE_VERSION }}/g' README.md
134135
sed -i -E -e 's/json-schema-validator((-[a-z]+)?:|\/)[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)/json-schema-validator\1${{ needs.version.outputs.NEXT_VERSION }}/g' README.md
136+
# maven
137+
sed -i -e -e 's|<version>[0-9]+\.[0-9]+\.[0-9]+|<version>${{ needs.version.outputs.RELEASE_VERSION }}|g' README.md
138+
sed -i -e -e 's|<version>[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)|<version>${{ needs.version.outputs.NEXT_VERSION }}|g' README.md
135139
- name: Commit next dev version
136140
id: commit_next_dev
137141
uses: EndBug/add-and-commit@v9

Diff for: README.md

+71-6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ from [kotlinx.serialization-json](https://github.com/Kotlin/kotlinx.serializatio
4040

4141
In order to use releases add Maven Central repository to the list of repositories.
4242

43-
##### Kotlin
43+
##### Gradle
44+
45+
###### Kotlin
4446

4547
```kotlin
4648
repositories {
@@ -50,7 +52,7 @@ repositories {
5052
implementation("io.github.optimumcode:json-schema-validator:0.5.1")
5153
```
5254

53-
##### Groovy
55+
###### Groovy
5456

5557
```groovy
5658
repositories {
@@ -68,27 +70,60 @@ implementation("io.github.optimumcode:json-schema-validator")
6870
_Release are published to Sonatype repository. The synchronization with Maven Central takes time._
6971
_If you want to use the release right after the publication you should add Sonatype Release repository to your build script._
7072

71-
##### Kotlin
73+
###### Kotlin
7274

7375
```kotlin
7476
repositories {
7577
maven(url = "https://s01.oss.sonatype.org/content/repositories/releases/")
7678
}
7779
```
7880

79-
##### Groovy
81+
###### Groovy
8082

8183
```groovy
8284
repositories {
8385
maven { url 'https://s01.oss.sonatype.org/content/repositories/releases/' }
8486
}
8587
```
8688

89+
##### Maven
90+
91+
You can also use `json-schema-validator` as a dependency in your maven project.
92+
But Maven cannot use Gradle's metadata so you need to depend on a JVM-specific artifact in your project:
93+
94+
```xml
95+
<dependency>
96+
<groupId>io.github.optimumcode</groupId>
97+
<artifactId>json-schema-validator-jvm</artifactId>
98+
<version>0.5.1</version>
99+
</dependency>
100+
```
101+
102+
And you can also add a sonatype repository to your POM file
103+
104+
```xml
105+
<repositories>
106+
<repository>
107+
<id>sonatype-release</id>
108+
<name>sonatype-release</name>
109+
<url>https://s01.oss.sonatype.org/content/repositories/releases/</url>
110+
<snapshots>
111+
<enabled>false</enabled>
112+
</snapshots>
113+
<releases>
114+
<enabled>true</enabled>
115+
</releases>
116+
</repository>
117+
</repositories>
118+
```
119+
87120
#### Snapshots
88121

89122
_If you want to use SNAPSHOT version you should add Sonatype Snapshot repository to your build script._
90123

91-
##### Kotlin
124+
##### Gradle
125+
126+
###### Kotlin
92127

93128
```kotlin
94129
repositories {
@@ -103,7 +138,7 @@ implementation(platform("io.github.optimumcode:json-schema-validator-bom:0.5.2-S
103138
implementation("io.github.optimumcode:json-schema-validator")
104139
```
105140

106-
##### Groovy
141+
###### Groovy
107142

108143
```groovy
109144
repositories {
@@ -113,6 +148,36 @@ repositories {
113148
implementation 'io.github.optimumcode:json-schema-validator:0.5.2-SNAPSHOT'
114149
```
115150

151+
##### Maven
152+
153+
For the Maven you need to add a snapshot repository to your POM file
154+
155+
```xml
156+
<repositories>
157+
<repository>
158+
<id>sonatype</id>
159+
<name>sonatype-snapshot</name>
160+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
161+
<snapshots>
162+
<enabled>true</enabled>
163+
</snapshots>
164+
<releases>
165+
<enabled>false</enabled>
166+
</releases>
167+
</repository>
168+
</repositories>
169+
```
170+
171+
And then you can add a dependency to a SNAPSHOT version
172+
173+
```xml
174+
<dependency>
175+
<groupId>io.github.optimumcode</groupId>
176+
<artifactId>json-schema-validator-jvm</artifactId>
177+
<version>0.5.2-SNAPSHOT</version>
178+
</dependency>
179+
```
180+
116181
### Example
117182

118183
If you have just one JSON schema or many independent schemes

0 commit comments

Comments
 (0)