Skip to content

Commit b68e408

Browse files
committed
full build
1 parent 774a2a3 commit b68e408

File tree

7 files changed

+43
-24
lines changed

7 files changed

+43
-24
lines changed

pom.xml

+19-9
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,27 @@
7474

7575
<plugin>
7676
<groupId>org.apache.maven.plugins</groupId>
77-
<artifactId>maven-jar-plugin</artifactId>
78-
<version>3.3.0</version>
77+
<artifactId>maven-assembly-plugin</artifactId>
78+
<version>3.6.0</version>
7979
<configuration>
80-
<archive>
81-
<manifest>
82-
<addClasspath>true</addClasspath>
83-
<classpathPrefix>libs/</classpathPrefix>
84-
<mainClass>${mvnMainClass}</mainClass>
85-
</manifest>
86-
</archive>
80+
<descriptorRefs>
81+
<descriptorRef>jar-with-dependencies</descriptorRef>
82+
</descriptorRefs>
83+
<archive>
84+
<manifest>
85+
<mainClass>${mvnMainClass}</mainClass>
86+
</manifest>
87+
</archive>
8788
</configuration>
89+
<executions>
90+
<execution>
91+
<id>make-assembly</id>
92+
<phase>package</phase>
93+
<goals>
94+
<goal>single</goal>
95+
</goals>
96+
</execution>
97+
</executions>
8898
</plugin>
8999

90100
</plugins>

src/main/java/net/unixcode/rts/parser/Main.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public class Main {
2121
final static protected Logger log = LoggerFactory.getLogger(Main.class);
2222
public static void main(String @NotNull [] argv) {
2323
if (argv.length < 1) {
24-
throw new RuntimeException("No input files were provided.");
24+
log.error("No input files were provided.");
25+
26+
System.exit(1);
2527
}
2628

2729
ApplicationContext ctxt = new AnnotationConfigApplicationContext(DIConfig.class);

src/main/java/net/unixcode/rts/parser/parsers/BaseRunnerProvider.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected void process() {
7777
}
7878

7979
if (sourceItem.getStream() == null) {
80-
System.err.println("Source stream is NULL. Trying next source item.");
80+
log.warn("Source stream is NULL. Trying next source item.");
8181

8282
sourceItem = null;
8383
continue;

src/main/java/net/unixcode/rts/parser/parsers/BaseSourceItem.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import net.unixcode.rts.parser.api.ISourceItem;
44
import org.antlr.v4.runtime.CharStream;
55
import org.antlr.v4.runtime.CharStreams;
6+
import org.slf4j.Logger;
7+
import org.slf4j.LoggerFactory;
68

79
import java.io.File;
810
import java.io.IOException;
@@ -11,6 +13,7 @@
1113
import java.text.MessageFormat;
1214

1315
public class BaseSourceItem implements ISourceItem {
16+
final protected Logger log = LoggerFactory.getLogger(getClass());
1417
protected String sourcePath;
1518
protected CharStream stream = null;
1619

@@ -22,23 +25,23 @@ public BaseSourceItem(String sourcePath) {
2225
this.sourcePath = file.getCanonicalPath();
2326

2427
if (!file.exists()) {
25-
throw new IOException("File is not exists.");
28+
throw new IOException("File does not exists.");
2629
}
2730

2831
if (!file.isFile()) {
29-
throw new IOException("Specified path is not a file.");
32+
throw new IOException("Specified path is not the file.");
3033
}
3134

3235
if (!file.canRead()) {
33-
throw new IOException("Specified file is not readable.");
36+
throw new IOException("Specified file does not readable.");
3437
}
3538
}
3639

3740
stream = CharStreams.fromFileName(this.sourcePath, StandardCharsets.UTF_16);
3841
}
3942
catch (IOException e) {
40-
System.err.println(MessageFormat.format("ERROR: Unable to compile file [{0}]", sourcePath));
41-
System.err.println(e.getMessage());
43+
log.error(MessageFormat.format("ERROR: Unable to compile file [{0}]", sourcePath));
44+
log.error(e.getMessage());
4245
}
4346
}
4447

src/main/java/net/unixcode/rts/parser/parsers/stf/STF2XMLListenerContext.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import net.unixcode.rts.parser.api.IParserListenerContext;
44
import net.unixcode.rts.parser.api.stf.ISTF2XMLListenerCtxt;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
57
import org.springframework.context.annotation.Scope;
68
import org.springframework.stereotype.Component;
79
import org.w3c.dom.Document;
@@ -19,6 +21,7 @@
1921
@Component
2022
@Scope("prototype")
2123
public class STF2XMLListenerContext implements ISTF2XMLListenerCtxt {
24+
final protected Logger log = LoggerFactory.getLogger(getClass());
2225
protected String sourcePath;
2326
protected Document doc;
2427
protected boolean processed = false;
@@ -30,7 +33,7 @@ public STF2XMLListenerContext() {
3033
doc = builder.newDocument();
3134
}
3235
catch (ParserConfigurationException e) {
33-
System.err.println(e.getMessage());
36+
log.error(e.getMessage());
3437

3538
throw new RuntimeException(e);
3639
}
@@ -78,8 +81,8 @@ public void writeToStream(OutputStreamWriter streamWriter) {
7881
transformer.transform(source, result);
7982
}
8083
catch (Exception e) {
81-
System.err.println("Unable transform Document to xml.");
82-
System.err.println(e.getMessage());
84+
log.error("Unable to transform Document to xml");
85+
log.error(e.getMessage());
8386

8487
throw new RuntimeException(e);
8588
}

src/main/java/net/unixcode/rts/parser/parsers/stf/STFLexerErrorListener.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int
1616
String err = "line " + line + ":" + charPositionInLine + " " + msg;
1717

1818
log.error(err);
19+
log.info("Try to check source file encoding. It must be UTF-16LE.");
1920

20-
// System.exit(1);
21+
System.exit(1);
2122
}
2223

2324
public static class LexerError extends Error {

src/main/java/net/unixcode/rts/parser/translator/XML2CXXTranslator.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import org.apache.commons.io.IOUtils;
88
import org.slf4j.Logger;
99
import org.slf4j.LoggerFactory;
10+
import org.springframework.context.ApplicationContext;
1011
import org.springframework.stereotype.Component;
11-
import org.springframework.util.ResourceUtils;
1212
import org.xml.sax.InputSource;
1313

1414
import javax.xml.transform.sax.SAXSource;
@@ -24,14 +24,14 @@ public class XML2CXXTranslator implements ITranslator<ISTF2XMLListenerCtxt> {
2424
protected XsltExecutable stylesheet;
2525
protected Xslt30Transformer transformer;
2626

27-
public XML2CXXTranslator() {
27+
public XML2CXXTranslator(ApplicationContext appContext) {
2828
try {
29-
File file = ResourceUtils.getFile(XSLT_FILENAME);
29+
InputStream xsltInputStream = appContext.getResource(XSLT_FILENAME).getInputStream();
3030

3131
processor = new Processor(false);
3232
XsltCompiler compiler = processor.newXsltCompiler();
3333

34-
stylesheet = compiler.compile(new StreamSource(file));
34+
stylesheet = compiler.compile(new StreamSource(xsltInputStream));
3535

3636
transformer = stylesheet.load30();
3737
}

0 commit comments

Comments
 (0)