Skip to content

Commit

Permalink
Remove logging dependencies
Browse files Browse the repository at this point in the history
Currently the Maven dependencies are:

- Parser and Lexer: jflex, java_cup
- CLI: airlift and Guava

The current footprint is around 5MB. Can be more optimized
but not that bad.

Refs #43
  • Loading branch information
nobeh committed Aug 2, 2015
1 parent 1899426 commit e2c9fa7
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 114 deletions.
36 changes: 21 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?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/maven-v4_0_0.xsd">
<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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -83,17 +84,32 @@
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<descriptor>src/main/assembly/assembly-standalone.xml</descriptor>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>single</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptor>src/main/assembly/assembly-standalone.xml</descriptor>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
<execution>
<id>fat-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</execution>
</executions>
</plugin>
Expand Down Expand Up @@ -158,16 +174,6 @@
<artifactId>airline</artifactId>
<version>${version.airline}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${version.slf4j}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${version.slf4j}</version>
</dependency>
</dependencies>

<distributionManagement>
Expand Down
23 changes: 11 additions & 12 deletions src/main/java/jabsc/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.bridge.SLF4JBridgeHandler;
import java.util.logging.Logger;

import bnfc.abs.Yylex;
import bnfc.abs.parser;
Expand All @@ -33,24 +30,25 @@ public class Compiler implements Runnable {

public static final String DEFAULT_OUTPUT_DIRECTORY_NAME = "generated-sources/jabsc";

private final Logger logger = Logger.getLogger(getClass().getName());

/**
* The version of JABSC Compiler.
*/
private static final String VERSION;

static {
// Set j.u.logging format: [LEVEL] MSG [THROWABLE]
System.setProperty("java.util.logging.SimpleFormatter.format", "[%4$s] %5$s%n%6$s");
VERSION = Optional.ofNullable(Compiler.class.getPackage().getImplementationVersion())
.orElse("1.x-SNAPSHOT");
SLF4JBridgeHandler.install();
}

/**
* .java
*/
private static final String JAVA_FILE_EXTENSION = ".java";

private final Logger logger = LoggerFactory.getLogger(getClass());

private final List<Path> sources;
private final Path outputDirectory;
private boolean debug = false;
Expand All @@ -67,25 +65,25 @@ public Compiler(List<Path> sources, Path outputDirectory) {
this.sources = createSources(sources);
this.outputDirectory = outputDirectory.normalize().toAbsolutePath();
validate(this.sources, outputDirectory);
logger.info("JABSC Compiler {} initialized", VERSION);
logger.info("jabsc " + VERSION);
}

/**
* @return
* @throws Exception
*/
public List<Path> compile() throws Exception {
logger.info("Compiling from {} to {}", sources, outputDirectory);
logger.info("Compiling from " + sources + " to " + outputDirectory);
final List<Path> compilations = new ArrayList<>();
for (Path source : sources) {
if (Files.isDirectory(source) && Files.list(source).count() == 0) {
logger.info("Source directory {} is empty. Skipping.", source);
logger.info("Source directory " + source + " is empty. Skipping.");
continue;
}
Path compilation = compile(source, outputDirectory);
compilations.add(compilation);
}
logger.info("Compiled {} Java sources to: {}", compilations.size(), outputDirectory);
logger.info("Compiled " + compilations.size() + " Java sources to: " + outputDirectory);
return compilations;
}

Expand Down Expand Up @@ -176,7 +174,8 @@ protected Program parseSource(final BufferedReader reader) throws Exception {
if (debug) {
parser.dump_stack();
}
logger.error("Compile error found at line {} near:\n\t{}", lexer.line_num(), lexer.buff());
logger.severe(
"Compile error found at line " + lexer.line_num() + " near:\n\t{}" + lexer.buff());
throw e;
}
}
Expand Down
Loading

0 comments on commit e2c9fa7

Please sign in to comment.