-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c852fd
commit 84b5739
Showing
9 changed files
with
555 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
lombok.anyConstructor.suppressConstructorProperties=true | ||
lombok.nonNull.exceptionType = IllegalArgumentException | ||
lombok.log.fieldName = LOG | ||
lombok.addLombokGeneratedAnnotation = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,276 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<version>1.0-SNAPSHOT</version> | ||
<artifactId>smojol-cli</artifactId> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.smojol</groupId> | ||
<artifactId>smojol</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<properties> | ||
<maven.compiler.source>21</maven.compiler.source> | ||
<maven.compiler.target>21</maven.compiler.target> | ||
<maven.antlr4.plugin.version>4.7</maven.antlr4.plugin.version> | ||
<antlr.version>4.7.1</antlr.version> | ||
<lombok.version>1.18.30</lombok.version> | ||
<maven.resources.plugin.version>3.0.2</maven.resources.plugin.version> | ||
<maven.checkstyle.plugin.version>3.4.0</maven.checkstyle.plugin.version> | ||
<maven.assembly.plugin.version>3.2.0</maven.assembly.plugin.version> | ||
<google.guava.version>32.0.1-jre</google.guava.version> | ||
<junit-jupiter.version>5.6.0</junit-jupiter.version> | ||
<junit.platform.version>1.6.0</junit.platform.version> | ||
<mockito.core.version>5.10.0</mockito.core.version> | ||
<maven.cobertura.plugin.version>2.7</maven.cobertura.plugin.version> | ||
<maven.coveralls.plugin.version>4.3.0</maven.coveralls.plugin.version> | ||
<maven.jacoco.plugin.version>0.8.11</maven.jacoco.plugin.version> | ||
<maven.surefire.plugin.version>3.0.0-M3</maven.surefire.plugin.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<commons.codec.version>1.17.0</commons.codec.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.smojol</groupId> | ||
<artifactId>smojol-toolkit</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-cli</groupId> | ||
<artifactId>commons-cli</artifactId> | ||
<version>1.8.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<version>${google.guava.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.checkerframework</groupId> | ||
<artifactId>checker-qual</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-codec</groupId> | ||
<artifactId>commons-codec</artifactId> | ||
<version>${commons.codec.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>${lombok.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<version>${junit-jupiter.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<version>${junit-jupiter.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.platform</groupId> | ||
<artifactId>junit-platform-runner</artifactId> | ||
<version>${junit.platform.version}</version> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<version>${mockito.core.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-junit-jupiter</artifactId> | ||
<version>${mockito.core.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
|
||
<build> | ||
<finalName>smojol-cli</finalName> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
</resource> | ||
<resource> | ||
<directory>src/main/antlr4</directory> | ||
<excludes> | ||
<exclude>**</exclude> | ||
</excludes> | ||
<includes> | ||
<include>*.tokens</include> | ||
</includes> | ||
</resource> | ||
<resource> | ||
<directory>src/test/antlr4</directory> | ||
<excludes> | ||
<exclude>**</exclude> | ||
</excludes> | ||
<includes> | ||
<include>*.tokens</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>${maven.assembly.plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
<configuration> | ||
<finalName>smojol-cli</finalName> | ||
<archive> | ||
<manifest> | ||
<mainClass>org.smojol.cli.FlowChartCLI</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
<appendAssemblyId>false</appendAssemblyId> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${maven.surefire.plugin.version}</version> | ||
<configuration> | ||
<parallel>all</parallel> | ||
<systemPropertyVariables> | ||
<property> | ||
<name>filesToTestPath</name> | ||
<!--suppress UnresolvedMavenProperty --> | ||
<value>${filesToTestPath}</value> | ||
</property> | ||
<property> | ||
<name>listingSnap</name> | ||
<!--suppress UnresolvedMavenProperty --> | ||
<value>${listingSnap}</value> | ||
</property> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>${maven.resources.plugin.version}</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-checkstyle-plugin</artifactId> | ||
<version>${maven.checkstyle.plugin.version}</version> | ||
<configuration> | ||
<configLocation>${project.basedir}/src/style/checkstyle.xml</configLocation> | ||
<consoleOutput>true</consoleOutput> | ||
<failsOnError>true</failsOnError> | ||
<linkXRef>false</linkXRef> | ||
<includeTestSourceDirectory>true</includeTestSourceDirectory> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>validate</id> | ||
<phase>validate</phase> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>cobertura-maven-plugin</artifactId> | ||
<version>${maven.cobertura.plugin.version}</version> | ||
<configuration> | ||
<format>xml</format> | ||
<maxmem>256m</maxmem> | ||
<aggregate>true</aggregate> | ||
<instrumentation> | ||
<includes> | ||
<include>org/eclipse/lsp/**/*.class</include> | ||
</includes> | ||
</instrumentation> | ||
<check/> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eluder.coveralls</groupId> | ||
<artifactId>coveralls-maven-plugin</artifactId> | ||
<version>${maven.coveralls.plugin.version}</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.jacoco</groupId> | ||
<artifactId>jacoco-maven-plugin</artifactId> | ||
<version>${maven.jacoco.plugin.version}</version> | ||
<configuration> | ||
<excludes> | ||
<exclude>**/generated-sources/**/*</exclude> | ||
<exclude>**/generated-test-sources/**/*</exclude> | ||
<exclude>**/org/eclipse/lsp/cobol/core/parser/**/*</exclude> | ||
</excludes> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>coverage-prepare-agent</id> | ||
<goals> | ||
<goal>prepare-agent</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>coverage-report</id> | ||
<phase>test</phase> | ||
<goals> | ||
<goal>report</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.1.0</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<mainClass>org.smojol.cli.FlowChartCLI</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
|
||
<pluginManagement> | ||
<plugins> | ||
</plugins> | ||
</pluginManagement> | ||
|
||
</build> | ||
</project> |
67 changes: 67 additions & 0 deletions
67
smojol-cli/src/main/java/org/smojol/cli/CliOptionsReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.smojol.cli; | ||
|
||
import lombok.Getter; | ||
import org.apache.commons.cli.*; | ||
|
||
import java.io.File; | ||
|
||
@Getter | ||
public class CliOptionsReader { | ||
private static final String SRC = "src"; | ||
private static final String SRC_DIR = "srcDir"; | ||
private static final String COPYBOOKS_DIR = "copyBooksDir"; | ||
private static final String DIALECT_JAR_PATH = "dialectJarPath"; | ||
private static final String REPORT_DIR = "reportDir"; | ||
private static final String EXCEPTION_TEMPLATE = "%s must be specified."; | ||
private static final String HELP = "help"; | ||
private String source; | ||
private String sourceDir; | ||
private File[] copyBookPaths; | ||
private String dialectJarPath; | ||
private String reportRootDir; | ||
|
||
public CliOptionsReader(String[] args) throws ParseException { | ||
Options options = new Options(); | ||
options.addOption("h", HELP, false, "Help"); | ||
options.addOption("p", SRC, true, "The name of the source file"); | ||
options.addOption("s", SRC_DIR, true, "The directory containing source file"); | ||
options.addOption("c", COPYBOOKS_DIR, true, "The directory containing copybooks"); | ||
options.addOption("d", DIALECT_JAR_PATH, true, "The path to the dialect JAR"); | ||
options.addOption("r", REPORT_DIR, true, "The directory containing the final artifacts"); | ||
|
||
HelpFormatter formatter = new HelpFormatter(); | ||
CommandLineParser parser = new DefaultParser(); | ||
CommandLine cmd = parser.parse(options, args); | ||
|
||
if (cmd.hasOption(HELP) || cmd.hasOption("h")) { | ||
formatter.printHelp("smojol", options); | ||
return; | ||
} | ||
if (!cmd.hasOption(SRC) && !cmd.hasOption("p")) { | ||
System.out.printf((EXCEPTION_TEMPLATE) + "%n", SRC); | ||
return; | ||
} | ||
if (!cmd.hasOption(SRC_DIR) && !cmd.hasOption("s")) { | ||
System.out.printf((EXCEPTION_TEMPLATE) + "%n", SRC_DIR); | ||
return; | ||
} | ||
if (!cmd.hasOption(COPYBOOKS_DIR) && !cmd.hasOption("c")) { | ||
System.out.printf((EXCEPTION_TEMPLATE) + "%n", COPYBOOKS_DIR); | ||
return; | ||
} | ||
if (!cmd.hasOption(DIALECT_JAR_PATH) && !cmd.hasOption("d")) { | ||
System.out.printf((EXCEPTION_TEMPLATE) + "%n", DIALECT_JAR_PATH); | ||
return; | ||
} | ||
if (!cmd.hasOption(REPORT_DIR) && !cmd.hasOption("r")) { | ||
System.out.printf((EXCEPTION_TEMPLATE) + "%n", REPORT_DIR); | ||
return; | ||
} | ||
|
||
source = cmd.getOptionValue(SRC) != null ? cmd.getOptionValue(SRC) : cmd.getOptionValue("p"); | ||
sourceDir = cmd.getOptionValue(SRC_DIR) != null ? cmd.getOptionValue(SRC_DIR) : cmd.getOptionValue("s"); | ||
copyBookPaths = new File[]{new File(cmd.getOptionValue(COPYBOOKS_DIR) != null ? cmd.getOptionValue(COPYBOOKS_DIR) : cmd.getOptionValue("c"))}; | ||
dialectJarPath = cmd.getOptionValue(DIALECT_JAR_PATH) != null ? cmd.getOptionValue(DIALECT_JAR_PATH) : cmd.getOptionValue("d"); | ||
reportRootDir = cmd.getOptionValue(REPORT_DIR) != null ? cmd.getOptionValue(REPORT_DIR) : cmd.getOptionValue("r"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.smojol.cli; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import org.apache.commons.cli.*; | ||
import org.smojol.analysis.LanguageDialect; | ||
import org.smojol.flowchart.FlowchartTasks; | ||
import org.smojol.interpreter.FlowchartGenerationStrategy; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/* | ||
Use something like: | ||
java -jar smojol-cli/target/smojol-cli.jar --src test-exp.cbl --srcDir /Users/asgupta/code/smojol/smojol-test-code --copyBooksDir /Users/asgupta/code/smojol/smojol-test-code --dialectJarPath /Users/asgupta/code/smojol/che-che4z-lsp-for-cobol-integration/server/dialect-idms/target/dialect-idms.jar --reportDir /Users/asgupta/code/smojol/out/report | ||
*/ | ||
public class FlowChartCLI { | ||
public static void main(String[] args) throws ParseException, IOException, InterruptedException { | ||
CliOptionsReader optionsReader = new CliOptionsReader(args); | ||
String source = optionsReader.getSource(); | ||
String sourceDir = optionsReader.getSourceDir(); | ||
File[] copyBookPaths = new File[]{new File(optionsReader.getDialectJarPath())}; | ||
String dialectJarPath = optionsReader.getDialectJarPath(); | ||
String reportRootDir = optionsReader.getReportRootDir(); | ||
|
||
List<String> programNames = ImmutableList.of(source); | ||
new FlowchartTasks(sourceDir, reportRootDir, copyBookPaths, dialectJarPath).generateForPrograms(programNames, FlowchartGenerationStrategy.FULL_PROGRAM, LanguageDialect.COBOL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE suppressions PUBLIC | ||
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" | ||
"https://checkstyle.org/dtds/suppressions_1_2.dtd"> | ||
|
||
<suppressions> | ||
<suppress checks="MethodName" files="[/\\]test[/\\]"/> | ||
|
||
<suppress checks="FinalClass" files="MessageTemplate.java"/> | ||
</suppressions> |
Oops, something went wrong.