Skip to content

Commit 734e044

Browse files
committed
use json format in runnable jar, project package with dependencies now
1 parent 0f29fec commit 734e044

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

pom.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,37 @@
3434
</dependencies>
3535

3636
<build>
37+
<plugins>
38+
<plugin>
39+
<artifactId>maven-assembly-plugin</artifactId>
40+
</plugin>
41+
</plugins>
42+
43+
3744
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
3845
<plugins>
3946
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
4047
<plugin>
4148
<artifactId>maven-clean-plugin</artifactId>
4249
<version>3.1.0</version>
4350
</plugin>
51+
4452
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
4553
<plugin>
4654
<artifactId>maven-resources-plugin</artifactId>
4755
<version>3.0.2</version>
4856
</plugin>
57+
4958
<plugin>
5059
<artifactId>maven-compiler-plugin</artifactId>
5160
<version>3.8.0</version>
5261
</plugin>
62+
5363
<plugin>
5464
<artifactId>maven-surefire-plugin</artifactId>
5565
<version>2.22.1</version>
5666
</plugin>
67+
5768
<plugin>
5869
<artifactId>maven-jar-plugin</artifactId>
5970
<version>3.0.2</version>
@@ -65,14 +76,40 @@
6576
</archive>
6677
</configuration>
6778
</plugin>
79+
80+
<plugin>
81+
<artifactId>maven-assembly-plugin</artifactId>
82+
<configuration>
83+
<archive>
84+
<manifest>
85+
<mainClass>com.github.leafee98.CSTI.core.App</mainClass>
86+
</manifest>
87+
</archive>
88+
<descriptorRefs>
89+
<descriptorRef>jar-with-dependencies</descriptorRef>
90+
</descriptorRefs>
91+
</configuration>
92+
<executions>
93+
<execution>
94+
<id>make-assembly</id>
95+
<phase>package</phase>
96+
<goals>
97+
<goal>single</goal>
98+
</goals>
99+
</execution>
100+
</executions>
101+
</plugin>
102+
68103
<plugin>
69104
<artifactId>maven-install-plugin</artifactId>
70105
<version>2.5.2</version>
71106
</plugin>
107+
72108
<plugin>
73109
<artifactId>maven-deploy-plugin</artifactId>
74110
<version>2.8.2</version>
75111
</plugin>
112+
76113
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
77114
<plugin>
78115
<artifactId>maven-site-plugin</artifactId>

src/main/java/com/github/leafee98/CSTI/core/App.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.github.leafee98.CSTI.core;
22

33
import java.io.*;
4-
import java.time.LocalTime;
4+
import java.nio.charset.Charset;
5+
import java.nio.charset.StandardCharsets;
56

6-
import com.github.leafee98.CSTI.core.bean.LessonRanges;
77
import com.github.leafee98.CSTI.core.bean.ScheduleObject;
8+
import com.github.leafee98.CSTI.core.bean.loader.JSONLoader;
89
import com.github.leafee98.CSTI.core.generate.Generator;
9-
import com.github.leafee98.CSTI.core.utils.LocalTimeRange;
1010
import com.github.leafee98.CSTI.core.wrapper.schedule.BreakLine;
1111

1212
public class App {
@@ -44,17 +44,16 @@ private static void initIO() throws FileNotFoundException {
4444
}
4545
}
4646

47-
public static void main(String[] args) throws FileNotFoundException, IOException {
47+
public static void main(String[] args) throws IOException {
4848
parseParameter(args);
49-
5049
initIO();
5150

52-
String confContent = new String(input.readAllBytes());
51+
String confContent = new String(input.readAllBytes(), StandardCharsets.UTF_8);
5352

54-
ScheduleObject scheduleObj = ScheduleObject.load(BreakLine.recovery(confContent));
53+
JSONLoader loader = new JSONLoader();
54+
ScheduleObject scheduleObj = loader.load(confContent);
5555

5656
Generator generator = new Generator(scheduleObj);
57-
5857
String result = generator.generate().toString();
5958

6059
output.write(result.getBytes());

0 commit comments

Comments
 (0)