diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..a3108f35b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,104 @@ +name: CI Pipeline + +on: + push: + branches: [ "**" ] # Run on every commit to any branch + pull_request: + branches: [ "**" ] # Run for PRs from any branch + workflow_dispatch: + +permissions: write-all + +jobs: + gradle_check: + name: Gradle Check + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, windows-latest, macos-latest ] + steps: + - uses: actions/checkout@main + with: + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@main + with: + java-version: '17' + distribution: 'temurin' + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@main + + - name: Run Gradle Check + run: ./gradlew check + + maven_verify: + name: Maven Verify + needs: gradle_check # ✅ Run only after Gradle check succeeds + runs-on: ${{ matrix.os }} + strategy: + matrix: +# os: [ ubuntu-latest, windows-latest, macos-latest ] + os: [ ubuntu-latest, macos-latest ] + steps: + - uses: actions/checkout@main + with: + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@main + with: + java-version: '17' + distribution: 'temurin' + + - name: Run Maven Verify + run: mvn --batch-mode verify + + gradle_publish: + name: Gradle Publish + needs: [ gradle_check, maven_verify ] # ✅ Run only after both succeed + if: github.ref == 'refs/heads/master' && github.repository == 'JSQLParser/JSqlParser' # ✅ Only for master branch of main repo + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + with: + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@main + with: + java-version: '17' + distribution: 'temurin' + + - name: Build with Gradle + uses: gradle/actions/setup-gradle@main + + - name: Publish with Gradle + run: ./gradlew publish + env: + ossrhUsername: ${{ secrets.OSSRHUSERNAME }} + ossrhPassword: ${{ secrets.OSSRHPASSWORD }} + + - uses: actions/setup-python@main + + - name: Install XSLT Processor + run: sudo apt-get install -y xsltproc sphinx-common + + - name: Install Python dependencies + run: pip install manticore_sphinx_theme sphinx_javadoc_xml myst_parser sphinx_substitution_extensions sphinx_issues sphinx_inline_tabs pygments + + - name: Build Sphinx documentation with Gradle + run: FLOATING_TOC=false ./gradlew -DFLOATING_TOC=false gitChangelogTask renderRR xslt xmldoc sphinx + + - name: Configure GitHub Pages + uses: actions/configure-pages@main + + - name: Upload artifact + uses: actions/upload-pages-artifact@main + with: + path: 'build/sphinx' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@main diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index 67ccc3166..000000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,35 +0,0 @@ -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle - -name: Gradle CI - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -permissions: - contents: read - -jobs: - check: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'temurin' - - name: Build with Gradle - uses: gradle/gradle-build-action@v2.6.0 - with: - arguments: check - env: - ossrhUsername: ${{ secrets.OSSRHPASSWORD }} - ossrhPassword: ${{ secrets.OSSRHUSERNAME }} diff --git a/.github/workflows/gradle_publish.yml b/.github/workflows/gradle_publish.yml deleted file mode 100644 index 4e8cbddea..000000000 --- a/.github/workflows/gradle_publish.yml +++ /dev/null @@ -1,37 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle - -name: Gradle publish Snapshot - -on: - workflow_dispatch: - -permissions: - contents: read - -jobs: - publish: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'temurin' - - name: Build with Gradle - uses: gradle/gradle-build-action@v2.6.0 - with: - arguments: publish - # arguments: build check publish - env: - ossrhUsername: ${{ secrets.OSSRHPASSWORD }} - ossrhPassword: ${{ secrets.OSSRHUSERNAME }} diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index 3c265b631..000000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,36 +0,0 @@ -# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven - -name: Maven CI - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - package: - - runs-on: ubuntu-latest - strategy: - matrix: - java: [11] - name: Java ${{ matrix.java }} building ... - - steps: - - uses: actions/checkout@v3 - - name: Set up Java ${{ matrix.java }} - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: 'temurin' - cache: maven - server-id: sonatype-nexus-snapshots - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD - - name: Build with Maven - run: mvn -B package --file pom.xml -DdisableXmlReport=true -Djacoco.skip=true -Dpmd.skip=true - env: - MAVEN_USERNAME: ${{ secrets.OSSRHUSERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRHPASSWORD }} diff --git a/.github/workflows/maven_deploy.yml b/.github/workflows/maven_deploy.yml deleted file mode 100644 index e63de93eb..000000000 --- a/.github/workflows/maven_deploy.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Maven deploy snapshot - -on: - push: - branches: [ "master" ] - -jobs: - deploy: - - runs-on: ubuntu-latest - strategy: - matrix: - java: [11] - name: Java ${{ matrix.java }} building ... - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Java ${{ matrix.java }} - uses: actions/setup-java@v4 - with: - java-version: ${{ matrix.java }} - distribution: 'temurin' - cache: maven - server-id: sonatype-nexus-snapshots - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD - - name: Build with Maven - run: mvn -B deploy --file pom.xml -DdisableXmlReport=true -Djacoco.skip=true -Dpmd.skip=true - env: - MAVEN_USERNAME: ${{ secrets.OSSRHUSERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRHPASSWORD }} diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml deleted file mode 100644 index 5fb5f9bd3..000000000 --- a/.github/workflows/sphinx.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Sphinx Pages -on: - push: - branches: [ "master" ] - -permissions: write-all -jobs: - docs: - runs-on: ubuntu-latest - steps: - - uses: actions/setup-python@v4 - - name: Install XSLT Processor - run: sudo apt-get install xsltproc sphinx-common - - name: Install dependencies - run: pip install furo myst_parser sphinx-prompt sphinx_substitution_extensions sphinx_issues sphinx_inline_tabs pygments - - name: Checkout project sources - uses: actions/checkout@v4 - with: - ref: master - fetch-depth: 0 - - name: Setup Gradle - uses: gradle/gradle-build-action@v2.4.2 - - name: Run build with Gradle Wrapper - run: FLOATING_TOC=false gradle --no-build-cache clean xmldoc sphinx - - name: Deploy - uses: actions/configure-pages@v2 - - name: Upload artifact - uses: actions/upload-pages-artifact@v1 - with: - # Upload entire repository - path: 'build/sphinx' - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 diff --git a/.gitignore b/.gitignore index a2b625283..955e7bf2d 100755 --- a/.gitignore +++ b/.gitignore @@ -8,10 +8,10 @@ # Exclude the Auto-generated Changelog /src/site/sphinx/changelog.rst -/src/site/sphinx/javadoc_stable.rst /src/site/sphinx/syntax_stable.rst -/src/site/sphinx/javadoc_snapshot.rst /src/site/sphinx/syntax_snapshot.rst +/src/site/sphinx/javadoc_stable.xml +/src/site/sphinx/javadoc_snapshot.xml # Generated by javacc-maven-plugin /bin @@ -32,3 +32,6 @@ /nbproject/ /.gradle + +# Mac +.DS_Store diff --git a/README.md b/README.md index 083165f7c..42122c891 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,22 @@ -# [JSqlParser 5.0 Website](https://jsqlparser.github.io/JSqlParser) drawing +# [JSqlParser 5.3 Website](https://jsqlparser.github.io/JSqlParser) drawing -[![Maven deploy snapshot](https://github.com/JSQLParser/JSqlParser/actions/workflows/maven_deploy.yml/badge.svg)](https://github.com/JSQLParser/JSqlParser/actions/workflows/maven_deploy.yml) -[![Gradle CI](https://github.com/JSQLParser/JSqlParser/actions/workflows/gradle.yml/badge.svg)](https://github.com/JSQLParser/JSqlParser/actions/workflows/gradle.yml) -[![Coverage Status](https://coveralls.io/repos/JSQLParser/JSqlParser/badge.svg?branch=master)](https://coveralls.io/r/JSQLParser/JSqlParser?branch=master) +[![CI](https://github.com/JSQLParser/JSqlParser/actions/workflows/ci.yml/badge.svg)](https://github.com/JSQLParser/JSqlParser/actions/workflows/ci.yml) +[![Coverage Status](https://coveralls.io/repos/JSQLParser/JSqlParser/badge.svg?branch=master)](https://coveralls.io/r/JSQLParser/JSqlParser?branch=master) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/6f9a2d7eb98f45969749e101322634a1)](https://www.codacy.com/gh/JSQLParser/JSqlParser/dashboard?utm_source=github.com&utm_medium=referral&utm_content=JSQLParser/JSqlParser&utm_campaign=Badge_Grade) -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.jsqlparser/jsqlparser/badge.svg)](http://maven-badges.herokuapp.com/maven-central/com.github.jsqlparser/jsqlparser) [![Javadocs](https://www.javadoc.io/badge/com.github.jsqlparser/jsqlparser.svg)](https://www.javadoc.io/doc/com.github.jsqlparser/jsqlparser) +[![Maven Central](https://img.shields.io/maven-central/v/com.github.jsqlparser/jsqlparser.svg?label=maven-central)](https://central.sonatype.com/artifact/com.github.jsqlparser/jsqlparser) [![Javadocs](https://www.javadoc.io/badge/com.github.jsqlparser/jsqlparser.svg)](https://www.javadoc.io/doc/com.github.jsqlparser/jsqlparser) [![Gitter](https://badges.gitter.im/JSQLParser/JSqlParser.svg)](https://gitter.im/JSQLParser/JSqlParser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) +A huge thank you to our sponsor, [Starlake.ai](https://starlake.ai/) who simplifies data ingestion, transformation, and orchestration, enabling faster delivery of high-quality data. Starlake has been instrumental in providing Piped SQL and numerous test cases for BigQuery, Redshift, DataBricks, and DuckDB. Show your support for ongoing development by visiting Starlake.ai and giving us a star! + ## Summary -Please visit the [WebSite](https://jsqlparser.github.io/JSqlParser). **JSqlParser** is a RDBMS agnostic SQL statement parser. It translates SQL statements into a traversable hierarchy of Java classes (see [Samples](https://jsqlparser.github.io/JSqlParser/usage.html#parse-a-sql-statements)): +Please visit our [WebSite](https://jsqlparser.github.io/JSqlParser) for detailed information. **JSqlParser** is a RDBMS agnostic SQL statement parser. It translates SQL statements into a traversable hierarchy of Java classes (see [Samples](https://jsqlparser.github.io/JSqlParser/usage.html#parse-a-sql-statements)): ```sql SELECT 1 FROM dual WHERE a = b -``` -```text +/* produces the following AST + SQL Text └─Statements: statement.select.PlainSelect ├─selectItems: statement.select.SelectItem @@ -24,6 +25,7 @@ SQL Text └─where: expression.operators.relational.EqualsTo ├─Column: a └─Column: b +*/ ``` ```java @@ -45,19 +47,54 @@ Column a = (Column) equalsTo.getLeftExpression(); Column b = (Column) equalsTo.getRightExpression(); Assertions.assertEquals("a", a.getColumnName()); Assertions.assertEquals("b", b.getColumnName()); -} ``` +## Support for `Piped SQL` + +Work is progressing for parsing `Piped SQL`, a much saner and more logical way to write queries in its semantic order. +```sql +FROM Produce +|> WHERE + item != 'bananas' + AND category IN ('fruit', 'nut') +|> AGGREGATE COUNT(*) AS num_items, SUM(sales) AS total_sales + GROUP BY item +|> ORDER BY item DESC; +``` + +For details, please see https://storage.googleapis.com/gweb-research2023-media/pubtools/1004848.pdf, https://cloud.google.com/bigquery/docs/reference/standard-sql/pipe-syntax and https://duckdb.org/docs/sql/query_syntax/from.html#from-first-syntax + +## Java Version -JSQLParser-4.9 was the last JDK8 compatible version. The recent JSQLParser-5.0 depends on JDK11 and introduces API breaking changes to the AST Visitors. Please see the Migration Guide for the details. +JSQLParser-4.9 was the last JDK8 compatible version. JSQLParser-5.0 and later depend on JDK11 and introduce API breaking changes to the AST Visitors. Please see the Migration Guide for the details. + +Building JSQLParser-5.1 and newer with Gradle will depend on a JDK17 toolchain due to the used plugins. + +JSQLParser-5.4 Snapshot and later use JavaCC-8 Snapshots for generating the parser. + +## Performance + +Unfortunately the released JSQLParser-5.2 shows a performance deterioration caused by commit [30cf5d7](https://github.com/JSQLParser/JSqlParser/commit/30cf5d7b930ae0a076f49deb5cc841d39e62b3dc) related to `FunctionAllColumns()`. +This has been resolved in JSQLParser 5.3-SNAPSHOT and JMH benchmarks have been added to avoid such regressions in the future. Further all `LOOKAHEAD` have been revised one by one, and we have gained back a very good performance of the Parser. + +As per March-2026, the productions `Condition()`, `RegularCondition()` and `AndExpression()` have been refactored successfully. Furthermore, we have overhauled Token definition and handling of Reserved Keywords. This resulted in a massive performance boost and seem to have solved most of the performance issues. + +```text +Benchmark (version) Mode Cnt Score Error Units +JSQLParserBenchmark.parseSQLStatements latest avgt 15 7.602 ± 0.135 ms/op <-- March/26 +JSQLParserBenchmark.parseSQLStatements 5.3 avgt 15 84.687 ± 3.321 ms/op +JSQLParserBenchmark.parseSQLStatements 5.1 avgt 15 86.592 ± 5.781 ms/op +``` ## [Supported Grammar and Syntax](https://jsqlparser.github.io/JSqlParser/syntax.html) **JSqlParser** aims to support the SQL standard as well as all major RDBMS. Any missing syntax or features can be added on demand. -| RDBMS | Statements | -|-----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------| -| Oracle
MS SQL Server and Sybase
Postgres
MySQL and MariaDB
DB2
H2 and HSQLDB and Derby
SQLite | `SELECT`
`INSERT`, `UPDATE`, `UPSERT`, `MERGE`
`DELETE`, `TRUNCATE TABLE`
`CREATE ...`, `ALTER ....`, `DROP ...`
`WITH ...` | -| Salesforce SOQL | `INCLUDES`, `EXCLUDES` | +| RDBMS | Statements | +|-----------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------| +| BigQuery
Snowflake
DuckDB
Redshift
Oracle
MS SQL Server and Sybase
Postgres
MySQL and MariaDB
DB2
H2 and HSQLDB and Derby
SQLite | `SELECT`
`INSERT`, `UPDATE`, `UPSERT`, `MERGE`
`DELETE`, `TRUNCATE TABLE`
`CREATE ...`, `ALTER ....`, `DROP ...`
`WITH ...` | +| PostgreSQL Row Level Security | `CREATE POLICY`
`ALTER TABLE ... ENABLE/DISABLE/FORCE/NO FORCE ROW LEVEL SECURITY` | +| Salesforce SOQL | `INCLUDES`, `EXCLUDES` | +| Piped SQL (also known as FROM SQL) | | **JSqlParser** can also be used to create SQL Statements from Java Code with a fluent API (see [Samples](https://jsqlparser.github.io/JSqlParser/usage.html#build-a-sql-statements)). @@ -67,12 +104,11 @@ If you like JSqlParser then please check out its related projects: * [JSQLFormatter](https://manticore-projects.com/JSQLFormatter/index.html) for pretty printing and formatting SQL Text -* [JSQLTranspiler](https://manticore-projects.com/JSQLTranspiler/index.html) for dialect specific rewriting, SQL Column resolution and Lineage +* [JSQLTranspiler](https://manticore-projects.com/JSQLTranspiler/index.html) for dialect specific rewriting, SQL Column resolution and Lineage, provided by [Starlake.ai](https://starlake.ai/) ## Alternatives to JSqlParser? -[**General SQL Parser**](http://www.sqlparser.com/features/introduce.php?utm_source=github-jsqlparser&utm_medium=text-general) looks pretty good, with extended SQL syntax (like PL/SQL and T-SQL) and java + .NET APIs. The tool is commercial (license available online), with a free download option. -Alternatively the dual-licensed [JOOQ](https://www.jooq.org/doc/latest/manual/sql-building/sql-parser/) provides a hand-written Parser supporting a lot of RDBMS, translation between dialects, SQL transformation, can be used as a JDBC proxy for translation and transformation purposes. +Alternatively the dual-licensed [JOOQ](https://www.jooq.org/doc/latest/manual/sql-building/sql-parser/) provides a handwritten Parser supporting a lot of RDBMS, translation between dialects, SQL transformation, can be used as a JDBC proxy for translation and transformation purposes. ## [Documentation](https://jsqlparser.github.io/JSqlParser) 1. [Samples](https://jsqlparser.github.io/JSqlParser/usage.html#parse-a-sql-statements) diff --git a/build.gradle b/build.gradle index c5d77bf30..a690cef6b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,13 @@ import se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask +import com.nwalsh.gradle.saxon.SaxonXsltTask + +import java.time.Instant + +buildscript { + dependencies { + classpath group: 'net.sf.saxon', name: 'Saxon-HE', version: 'latest.release' + } +} plugins { id 'java' @@ -12,6 +21,7 @@ plugins { id "com.diffplug.spotless" version "latest.release" id 'pmd' id 'checkstyle' + id 'eclipse' // download the RR tools which have no Maven Repository id "de.undercouch.download" version "latest.release" @@ -19,7 +29,8 @@ plugins { id "se.bjurr.gitchangelog.git-changelog-gradle-plugin" version "latest.release" id "me.champeau.jmh" version "latest.release" - id "com.nwalsh.gradle.saxon.saxon-gradle" version "0.9.6" + id "com.nwalsh.gradle.saxon.saxon-gradle" version "latest.release" + id 'biz.aQute.bnd.builder' version "latest.release" } def getVersion = { boolean considerSnapshot -> @@ -27,58 +38,106 @@ def getVersion = { boolean considerSnapshot -> Integer minor = 0 Integer patch = null Integer build = null - def commit = null - def snapshot = "" - new ByteArrayOutputStream().withStream { os -> - exec { - args = [ - "--no-pager" - , "describe" - , "--tags" - , "--always" - , "--dirty=-SNAPSHOT" - ] - executable "git" - standardOutput = os - } - def versionStr = os.toString().trim() - def pattern = /(?\d*)\.(?\d*)(\.(?\d*))?(-(?\d*)-(?[a-zA-Z\d]*))?/ - def matcher = versionStr =~ pattern - if (matcher.find()) { - major = matcher.group('major') as Integer - minor = matcher.group('minor') as Integer - patch = matcher.group('patch') as Integer - build = matcher.group('build') as Integer - commit = matcher.group('commit') - } + String commit = null + String snapshot = "" + + def versionStr = providers.exec { + commandLine "git", "--no-pager", "-C", project.projectDir, "describe", "--tags", "--always", "--dirty=-SNAPSHOT" + }.standardOutput.asText.get().trim() + + def pattern = /jsqlparser-(?\d*)\.(?\d*)(\.(?\d*))?(-(?\d*)-(?[a-zA-Z\d]*))?/ + def matcher = versionStr =~ pattern + + if (matcher.find()) { + major = matcher.group('major') as Integer ?: 0 + minor = matcher.group('minor') as Integer ?: 0 + patch = matcher.group('patch') as Integer ?: null + build = matcher.group('build') as Integer ?: null + commit = matcher.group('commit') ?: null + } - if (considerSnapshot && ( versionStr.endsWith('SNAPSHOT') || build!=null) ) { - minor++ - if (patch!=null) patch = 0 - snapshot = "-SNAPSHOT" - } + if (considerSnapshot && (versionStr.endsWith('SNAPSHOT') || build != null)) { + minor++ + if (patch != null) patch = 0 + snapshot = "-SNAPSHOT" } - return patch!=null + + return patch != null ? "${major}.${minor}.${patch}${snapshot}" - : "${major}.${minor}${snapshot}" + : "${major}.${minor}${snapshot}" } + // for publishing a release, call Gradle with Environment Variable RELEASE: // RELEASE=true gradle JSQLParser:publish version = getVersion( !System.getenv("RELEASE") ) group = 'com.github.jsqlparser' description = 'JSQLParser library' -archivesBaseName = "JSQLParser" + +tasks.register('generateBuildInfo') { + outputs.dir layout.buildDirectory.file("resources/main") + doLast { + def outputDir = new File( layout.buildDirectory.file("generated/sources/buildinfo/java/main").get().asFile, "net/sf/jsqlparser") + outputDir.mkdirs() + + def gitVersionStr = providers.exec { + commandLine "git", "--no-pager", "-C", project.projectDir, "describe", "--tags", "--always", "--dirty=-SNAPSHOT" + }.standardOutput.asText.get().trim() + + def gitCommitStr = providers.exec { + commandLine "git", "--no-pager", "-C", project.projectDir, "rev-parse", "--short", "HEAD" + }.standardOutput.asText.get().trim() + + def buildTime = Instant.now().toString() + + def content = """\ + |package net.sf.jsqlparser; + | + |public final class BuildInfo { + | public static final String NAME = "${project.name}"; + | public static final String VERSION = "${gitVersionStr}"; + | public static final String GIT_COMMIT = "${gitCommitStr ?: 'unknown'}"; + | public static final String BUILD_TIME = "${buildTime}"; + |} + """.stripMargin() + + new File(outputDir, "BuildInfo.java").text = content + } +} + +// Make sure the file is included in the compiled sources +sourceSets { + main { + java { + srcDir layout.buildDirectory.file("generated/sources/buildinfo/java/main").get().asFile + } + } +} + +tasks.withType(JavaCompile).configureEach { + mustRunAfter("generateBuildInfo") +} + +tasks.withType(Pmd).configureEach { + mustRunAfter("generateBuildInfo") +} + +tasks.withType(Checkstyle).configureEach { + exclude '**/module-info.java', '**/package-info.java' + + mustRunAfter("generateBuildInfo") +} repositories { gradlePluginPortal() - mavenLocal() mavenCentral() - // Sonatype OSSRH + // JavaCC 8 Snapshots maven { - url = uri('https://s01.oss.sonatype.org/content/repositories/snapshots/') + url = uri('https://central.sonatype.com/repository/maven-snapshots/') } + + maven { url "https://dev.saxonica.com/maven" } } configurations { @@ -95,27 +154,121 @@ dependencies { testImplementation 'com.h2database:h2:+' // for JaCoCo Reports - testImplementation 'org.junit.jupiter:junit-jupiter-api:+' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:+' - testImplementation 'org.junit.jupiter:junit-jupiter-params:+' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.4' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.4' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.4' + testImplementation 'org.junit.jupiter:junit-jupiter-params:5.11.4' // https://mvnrepository.com/artifact/org.mockito/mockito-junit-jupiter - testImplementation 'org.mockito:mockito-junit-jupiter:+' + testImplementation 'org.mockito:mockito-junit-jupiter:5.18.0' // Performance Benchmark testImplementation 'org.openjdk.jmh:jmh-core:+' testImplementation 'org.openjdk.jmh:jmh-generator-annprocess:+' // Java Doc in XML Format - xmlDoclet 'com.manticore-projects.tools:xml-doclet:+' + xmlDoclet ('com.manticore-projects.tools:xml-doclet:+'){ changing = true } // enforce latest version of JavaCC - testImplementation 'net.java.dev.javacc:javacc:+' - javacc 'net.java.dev.javacc:javacc:+' + testImplementation('org.javacc:core:8.1.0-SNAPSHOT') { changing = true } + testImplementation('org.javacc.generator:java:8.1.0-SNAPSHOT') { changing = true } + + jmh 'org.openjdk.jmh:jmh-core:1.37' + jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.37' + javacc('org.javacc:core:8.1.0-SNAPSHOT') { changing = true } + javacc('org.javacc.generator:java:8.1.0-SNAPSHOT') { changing = true } +} +configurations.configureEach { + resolutionStrategy.eachDependency { DependencyResolveDetails details -> + if (details.requested.group in ['org.javacc:core', 'org.javacc.generator']) { + // Check for updates every build + resolutionStrategy.cacheChangingModulesFor 30, 'seconds' + } + } } compileJavacc { - arguments = [grammar_encoding: 'UTF-8', static: 'false', java_template_type: 'modern'] + arguments = [ + grammar_encoding: 'UTF-8', + static: 'false', + java_template_type: 'modern', + // Comment this in to build the parser with tracing. + DEBUG_PARSER: 'false', + DEBUG_LOOKAHEAD: 'false' + ] +} + +// Post-process the generated CCJSqlParserTokenManager.java to split large static +// array initializers into separate methods, preventing the method from +// exceeding the JVM's 64KB bytecode limit (which breaks ASM-based tools like sbt-assembly). +tasks.register('splitTokenManagerStaticInit') { + dependsOn(compileJavacc) + + def tokenManagerFile = layout.buildDirectory.file( + "generated/javacc/net/sf/jsqlparser/parser/CCJSqlParserTokenManager.java" + ) + + inputs.file(tokenManagerFile) + outputs.file(tokenManagerFile) + + doLast { + def file = tokenManagerFile.get().asFile + if (!file.exists()) { + throw new GradleException("CCJSqlParserTokenManager.java not found at ${file}") + } + def content = file.text + + // Pattern matches static final array field declarations with inline initialization. + // We extract large ones and move their initialization into separate methods. + def fieldsToExtract = [ + // [regex-safe field name, array type for method return] + ['stringLiterals', 'int[]'], + ['jjstrLiteralImages', 'String[]'], + ['jjmatchKinds', 'int[]'], + ['jjnewLexState', 'int[]'], + ] + + fieldsToExtract.each { entry -> + def fieldName = entry[0] + def arrayType = entry[1] + + // Match: = { ... }; + // The field declaration may use 'public' or 'private' and 'static final' + def pattern = ~"(?s)((?:public|private)\\s+static\\s+final\\s+${java.util.regex.Pattern.quote(arrayType)}\\s+${fieldName}\\s*=\\s*)\\{(.*?)\\};" + def matcher = pattern.matcher(content) + if (matcher.find()) { + def prefix = matcher.group(1) + def body = matcher.group(2) + def methodName = "_init_${fieldName}" + def replacement = "${prefix}${methodName}();\n" + + " private static ${arrayType} ${methodName}() { return new ${arrayType} {${body}}; }" + content = matcher.replaceFirst(java.util.regex.Matcher.quoteReplacement(replacement)) + logger.lifecycle("splitTokenManagerStaticInit: extracted ${fieldName} initialization into ${methodName}()") + } + } + + // Handle int[][] arrays separately (jjcompositeState, jjnextStateSet) + def arrayArrayFields = ['jjcompositeState', 'jjnextStateSet'] + arrayArrayFields.each { fieldName -> + def pattern = ~"(?s)(private\\s+static\\s+final\\s+int\\[\\]\\[\\]\\s+${fieldName}\\s*=\\s*)\\{(.*?)\\};" + def matcher = pattern.matcher(content) + if (matcher.find()) { + def prefix = matcher.group(1) + def body = matcher.group(2) + def methodName = "_init_${fieldName}" + def replacement = "${prefix}${methodName}();\n" + + " private static int[][] ${methodName}() { return new int[][] {${body}}; }" + content = matcher.replaceFirst(java.util.regex.Matcher.quoteReplacement(replacement)) + logger.lifecycle("splitTokenManagerStaticInit: extracted ${fieldName} initialization into ${methodName}()") + } + } + + file.text = content + } +} + +tasks.withType(JavaCompile).configureEach { + dependsOn('splitTokenManagerStaticInit') } java { @@ -124,16 +277,13 @@ java { sourceCompatibility = '11' targetCompatibility = '11' + // needed for XML-Doclet to work (since Doclet changed again with Java 13) toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) + languageVersion.set(JavaLanguageVersion.of(17)) } } -compileJava { - options.release = 11 -} - javadoc { include("build/generated/javacc/net/sf/jsqlparser/parser/*.java" ) if(JavaVersion.current().isJava9Compatible()) { @@ -145,51 +295,70 @@ javadoc { jar { manifest { attributes ( - "Automatic-Module-Name": "net.sf.jsqlparser" + "Automatic-Module-Name": "net.sf.jsqlparser" + ) + } + + bundle { + properties.empty() + bnd( + "Created-By": System.properties.get('user.name'), + "Bundle-SymbolicName": "net.sf.jsqlparser", + "Import-Package": "*", + "Export-Package": "net.sf.jsqlparser.*", + "Automatic-Module-Name": "net.sf.jsqlparser" ) } + + dependsOn(generateBuildInfo) } tasks.register('xmldoc', Javadoc) { + dependsOn(compileJavacc) + def outFile = reporting.file( version.endsWith("-SNAPSHOT") ? "xmlDoclet/javadoc_snapshot.xml" : "xmlDoclet/javadoc_stable.xml" ) - def rstFile = reporting.file( - version.endsWith("-SNAPSHOT") - ? "xmlDoclet/javadoc_snapshot.rst" - : "xmlDoclet/javadoc_stable.rst" - ) - source = sourceSets.main.allJava - // beware: Gradle deletes this folder automatically and there is no switch-off + // add any generated Java sources + source += fileTree(layout.buildDirectory.dir("generated/javacc").get().asFile) { + include '**/*.java' + } + source += fileTree(layout.buildDirectory.dir("generated/jjtree").get().asFile) { + include '**/*.java' + } + + classpath = sourceSets.main.runtimeClasspath + destinationDir = reporting.file("xmlDoclet") options.docletpath = configurations.xmlDoclet.files as List - options.doclet = "com.github.markusbernhardt.xmldoclet.XmlDoclet" + options.doclet = "com.manticore.tools.xmldoclet.XmlDoclet" title = "API $version" - options.addBooleanOption("rst", true) - options.addBooleanOption("withFloatingToc", Boolean.parseBoolean(System.getenv().getOrDefault("FLOATING_TOC", "true"))) + options.addStringOption("basePackage", "net.sf.jsqlparser") options.addStringOption("filename", outFile.getName()) - dependsOn(compileJava) doLast { copy { - from rstFile - into "${projectDir}/src/site/sphinx/" + from outFile + into layout.projectDirectory.dir("src/site/sphinx/").asFile } } } test { - environment = [ 'EXPORT_TEST_TO_FILE': 'True' ] + environment = [ 'EXPORT_TEST_TO_FILE': 'False' ] useJUnitPlatform() // set heap size for the test JVM(s) - minHeapSize = "128m" - maxHeapSize = "1G" + minHeapSize = "1G" + maxHeapSize = "4G" + + // set JVM stack size + jvmArgs = ['-Xss2m', '--add-opens=java.base/java.lang=ALL-UNNAMED'] jacoco { excludes = ['net/sf/jsqlparser/parser/CCJSqlParserTokenManager'] @@ -238,7 +407,7 @@ jacocoTestCoverageVerification { //@todo: temporarily increased to 7000, we need to bring that down to 5500 after accepting the Keywords PR maximum = 20000 - } + } excludes = [ 'net.sf.jsqlparser.util.validation.*', 'net.sf.jsqlparser.**.*Adapter', @@ -263,37 +432,41 @@ jacocoTestCoverageVerification { spotbugsMain { reports { - html { - enabled = true - destination = file("build/reports/spotbugs/main/spotbugs.html") - stylesheet = 'fancy-hist.xsl' - } + html.required.set(true) + html.outputLocation.set( layout.buildDirectory.file("reports/spotbugs/main/spotbugs.html").get().asFile ) + html.stylesheet="fancy-hist.xsl" } } + spotbugs { // fail only on P1 and without the net.sf.jsqlparser.parser.* excludeFilter = file("config/spotbugs/spotBugsExcludeFilter.xml") +} - // do not run over the test, although we should do that eventually - spotbugsTest.enabled = false +// do not run over the test, although we should do that eventually +tasks.named('spotbugsTest').configure { + enabled = false } pmd { + // later versions throw NPE + toolVersion = '7.17.0' + consoleOutput = true sourceSets = [sourceSets.main] // clear the ruleset in order to use configured rules only ruleSets = [] - - //rulesMinimumPriority = 1 + rulesMinimumPriority = 2 ruleSetFiles = files("config/pmd/ruleset.xml") +} - pmdMain { - excludes = [ - "build/generated/*" - ] - } +tasks.named('pmdMain').configure { + excludes = [ + "build/generated/*" + , "**/net/sf/jsqlparser/parser/SimpleCharStream.java" + ] } checkstyle { @@ -301,6 +474,17 @@ checkstyle { configFile = rootProject.file('config/checkstyle/checkstyle.xml') } +tasks.withType(Checkstyle).configureEach { + reports { + xml.required = false + html.required = true + } + excludes = [ + "**/module-info.java" + , "net/sf/jsqlparser/parser/SimpleCharStream.java" + ] +} + spotless { // optional: limit format enforcement to just the files changed by this feature branch ratchetFrom 'origin/master' @@ -311,82 +495,81 @@ spotless { // define the steps to apply to those files trimTrailingWhitespace() - indentWithSpaces(4) // or spaces. Takes an integer argument if you don't like 4 + leadingTabsToSpaces(4) endWithNewline() } java { - indentWithSpaces(4) + leadingTabsToSpaces(4) eclipse().configFile('config/formatter/eclipse-java-google-style.xml') } } -tasks.withType(Checkstyle).configureEach { - reports { - xml.required = false - html.required = true - } - excludes = [ "**/module-info.java" ] -} tasks.register('renderRR') { dependsOn(compileJavacc) + doLast { - // these WAR files have been provided as a courtesy by Gunther Rademacher - // and belong to the RR - Railroad Diagram Generator Project - // https://github.com/GuntherRademacher/rr - // - // Hosting at manticore-projects.com is temporary until a better solution is found - // Please do not use these files without Gunther's permission + def rrDir = layout.buildDirectory.dir("rr").get().asFile + + // Download convert.war download.run { src 'http://manticore-projects.com/download/convert.war' - dest "$buildDir/rr/convert.war" + dest new File(rrDir, "convert.war") overwrite false onlyIfModified true } + // Download rr.war download.run { src 'http://manticore-projects.com/download/rr.war' - dest "$buildDir/rr/rr.war" + dest new File(rrDir, "rr.war") overwrite false onlyIfModified true tempAndMove true } - javaexec { - standardOutput = new FileOutputStream("${buildDir}/rr/JSqlParserCC.ebnf") - main = "-jar" - args = [ - "$buildDir/rr/convert.war", - "$buildDir/generated/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jj" - ] + // Convert JJ file to EBNF + def ebnfFile = new File(rrDir, "JSqlParserCC.ebnf") + def jjFile = layout.buildDirectory.dir("generated/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jj").get().asFile.absolutePath + + def convertProc = new ProcessBuilder('java', '-jar', + new File(rrDir, "convert.war").absolutePath, + jjFile) + .redirectOutput(ebnfFile) + .redirectErrorStream(true) + .start() + if (convertProc.waitFor() != 0) { + throw new GradleException("Failed to convert JJ to EBNF") } - javaexec { - main = "-jar" - args = [ - "$buildDir/rr/rr.war", - "-noepsilon", - "-color:#4D88FF", - "-offset:0", - "-width:800", - //"-png", - //"-out:${buildDir}/rr/JSqlParserCC.zip", - "-out:${buildDir}/rr/JSqlParserCC.xhtml", - "${buildDir}/rr/JSqlParserCC.ebnf" - ] + // Generate RR diagrams + def rrProc = new ProcessBuilder('java', '-jar', + new File(rrDir, "rr.war").absolutePath, + "-noepsilon", + "-color:#4D88FF", + "-offset:0", + "-width:800", + "-out:${new File(rrDir, "JSqlParserCC.xhtml")}", + new File(rrDir, "JSqlParserCC.ebnf").absolutePath) + .redirectErrorStream(true) + .start() + rrProc.inputStream.eachLine { logger.info(it) } + if (rrProc.waitFor() != 0) { + throw new GradleException("Failed to generate RR diagrams") } } } + tasks.register('gitChangelogTask', GitChangelogTask) { - fromRepo = file("$projectDir") - file = new File("${projectDir}/src/site/sphinx/changelog.rst") - fromRef = "4.0" + fromRepo.set( file("$projectDir").toString() ) + file.set( new File("${projectDir}/src/site/sphinx/changelog.rst") ) + fromRevision.set( "4.0") //toRef = "1.1"; // switch off the formatter since the indentation matters for Mark-down // @formatter:off - templateContent =""" + templateContent.set (""" ************************ Changelog ************************ @@ -413,38 +596,38 @@ Version {{name}} {{/issues}} {{/tags}} -""" +""") // @formatter:on } tasks.register('updateKeywords', JavaExec) { group = "Execution" - description = "Run the main class with JavaExecTask" + description = "Generate the Reserved Keywords documentation" classpath = sourceSets.main.runtimeClasspath args = [ file('src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt').absolutePath , file('src/site/sphinx/keywords.rst').absolutePath ] - main("net.sf.jsqlparser.parser.ParserKeywordsUtils") + mainClass.set("net.sf.jsqlparser.parser.ParserKeywordsUtils") dependsOn(compileJava) } -xslt { +tasks.register('xslt', SaxonXsltTask) { def outFile = version.endsWith("-SNAPSHOT") - ? file("src/site/sphinx/syntax_snapshot.rst") - : file("src/site/sphinx/syntax_stable.rst") + ? file("src/site/sphinx/syntax_snapshot.rst") + : file("src/site/sphinx/syntax_stable.rst") dependsOn(renderRR) - stylesheet 'src/main/resources/rr/xhtml2rst.xsl' + stylesheet file('src/main/resources/rr/xhtml2rst.xsl') - parameters ( - "withFloatingToc": System.getenv().getOrDefault("FLOATING_TOC", "true"), + parameters( + "withFloatingToc": System.getProperty("FLOATING_TOC", "false"), "isSnapshot": Boolean.toString(version.endsWith("-SNAPSHOT")) ) // Transform every .xml file in the "input" directory. - input "$buildDir/rr/JSqlParserCC.xhtml" + input layout.buildDirectory.file("rr/JSqlParserCC.xhtml").get() output outFile } @@ -475,7 +658,7 @@ tasks.register('sphinx', Exec) { , "-Drelease=${getVersion(false)}" , "-Drst_prolog=$PROLOG" , "${projectDir}/src/site/sphinx" - , "${project.buildDir}/sphinx" + , layout.buildDirectory.file("sphinx").get().asFile ] executable "sphinx-build" @@ -499,6 +682,7 @@ publishing { artifactId = 'jsqlparser' from components.java + versionMapping { usage('java-api') { fromResolutionOf('runtimeClasspath') @@ -507,54 +691,61 @@ publishing { fromResolutionResult() } } + pom { - name = 'JSQLParser library' - description = 'Parse SQL Statements into Abstract Syntax Trees (AST)' - url = 'https://github.com/JSQLParser/JSqlParser' + name.set('JSQLParser library') + description.set('Parse SQL Statements into Abstract Syntax Trees (AST)') + url.set('https://github.com/JSQLParser/JSqlParser') + licenses { license { - name = 'GNU Library or Lesser General Public License (LGPL) V2.1' - url = 'http://www.gnu.org/licenses/lgpl-2.1.html' + name.set('GNU Library or Lesser General Public License (LGPL) V2.1') + url.set('http://www.gnu.org/licenses/lgpl-2.1.html') } license { - name = 'The Apache Software License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + name.set('The Apache Software License, Version 2.0') + url.set('http://www.apache.org/licenses/LICENSE-2.0.txt') } } + developers { developer { - id = 'twa' - name = 'Tobias Warneke' - email = 't.warneke@gmx.net' + id.set('twa') + name.set('Tobias Warneke') + email.set('t.warneke@gmx.net') } developer { - id = 'are' - name = 'Andreas Reichel' - email = 'andreas@manticore-projects.com' + id.set('are') + name.set('Andreas Reichel') + email.set('andreas@manticore-projects.com') } } + scm { - connection = 'scm:git:https://github.com/JSQLParser/JSqlParser.git' - developerConnection = 'scm:git:ssh://git@github.com:JSQLParser/JSqlParser.git' - url = 'https://github.com/JSQLParser/JSqlParser.git' + connection.set('scm:git:https://github.com/JSQLParser/JSqlParser.git') + developerConnection.set('scm:git:ssh://git@github.com:JSQLParser/JSqlParser.git') + url.set('https://github.com/JSQLParser/JSqlParser.git') } } } } + repositories { maven { - name "ossrh" - def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" - def snapshotsRepoUrl= "https://oss.sonatype.org/content/repositories/snapshots/" - url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + name = "ossrh" + def releasesRepoUrl = "https://central.sonatype.com/repository/maven-releases" + def snapshotsRepoUrl = "https://central.sonatype.com/repository/maven-snapshots/" + url(version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl) + credentials { - username = System.getenv("ossrhUsername") - password = System.getenv("ossrhPassword") + username = providers.environmentVariable("ossrhUsername").orNull + password = providers.environmentVariable("ossrhPassword").orNull } } } } + signing { //def signingKey = findProperty("signingKey") //def signingPassword = findProperty("signingPassword") @@ -572,12 +763,13 @@ tasks.withType(JavaCompile).configureEach { remotes { webServer { - host = findProperty("${project.name}.host") - user = findProperty("${project.name}.username") - identity = new File("${System.properties['user.home']}/.ssh/id_rsa") + host = findProperty("${project.name}.host") ?: "defaultHost" // Provide default if not found + user = findProperty("${project.name}.username") ?: "defaultUsername" // Provide default if not found + identity = file("${System.getProperty('user.home')}/.ssh/id_rsa") } } + tasks.register('upload') { doFirst { if (findProperty("${project.name}.host") == null) { @@ -594,13 +786,24 @@ tasks.register('upload') { session(remotes.webServer) { def versionStable = getVersion(false) execute "mkdir -p download/${project.name}-${versionStable}" - for (File file: fileTree(include:['*.jar'], dir:"${project.buildDir}/libs").collect()) { + for (File file: fileTree(include:['*.jar'], dir: layout.buildDirectory.dir("libs").get()).collect()) { put from: file, into: "download/${project.name}-${versionStable}" } } } } + + dependsOn(check, assemble, gitChangelogTask, renderRR, xslt, xmldoc) +} + +check { + dependsOn jacocoTestCoverageVerification } -check.dependsOn jacocoTestCoverageVerification -upload.dependsOn(check, assemble, gitChangelogTask, renderRR, xslt, xmldoc) +jmh { + includes = ['.*JSQLParserBenchmark.*'] + warmupIterations = 2 + fork = 3 + iterations = 5 + timeOnIteration = '1s' +} \ No newline at end of file diff --git a/config/pmd/ruleset.xml b/config/pmd/ruleset.xml index acca2d6e9..45804d4c0 100644 --- a/config/pmd/ruleset.xml +++ b/config/pmd/ruleset.xml @@ -20,14 +20,15 @@ under the License. - The default ruleset used by the Maven PMD Plugin, when no other ruleset is specified. - It contains the rules of the old (pre PMD 6.0.0) rulesets java-basic, java-empty, java-imports, - java-unnecessary, java-unusedcode. + Custom PMD ruleset, compatible with PMD 7.x. - This ruleset might be used as a starting point for an own customized ruleset [0]. + Based on the old (pre PMD 6.0.0) rulesets java-basic, java-empty, java-imports, + java-unnecessary, java-unusedcode, migrated for PMD 7. - [0] https://pmd.github.io/latest/pmd_userdocs_making_rulesets.html - + This ruleset might be used as a starting point for an own customized ruleset [0]. + + [0] https://pmd.github.io/latest/pmd_userdocs_making_rulesets.html + @@ -46,6 +47,14 @@ under the License. + + + + + + @@ -63,14 +72,15 @@ under the License. - - + + + @@ -80,16 +90,10 @@ under the License. + + - - - - - - - - - + @@ -97,15 +101,14 @@ under the License. - - - + + - + - + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 0716ad888..8b590d14c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,14 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx1G -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError +org.gradle.jvmargs=-Xmx8G -Xss8m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError -org.gradle.caching=false +org.gradle.caching=true # Modularise your project and enable parallel build org.gradle.parallel=true # Enable configure on demand. -org.gradle.configureondemand=false +org.gradle.configureondemand=true # see https://docs.gradle.org/current/userguide/upgrading_version_8.html#xml_parsing_now_requires_recent_parsers systemProp.javax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136f..d997cfc60 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4413138c..dbc3ce4a0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index b740cf133..f640dbced 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob//platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -112,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -170,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -203,15 +203,14 @@ fi DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, # and any embedded shellness will be escaped. # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be # treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 7101f8e46..c4bdd3ab8 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,92 +1,93 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/pom.xml b/pom.xml index f01ff7452..5ac0c4666 100644 --- a/pom.xml +++ b/pom.xml @@ -2,11 +2,11 @@ 4.0.0 com.github.jsqlparser jsqlparser - 5.1-SNAPSHOT - JSQLParser library + 5.4-SNAPSHOT + JSQLParser library 2004 - JSQLParser + JSQLParser bundle https://github.com/JSQLParser/JSqlParser @@ -24,48 +24,88 @@ + + + javacc8-snapshots + + true + + false + https://central.sonatype.com/repository/maven-snapshots/ + + + ossrh-snapshots + https://central.sonatype.com/repository/maven-snapshots/ + true + false + + + + + javacc8-snapshots + + true + + false + https://central.sonatype.com/repository/maven-snapshots/ + + + ossrh-snapshots + https://central.sonatype.com/repository/maven-snapshots/ + true + false + + + - net.java.dev.javacc - javacc - [7.0.13,) + org.javacc + core + 8.1.0-SNAPSHOT + pom + test + + + org.javacc.generator + java + 8.1.0-SNAPSHOT test commons-io commons-io - [2.15.1,) + 2.18.0 test - org.junit.jupiter - junit-jupiter - [5.10.2,) - test + org.junit.jupiter + junit-jupiter + 5.11.4 + test org.mockito mockito-core - [5.11.0,) + 5.15.2 test org.mockito mockito-junit-jupiter - [5.11.0,) + 5.15.2 test org.assertj assertj-core - [3.25.3,) + (3.27.7,) test org.apache.commons commons-lang3 - [3.14.0,) + [3.18.0,) test @@ -78,10 +118,27 @@ org.hamcrest - hamcrest-all - 1.3 + hamcrest + 2.2 + test + + + + + org.openjdk.jmh + jmh-core + 1.37 test + + + + org.openjdk.jmh + jmh-generator-annprocess + 1.37 + provided + + @@ -94,11 +151,13 @@ sonatype-nexus-staging - https://oss.sonatype.org/service/local/staging/deploy/maven2/ + https://central.sonatype.com/repository/maven-releases - sonatype-nexus-snapshots - https://oss.sonatype.org/content/repositories/snapshots/ + sonatype-nexus-snapshots + https://central.sonatype.com/repository/maven-snapshots/ + false + true @@ -120,7 +179,7 @@ org.codehaus.mojo exec-maven-plugin - 3.1.0 + 3.5.0 net.sf.jsqlparser.parser.ParserKeywordsUtils @@ -132,8 +191,9 @@ org.apache.maven.plugins maven-pmd-plugin - 3.21.2 + 3.26.0 + 2 ${project.basedir}/config/pmd/ruleset.xml @@ -141,6 +201,7 @@ **/*Bean.java **/generated/*.java + **/net/sf/jsqlparser/parser/SimpleCharStream.java target/generated-sources @@ -173,7 +234,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.2.0 + 3.6.0 add-source @@ -192,18 +253,31 @@ maven-compiler-plugin - 3.10.1 + 3.14.0 11 11 true ${project.build.sourceEncoding} true + 2000m + + -J-Xss4M + + true + + + org.openjdk.jmh + jmh-generator-annprocess + 1.37 + + org.javacc.plugin javacc-maven-plugin + 3.8.0 javacc @@ -212,30 +286,30 @@ jjtree-javacc - UTF-8 - false - 1.8 + + -CODE_GENERATOR="Java" + -GRAMMAR_ENCODING="UTF-8" + + + -GRAMMAR_ENCODING="UTF-8" + -CODE_GENERATOR="Java" + - net.java.dev.javacc - javacc - [7.0.13,) + org.javacc.generator + java + 8.1.0-SNAPSHOT + + + org.javacc + core + 8.1.0-SNAPSHOT - - org.apache.maven.plugins - maven-eclipse-plugin - 2.9 - - - /target/generated-sources/javacc - - - org.apache.maven.plugins maven-resources-plugin @@ -271,32 +345,23 @@ org.apache.maven.plugins maven-release-plugin - - 3.0.0-M7 + --> + 3.1.1 true false forked-path sign-release-artifacts - org.apache.maven.plugins maven-source-plugin - 3.2.1 + 3.3.1 attach-sources @@ -309,7 +374,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + 3.11.2 attach-javadocs @@ -317,6 +382,10 @@ ${javadoc.opts} net.sf.jsqlparser.parser none + true + 2g + 800m + -J-Xss4m jar @@ -327,7 +396,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.0 + 3.4.2 @@ -336,41 +405,6 @@ - - maven-site-plugin - 3.12.1 - - - attach-descriptor - - attach-descriptor - - - - - en - - - - org.eluder.coveralls - coveralls-maven-plugin - 4.3.0 - - - org.codehaus.mojo - cobertura-maven-plugin - 2.7 - - xml - - - net/sf/jsqlparser/parser/*.class - net/sf/jsqlparser/JSQLParserException.class - - - - - org.apache.felix maven-bundle-plugin @@ -380,7 +414,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.2.5 + 3.5.2 false @@ -388,13 +422,14 @@ --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED + -Xmx2G -Xms800m -Xss4m org.jacoco jacoco-maven-plugin - 0.8.10 + 0.8.13 @@ -413,7 +448,7 @@ com.diffplug.spotless spotless-maven-plugin - 2.28.0 + 2.44.4 origin/master @@ -454,28 +489,40 @@ + + org.sonatype.central + central-publishing-maven-plugin + 0.10.0 + true + + sonatype-nexus + + - + org.apache.maven.plugins maven-surefire-report-plugin - 3.0.0-M7 + 3.5.2 ${project.reporting.outputDirectory}/testresults + -Xmx2G -Xms800m -Xss4m org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + 3.11.2 true - 800m none - + 2g + 800m + -J-Xss2m +