diff --git a/build.gradle b/build.gradle index 2ac72154310c880804f971110914c2b95584af6c..1a5153bb9a6af33f54da80d6a89c952c8bc7be31 100644 --- a/build.gradle +++ b/build.gradle @@ -4,17 +4,17 @@ apply plugin: 'eclipse' apply plugin: 'maven-publish' apply plugin: 'signing' - -project.version = '3.2.15-SNAPSHOT' -project.group = 'de.hhu.stups' +allprojects { + project.group = 'de.hhu.stups' + project.version = '3.3.0-SNAPSHOT' + project.ext.isSnapshot = project.version.endsWith("-SNAPSHOT") +} wrapper { gradleVersion = "6.3" distributionType = Wrapper.DistributionType.ALL } -final isSnapshot = project.version.endsWith("-SNAPSHOT") - sourceCompatibility = 7 targetCompatibility = 7 diff --git a/sablecc-runtime/build.gradle b/sablecc-runtime/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..2534e9b3b66577a8d752e0c9ad2a5db75e49d2d7 --- /dev/null +++ b/sablecc-runtime/build.gradle @@ -0,0 +1,64 @@ +plugins { + id "java-library" + id "maven-publish" + id "signing" +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_7 + withSourcesJar() + withJavadocJar() +} + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + + pom { + name = 'SableCC - Stups fork (runtime library)' + description = 'This is the runtime support library for the Stups fork of SableCC. It provides common classes and interfaces used by the generated parsers at runtime.' + url = 'https://gitlab.cs.uni-duesseldorf.de/general/stups/sablecc-stups' + + licenses { + license { + name = 'GNU Lesser General Public License, Version 2.1' + url = 'http://www.gnu.org/licenses/lgpl-2.1.html' + } + } + + scm { + connection = 'scm:git:https://gitlab.cs.uni-duesseldorf.de/general/stups/sablecc-stups.git' + developerConnection = 'scm:git:git@gitlab.cs.uni-duesseldorf.de:general/stups/sablecc-stups.git' + url = 'https://gitlab.cs.uni-duesseldorf.de/general/stups/sablecc-stups' + } + + developers { + developer { + id = 'bendisposto' + name = 'Jens Bendisposto' + email = 'jens@bendisposto.de' + } + } + } + } + } + + repositories { + maven { + final releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2" + final snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots" + url isSnapshot ? snapshotsRepoUrl : releasesRepoUrl + if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { + credentials { + username project.ossrhUsername + password project.ossrhPassword + } + } + } + } +} + +signing { + sign publishing.publications.mavenJava +} diff --git a/src/main/resources/patchfiles/IParser.txt b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/IParser.java similarity index 100% rename from src/main/resources/patchfiles/IParser.txt rename to sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/IParser.java diff --git a/src/main/resources/patchfiles/IToken.txt b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/IToken.java similarity index 100% rename from src/main/resources/patchfiles/IToken.txt rename to sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/IToken.java diff --git a/src/main/resources/patchfiles/ITokenListContainer.txt b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/ITokenListContainer.java similarity index 100% rename from src/main/resources/patchfiles/ITokenListContainer.txt rename to sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/ITokenListContainer.java diff --git a/src/main/resources/patchfiles/PositionedNode.txt b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/PositionedNode.java similarity index 100% rename from src/main/resources/patchfiles/PositionedNode.txt rename to sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/PositionedNode.java diff --git a/src/main/resources/patchfiles/SourcePosition.txt b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcePosition.java similarity index 100% rename from src/main/resources/patchfiles/SourcePosition.txt rename to sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcePosition.java diff --git a/src/main/resources/patchfiles/SourcePositions.txt b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcePositions.java similarity index 100% rename from src/main/resources/patchfiles/SourcePositions.txt rename to sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcePositions.java diff --git a/src/main/resources/patchfiles/SourcecodeRange.txt b/sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcecodeRange.java similarity index 100% rename from src/main/resources/patchfiles/SourcecodeRange.txt rename to sablecc-runtime/src/main/java/de/hhu/stups/sablecc/patch/SourcecodeRange.java diff --git a/settings.gradle b/settings.gradle index f8e1a304f02217429bc099f8761a639e7dc3a25a..00be2ad78605ef76b81c9b00234e736f7affc882 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,2 @@ rootProject.name = "sablecc" +include "sablecc-runtime" diff --git a/src/main/java/org/sablecc/sablecc/SableCC.java b/src/main/java/org/sablecc/sablecc/SableCC.java index 235a92e466bff7e91e4ae178064897a5602fba6d..3c80cb626ed821872cef3501ce4e949035dba5a5 100644 --- a/src/main/java/org/sablecc/sablecc/SableCC.java +++ b/src/main/java/org/sablecc/sablecc/SableCC.java @@ -113,33 +113,6 @@ public class SableCC { } } - /* - * extract additional stups-classes from .jar-file - */ - String generated = "."; - boolean found = false; - for (String p : arguments) { - if (found) { - generated = p; - break; - } - - if ("-d".equals(p)) { - found = true; - } - } - - String patchFolder = generated + "/de/hhu/stups/sablecc/patch"; - String[] patchFiles = { "IParser", "IToken", "ITokenListContainer", - "PositionedNode", "SourcePosition", "SourcePositions", - "SourcecodeRange" }; - - new File(patchFolder).mkdirs(); - - for (String f : patchFiles) { - extractPatchFile(patchFolder, f); - } - try { for (int i = 0; i < filename.size(); i++) { processGrammar((String) filename.elementAt(i), d_option); @@ -151,74 +124,6 @@ public class SableCC { System.exit(0); } - private static void extractPatchFile(String patchFolder, String patchFile) { - - ClassLoader loader = SableCC.class.getClassLoader(); - InputStream input = loader.getResourceAsStream("patchfiles/" - + patchFile + ".txt"); - String output = ""; - - String outputFile = patchFolder + "/" + patchFile + ".java"; - try { - output = convertStreamToString(input); - } catch (IOException e) { - e.printStackTrace(); - System.exit(1); - } - - Writer writer = null; - try { - File file = new File(outputFile); - writer = new BufferedWriter(new FileWriter(file)); - writer.write(output); - } catch (FileNotFoundException e) { - e.printStackTrace(); - System.exit(1); - } catch (IOException e) { - e.printStackTrace(); - System.exit(1); - } finally { - try { - if (writer != null) { - writer.close(); - } - } catch (IOException e) { - e.printStackTrace(); - System.exit(1); - } - } - } - - private static String convertStreamToString(InputStream is) - throws IOException { - /* - * To convert the InputStream to String we use the Reader.read(char[] - * buffer) method. We iterate until the Reader return -1 which means - * there's no more data to read. We use the StringWriter class to - * produce the string. - */ - - if (is != null) { - Writer writer = new StringWriter(); - - char[] buffer = new char[1024]; - try { - Reader reader = new BufferedReader(new InputStreamReader(is, - "UTF-8")); - int n; - while ((n = reader.read(buffer)) != -1) { - writer.write(buffer, 0, n); - } - } finally { - is.close(); - } - return writer.toString(); - } else { - return ""; - } - - } - /** * The main method for processing grammar file and generating the * parser/lexer.