Skip to content

Commit

Permalink
Create module jflex.base (#502)
Browse files Browse the repository at this point in the history
* Move Jflex version in jflex.base.Build

* Update release scripts.
  • Loading branch information
regisd committed Oct 21, 2018
1 parent 51400d1 commit ca298de
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 13 deletions.
1 change: 1 addition & 0 deletions jflex/src/main/java/jflex/BUILD
Expand Up @@ -6,6 +6,7 @@ java_library(
srcs = ["Main.java"], # cli
deps = [
"//jflex/src/main/java/jflex/anttask",
"//jflex/src/main/java/jflex/base",
"//jflex/src/main/java/jflex/core",
"//jflex/src/main/java/jflex/exceptions",
"//jflex/src/main/java/jflex/gui",
Expand Down
5 changes: 3 additions & 2 deletions jflex/src/main/java/jflex/Main.java
Expand Up @@ -26,6 +26,7 @@
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jflex.base.Build;
import jflex.core.LexGenerator;
import jflex.core.Options;
import jflex.core.Out;
Expand Down Expand Up @@ -138,7 +139,7 @@ private static List<File> parseOptions(String argv[]) throws SilentExit {

if (Objects.equals(argv[i], "--version")
|| Objects.equals(argv[i], "-version")) { // $NON-NLS-1$ //$NON-NLS-2$
Out.println(ErrorMessages.THIS_IS_JFLEX, LexGenerator.VERSION);
Out.println(ErrorMessages.THIS_IS_JFLEX, Build.VERSION);
throw new SilentExit(0);
}

Expand Down Expand Up @@ -305,7 +306,7 @@ private static void printUsage() {
Out.println("--help");
Out.println("-h print this message");
Out.println("");
Out.println(ErrorMessages.THIS_IS_JFLEX, LexGenerator.VERSION);
Out.println(ErrorMessages.THIS_IS_JFLEX, Build.VERSION);
Out.println("Have a nice day!");
}

Expand Down
6 changes: 6 additions & 0 deletions jflex/src/main/java/jflex/base/BUILD
@@ -0,0 +1,6 @@
package(default_visibility = ["//visibility:public"])

java_library(
name = "base",
srcs = glob(["*.java"]),
)
9 changes: 9 additions & 0 deletions jflex/src/main/java/jflex/base/Build.java
@@ -0,0 +1,9 @@
package jflex.base;

public class Build {

/** Current JFlex version */
public static final String VERSION = "1.7.1-SNAPSHOT"; // $NON-NLS-1$

private Build() {}
}
1 change: 1 addition & 0 deletions jflex/src/main/java/jflex/core/BUILD
Expand Up @@ -8,6 +8,7 @@ java_library(
],
deps = [
"//cup:cup_runtime",
"//jflex/src/main/java/jflex/base",
"//jflex/src/main/java/jflex/chars",
"//jflex/src/main/java/jflex/exceptions",
"//jflex/src/main/java/jflex/io",
Expand Down
3 changes: 2 additions & 1 deletion jflex/src/main/java/jflex/core/Emitter.java
Expand Up @@ -19,6 +19,7 @@
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jflex.base.Build;
import jflex.exceptions.GeneratorException;
import jflex.io.FileUtil;
import jflex.l10n.ErrorMessages;
Expand Down Expand Up @@ -412,7 +413,7 @@ private void emitNextInput() {

private void emitHeader() {
println("// DO NOT EDIT");
println("// Generated by JFlex " + LexGenerator.VERSION + " http://jflex.de/");
println("// Generated by JFlex " + Build.VERSION + " http://jflex.de/");
String path = FileUtil.getRelativePath(Options.getRootDirectory(), inputFile);
if (File.separatorChar == '\\') {
path = FileUtil.slashify(path);
Expand Down
3 changes: 0 additions & 3 deletions jflex/src/main/java/jflex/core/LexGenerator.java
Expand Up @@ -30,9 +30,6 @@
*/
public class LexGenerator {

/** JFlex version */
public static final String VERSION = "1.7.1-SNAPSHOT"; // $NON-NLS-1$

/**
* Generates a scanner for the specified input file.
*
Expand Down
3 changes: 2 additions & 1 deletion jflex/src/main/java/jflex/core/Out.java
Expand Up @@ -15,6 +15,7 @@
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import jflex.base.Build;
import jflex.core.unicode.UnicodeProperties;
import jflex.exceptions.GeneratorException;
import jflex.l10n.ErrorMessages;
Expand Down Expand Up @@ -406,7 +407,7 @@ public static void printSystemInfo() {
err("OS version: " + System.getProperty("os.version"));
err("Encoding: " + System.getProperty("file.encoding"));
err("Unicode versions: " + UnicodeProperties.UNICODE_VERSIONS);
err("JFlex version: " + LexGenerator.VERSION);
err("JFlex version: " + Build.VERSION);
}

/**
Expand Down
1 change: 1 addition & 0 deletions jflex/src/main/java/jflex/gui/BUILD
Expand Up @@ -5,6 +5,7 @@ java_library(
srcs = glob(["*.java"]),
deps = [
"//jflex",
"//jflex/src/main/java/jflex/base",
"//jflex/src/main/java/jflex/exceptions",
"//jflex/src/main/java/jflex/l10n",
],
Expand Down
4 changes: 2 additions & 2 deletions jflex/src/main/java/jflex/gui/MainFrame.java
Expand Up @@ -17,7 +17,7 @@
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import jflex.core.LexGenerator;
import jflex.base.Build;
import jflex.core.Out;

/**
Expand Down Expand Up @@ -53,7 +53,7 @@ public final class MainFrame extends Frame implements Handles {

/** Constructor for MainFrame. */
public MainFrame() {
super("JFlex " + LexGenerator.VERSION);
super("JFlex " + Build.VERSION);
buildContent();

addWindowListener(
Expand Down
4 changes: 2 additions & 2 deletions post-release.pl
Expand Up @@ -101,8 +101,8 @@
print "Updating version in build.xml\n";
system (qq!perl -pi -e "s/\Q$previous_snapshot\E/$snapshot/" jflex/build.xml !);

print "Updating version in Main.java\n";
system (qq!perl -pi -e "s/\Q$previous_snapshot\E/$snapshot/" jflex/src/main/java/jflex/Main.java !);
print "Updating version in Build.java\n";
system (qq!perl -pi -e "s/\Q$previous_snapshot\E/$snapshot/" jflex/src/main/java/jflex/base/Build.java !);

print "Updating version in the testsuite's Exec.java\n";
system (qq!perl -pi -e "s/\Q$previous_snapshot\E/$snapshot/"!
Expand Down
4 changes: 2 additions & 2 deletions prepare-release.pl
Expand Up @@ -81,8 +81,8 @@
system ('perl -pi -e "s/-SNAPSHOT//" jflex/build.xml');
print "\ndone.\n\n";

print " updating version in Main.java";
system ('perl -pi -e "s/version = \"(.*)-SNAPSHOT/version = \"\\1/" jflex/src/main/java/jflex/Main.java ');
print " updating version in Build.java";
system ('perl -pi -e "s/version = \"(.*)-SNAPSHOT/version = \"\\1/" jflex/src/main/java/jflex/base/Build.java ');
print "\ndone.\n\n";

print " updating version in the testsuite's Exec.java";
Expand Down

0 comments on commit ca298de

Please sign in to comment.