Skip to content

Commit 7c10166

Browse files
committed
initial version
1 parent 45af209 commit 7c10166

File tree

13 files changed

+209
-105
lines changed

13 files changed

+209
-105
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,10 @@ buildNumber.properties
274274
.mvn/wrapper/maven-wrapper.jar
275275
.flattened-pom.xml
276276

277-
# End of https://www.toptal.com/developers/gitignore/api/java,maven,eclipse,intellij,intellij+all
277+
# End of https://www.toptal.com/developers/gitignore/api/java,maven,eclipse,intellij,intellij+all
278+
279+
# Ignore Gradle project-specific cache directory
280+
.gradle
281+
282+
# Ignore Gradle build output directory
283+
build

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Compile-time JSON-parser
1+
# Compile-time JSON-parser [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.danthe1st/compile-time-json-parser/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.danthe1st/compile-time-json-parser)
22
> generates a JSON-parser for Java-objects at compile-time
33
44
Compile-time JSON-parser supports both non-private variables and properties.
@@ -10,12 +10,12 @@ The generated JSON-parser uses `org.json:json`.
1010
* Download the sources
1111
* Run `mvn clean install` in the directory of Compile-time JSON-parser
1212
* Create a Maven Project in IntelliJ where you want to use Compile-time JSON-parser
13-
* Add the following dependency to the `pom.xml` of the project where you want to use Compile-time JSON-parser
13+
* Add the following dependency to the `pom.xml` of the project where you want to use Compile-time JSON-parser (replace `VERSION` with the version from [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.danthe1st/compile-time-json-parser/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.danthe1st/compile-time-json-parser))
1414
```xml
1515
<dependency>
1616
<groupId>io.github.danthe1st</groupId>
1717
<artifactId>compile-time-json-parser</artifactId>
18-
<version>0.0.1-SNAPSHOT</version>
18+
<version>VERSION</version>
1919
</dependency>
2020
```
2121
* If you wish to use JPMS, also add the annotation processor to the `maven-compiler-plugin`
@@ -39,6 +39,7 @@ The generated JSON-parser uses `org.json:json`.
3939

4040
### Usage
4141
* Create a data class and annotate it with `@GenerateJSON` like this:
42+
4243
```java
4344
import io.github.danthe1st.json_compile.api.GenerateJSON;
4445
@GenerateJSON
@@ -75,6 +76,7 @@ public class TestClass {
7576
```
7677
* When compiling the class, a class suffixed with `JSONLoader` should be automatically generated.<br/>
7778
This class contains a method named `fromJSON` that creates an instance of the data class from a `String`:
79+
7880
```java
7981
String json= String.join("", Files.readAllLines(Path.of("testClass.json")));
8082
TestClass obj = TestClassJSONLoader.fromJSON(json);
@@ -115,7 +117,6 @@ An example project can be found in the directory `examples/maven-example`.
115117
* Objects annotated with `@GenerateJSON` need to have a no-args-constructor
116118
* Collections need to be initialized in the constructor
117119
* Generic objects are not supported (except generic collections)
118-
* Compile-time JSON-parser is not yet published to maven central, so you will have to build it by yourself.
119120
* Configuration is not supported
120121

121122
### IDE-specific configuration

examples/maven-example/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>io.github.danthe1st</groupId>
66
<artifactId>json-parser-maven-example</artifactId>
7-
<version>0.0.1-SNAPSHOT</version>
7+
<version>1.0.0</version>
88
<dependencies>
99
<dependency>
1010
<groupId>io.github.danthe1st</groupId>
1111
<artifactId>compile-time-json-parser</artifactId>
12-
<version>0.0.1-SNAPSHOT</version>
12+
<version>1.0.0-SNAPSHOT</version>
1313
</dependency>
1414
</dependencies>
1515
<build>

examples/maven-example/src/main/java/io/github/danthe1st/json_compile_example/ReferencedClass.java renamed to examples/maven-example/src/main/java/io/github/danthe1st/json_compile_example/maven/ReferencedClass.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.danthe1st.json_compile_example;
1+
package io.github.danthe1st.json_compile_example.maven;
22

33
import io.github.danthe1st.json_compile.api.GenerateJSON;
44

examples/maven-example/src/main/java/io/github/danthe1st/json_compile_example/TestClass.java renamed to examples/maven-example/src/main/java/io/github/danthe1st/json_compile_example/maven/TestClass.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.danthe1st.json_compile_example;
1+
package io.github.danthe1st.json_compile_example.maven;
22

33
import io.github.danthe1st.json_compile.api.GenerateJSON;
44

@@ -14,10 +14,10 @@
1414

1515
@GenerateJSON
1616
public class TestClass {
17-
private int privVal;
17+
private int privVal;//private values without getters/setters-->ignored
1818
public String pubVal;
1919

20-
public int[][] data={{1,2,3},{},{1,2,3,4,5,6}};
20+
public int[][] data={{1,2,3},{},{1,2,3,4,5,6}};//private values without getters/setters-->used
2121

2222
private ReferencedClass otherObject=new ReferencedClass();
2323

examples/maven-example/src/main/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module example{
1+
module io.github.danthe1st.json_compiler.examples.maven{
22
requires java.base;
33
requires io.github.danthe1st.json_compile;
44
requires org.json;

pom.xml

Lines changed: 170 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,172 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4-
<modelVersion>4.0.0</modelVersion>
5-
<groupId>io.github.danthe1st</groupId>
6-
<artifactId>compile-time-json-parser</artifactId>
7-
<version>0.0.1-SNAPSHOT</version>
8-
<name>Compile time JSON parser</name>
9-
<description>prepares converting JSON objects to java objects at compile-time</description>
10-
<dependencies>
11-
<dependency>
12-
<groupId>org.json</groupId>
13-
<artifactId>json</artifactId>
14-
<version>20210307</version>
15-
</dependency>
16-
</dependencies>
17-
<build>
18-
<plugins>
19-
<plugin>
20-
<groupId>org.apache.maven.plugins</groupId>
21-
<artifactId>maven-compiler-plugin</artifactId>
22-
<version>3.8.1</version>
23-
<configuration>
24-
<release>11</release>
25-
<proc>none</proc>
26-
</configuration>
27-
<executions>
28-
<execution>
29-
<id>process-test-annotations</id>
30-
<phase>generate-test-sources</phase>
31-
<goals>
32-
<goal>testCompile</goal>
33-
</goals>
34-
<configuration>
35-
<proc>only</proc>
36-
<annotationProcessors>
37-
<annotationProcessor>io.github.danthe1st.json_compile.impl.JSONCreator</annotationProcessor>
38-
</annotationProcessors>
39-
</configuration>
40-
</execution>
41-
</executions>
42-
</plugin>
43-
<plugin>
44-
<artifactId>maven-assembly-plugin</artifactId>
45-
<version>2.2-beta-5</version>
46-
<configuration>
47-
<descriptorRefs>
48-
<descriptorRef>jar-with-dependencies</descriptorRef>
49-
</descriptorRefs>
50-
</configuration>
51-
<executions>
52-
<execution>
53-
<id>jar-with-dependencies</id>
54-
<phase>package</phase>
55-
<goals>
56-
<goal>single</goal>
57-
</goals>
58-
</execution>
59-
</executions>
60-
</plugin>
61-
</plugins>
62-
</build>
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>io.github.danthe1st</groupId>
6+
<artifactId>compile-time-json-parser</artifactId>
7+
<version>1.0.0</version>
8+
<packaging>jar</packaging>
9+
<name>Compile time JSON parser</name>
10+
<description>prepares converting JSON objects to java objects at compile-time</description>
11+
<url>https://github.com/danthe1st/compile-time-json-parser</url>
12+
<licenses>
13+
<license>
14+
<name>The MIT License</name>
15+
<url>https://opensource.org/licenses/MIT</url>
16+
</license>
17+
</licenses>
18+
<developers>
19+
<developer>
20+
<url>https://github.com/danthe1st/</url>
21+
<name>Daniel</name>
22+
<roles>
23+
<role>Developer</role>
24+
<role>Maintainer</role>
25+
</roles>
26+
<timezone>+1</timezone>
27+
</developer>
28+
</developers>
29+
<scm>
30+
<connection>scm:git:git@github.com:danthe1st/compile-time-json-parser.git</connection>
31+
<developerConnection>scm:git:git@github.com:danthe1st/compile-time-json-parser.git</developerConnection>
32+
<url>https://github.com/danthe1st/compile-time-json-parser</url>
33+
</scm>
34+
<issueManagement>
35+
<url>https://github.com/danthe1st/compile-time-json-parser/issues</url>
36+
<system>GitHub</system>
37+
</issueManagement>
38+
<distributionManagement>
39+
<snapshotRepository>
40+
<id>ossrh</id>
41+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
42+
</snapshotRepository>
43+
<repository>
44+
<id>ossrh</id>
45+
<url>https://oss.sonatype.org/content/repositories/releases</url>
46+
</repository>
47+
</distributionManagement>
48+
<properties>
49+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
50+
</properties>
51+
<dependencies>
52+
<dependency>
53+
<groupId>org.json</groupId>
54+
<artifactId>json</artifactId>
55+
<version>20210307</version>
56+
</dependency>
57+
</dependencies>
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.apache.maven.plugins</groupId>
62+
<artifactId>maven-compiler-plugin</artifactId>
63+
<version>3.8.1</version>
64+
<configuration>
65+
<release>11</release>
66+
<proc>none</proc>
67+
</configuration>
68+
<executions>
69+
<execution>
70+
<id>process-test-annotations</id>
71+
<phase>generate-test-sources</phase>
72+
<goals>
73+
<goal>testCompile</goal>
74+
</goals>
75+
<configuration>
76+
<proc>only</proc>
77+
<annotationProcessors>
78+
<annotationProcessor>io.github.danthe1st.json_compile.impl.JSONCreator
79+
</annotationProcessor>
80+
</annotationProcessors>
81+
</configuration>
82+
</execution>
83+
</executions>
84+
</plugin>
85+
<plugin>
86+
<artifactId>maven-assembly-plugin</artifactId>
87+
<version>2.2-beta-5</version>
88+
<configuration>
89+
<descriptorRefs>
90+
<descriptorRef>jar-with-dependencies</descriptorRef>
91+
</descriptorRefs>
92+
</configuration>
93+
<executions>
94+
<execution>
95+
<id>jar-with-dependencies</id>
96+
<phase>package</phase>
97+
<goals>
98+
<goal>single</goal>
99+
</goals>
100+
</execution>
101+
</executions>
102+
</plugin>
103+
<plugin>
104+
<groupId>org.apache.maven.plugins</groupId>
105+
<artifactId>maven-gpg-plugin</artifactId>
106+
<version>1.5</version>
107+
<executions>
108+
<execution>
109+
<id>sign-artifacts</id>
110+
<phase>deploy</phase>
111+
<goals>
112+
<goal>sign</goal>
113+
</goals>
114+
</execution>
115+
</executions>
116+
</plugin>
117+
<plugin>
118+
<groupId>org.apache.maven.plugins</groupId>
119+
<artifactId>maven-source-plugin</artifactId>
120+
<version>3.0.1</version>
121+
<configuration>
122+
<encoding>UTF-8</encoding>
123+
</configuration>
124+
<executions>
125+
<execution>
126+
<id>attach-javadocs</id>
127+
<phase>verify</phase>
128+
<goals>
129+
<goal>jar</goal>
130+
</goals>
131+
</execution>
132+
<execution>
133+
<id>attach-sources</id>
134+
<goals>
135+
<goal>jar</goal>
136+
</goals>
137+
</execution>
138+
</executions>
139+
</plugin>
140+
<plugin>
141+
<groupId>org.apache.maven.plugins</groupId>
142+
<artifactId>maven-javadoc-plugin</artifactId>
143+
<version>3.0.1</version>
144+
<configuration>
145+
<javadocVersion>11</javadocVersion>
146+
<doclint>all</doclint>
147+
<source>11</source>
148+
</configuration>
149+
<executions>
150+
<execution>
151+
<id>attach-javadocs</id>
152+
<phase>verify</phase>
153+
<goals>
154+
<goal>jar</goal>
155+
</goals>
156+
</execution>
157+
</executions>
158+
</plugin>
159+
<plugin>
160+
<groupId>org.sonatype.plugins</groupId>
161+
<artifactId>nexus-staging-maven-plugin</artifactId>
162+
<version>1.6.7</version>
163+
<extensions>true</extensions>
164+
<configuration>
165+
<serverId>ossrh</serverId>
166+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
167+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
168+
</configuration>
169+
</plugin>
170+
</plugins>
171+
</build>
63172
</project>

0 commit comments

Comments
 (0)