Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shade antlr dependency for partiql-parser and partiql-lang #1439

Merged
merged 11 commits into from
May 14, 2024
Merged

Conversation

alancai98
Copy link
Member

@alancai98 alancai98 commented Apr 19, 2024

Relevant Issues

Description

  • Shades the antlr dependency for partiql-parser and partiql-lang
  • Upgrades Gradle to 8.7 and a few other dependencies
  • Testing
    • publishing to Maven local puts the antlr dependencies for partiql-parser and partiql-lang behind org.partiql.thirdparty
    • published .pom does not include antlr dependency
    • published partiql-parser and partiql-lang generated code uses antlr from org.partiql.thirdparty dependency:
// PartiQLParser.class
package org.partiql.parser.antlr;

import java.util.ArrayList;
import java.util.List;
import org.partiql.thirdparty.antlr.v4.runtime.FailedPredicateException;
import org.partiql.thirdparty.antlr.v4.runtime.NoViableAltException;
import org.partiql.thirdparty.antlr.v4.runtime.Parser;
import org.partiql.thirdparty.antlr.v4.runtime.ParserRuleContext;
import org.partiql.thirdparty.antlr.v4.runtime.RecognitionException;
import org.partiql.thirdparty.antlr.v4.runtime.RuleContext;
import org.partiql.thirdparty.antlr.v4.runtime.RuntimeMetaData;
import org.partiql.thirdparty.antlr.v4.runtime.Token;
import org.partiql.thirdparty.antlr.v4.runtime.TokenStream;
import org.partiql.thirdparty.antlr.v4.runtime.Vocabulary;
import org.partiql.thirdparty.antlr.v4.runtime.VocabularyImpl;
import org.partiql.thirdparty.antlr.v4.runtime.atn.ATN;
import org.partiql.thirdparty.antlr.v4.runtime.atn.ATNDeserializer;
import org.partiql.thirdparty.antlr.v4.runtime.atn.ParserATNSimulator;
import org.partiql.thirdparty.antlr.v4.runtime.atn.PredictionContextCache;
import org.partiql.thirdparty.antlr.v4.runtime.dfa.DFA;
import org.partiql.thirdparty.antlr.v4.runtime.tree.ParseTreeListener;
import org.partiql.thirdparty.antlr.v4.runtime.tree.ParseTreeVisitor;
import org.partiql.thirdparty.antlr.v4.runtime.tree.TerminalNode;

public class PartiQLParser extends Parser {
...

Other Information

  • Updated Unreleased Section in CHANGELOG: [NO]

    • No public api changes
  • Any backward-incompatible changes? [NO]

  • Any new external dependencies? [YES]

    • com.github.johnrengelman:shadow:8.1.1
    • gradle-wrapper version bump 7.6.2 -> 8.7
    • detekt version bump 1.20.0-RC1 -> 1.20.0-RC2
    • jacoco version bump 0.8.8 -> 0.8.11
  • Do your changes comply with the Contributing Guidelines
    and Code Style Guidelines? [YES]

License Information

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@alancai98 alancai98 self-assigned this Apr 19, 2024
Copy link

github-actions bot commented Apr 19, 2024

Conformance comparison report

Base (4851cac) 77bc636 +/-
% Passing 92.54% 92.54% 0.00%
✅ Passing 5384 5384 0
❌ Failing 434 434 0
🔶 Ignored 0 0 0
Total Tests 5818 5818 0

Number passing in both: 5384

Number failing in both: 434

Number passing in Base (4851cac) but now fail: 0

Number failing in Base (4851cac) but now pass: 0

@alancai98 alancai98 marked this pull request as draft April 20, 2024 01:22
@alancai98
Copy link
Member Author

Draft PR in its current state appears to do the proper shading (putting the antlr dependencies behind a different directory). Still looking at the issues related to publishing. It looks like I'll need a bugfix GradleUp/shadow#798 that's only in shadow 8.0+, which only works w/ Gradle 8.0+.

Will try updating the Gradle version to 8.0+ #1440 and upgrade the shadow version to 8.0 to see if that fixes the publishing issue.

@alancai98 alancai98 marked this pull request as ready for review April 23, 2024 01:14
@alancai98 alancai98 changed the title [WIP] Shade antlr dependency for partiql-parser and partiql-lang Shade antlr dependency for partiql-parser and partiql-lang Apr 23, 2024
@alancai98 alancai98 requested a review from RCHowell April 23, 2024 01:31
partiql-lang/build.gradle.kts Outdated Show resolved Hide resolved
@alancai98
Copy link
Member Author

Confirmed that all of the subprojects published to Maven have the same POM dependencies with all of the ANTLR + ANTLR-runtime dependencies removed.

@alancai98 alancai98 requested a review from RCHowell April 24, 2024 19:09
@alancai98 alancai98 requested a review from johnedquinn May 9, 2024 18:13
@johnedquinn
Copy link
Member

I see that you've published locally (publishToMavenLocal) to look at the POM. Have you created a new project to test that you can use the partiql-parser package? I'm having trouble in my own build. I had previously locally published 0.13.3-SNAPSHOT and I've just now locally published 0.14.6-SNAPSHOT (including these changes). For some reason, I can't resolve 0.14.6-SNAPSHOT when I specify it in build.gradle.kts, but when I specify the 0.13.3-SNAPSHOT, it works.

For context, I was going to run some tests to make sure I can use org.partiql.parser.PartiQLParser. I was also going to check that org.antlr.* would not be able to be used. Then, I was going to add another dependency on a different version of the ANTLR runtime to see if the resolution would be okay when actually using some of the runtime classes (org.antlr.v4.runtime.Token for instance).

Here's my build script:

plugins {
    id("java")
}

group = "org.partiql.shade-test"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    // For testing
    testImplementation("org.partiql:partiql-parser:0.13.3-SNAPSHOT")
    // testImplementation("org.partiql:partiql-parser:0.14.6-SNAPSHOT")

    testImplementation(platform("org.junit:junit-bom:5.9.1"))
    testImplementation("org.junit.jupiter:junit-jupiter")
}

tasks.test {
    useJUnitPlatform()
}

@alancai98
Copy link
Member Author

I see that you've published locally (publishToMavenLocal) to look at the POM. Have you created a new project to test that you can use the partiql-parser package? I'm having trouble in my own build. I had previously locally published 0.13.3-SNAPSHOT and I've just now locally published 0.14.6-SNAPSHOT (including these changes). For some reason, I can't resolve 0.14.6-SNAPSHOT when I specify it in build.gradle.kts, but when I specify the 0.13.3-SNAPSHOT, it works.

For context, I was going to run some tests to make sure I can use org.partiql.parser.PartiQLParser. I was also going to check that org.antlr.* would not be able to be used. Then, I was going to add another dependency on a different version of the ANTLR runtime to see if the resolution would be okay when actually using some of the runtime classes (org.antlr.v4.runtime.Token for instance).
...

Thanks for testing the local publishing on your end. My build.gradle.kts was pretty similar to yours except for specifying the Kotlin plugin.

I was able to reproduce some build errors you're probably experiencing when pulling in the local published version of this branch (0.14.6-SNAPSHOT) and using an empty Maven local cache. I had not seen those errors in previous testing since I had locally published 0.14.6-SNAPSHOT before the latest commit of this PR. My guess is that some combination of the previous local published Maven artifacts and the latest PR's local publishing allowed my local build to succeed.

I'll try fixing the publishing task and performing further testing.

@alancai98
Copy link
Member Author

Did some more local testing on my end after the most recent commits.

Process I followed:

  1. delete local ~/.m2 directory for partiql
  2. ensure DOKKA environment is set to true
  3. published the shade-antlr branch to maven local (./gradlew publishToMavenLocal) as 0.14.6-SNAPSHOT
  4. created a local project with a gradle build similar to Shade antlr dependency for partiql-parser and partiql-lang #1439 (comment)

Testing done:

  1. Confirmed I could pull in org.partiql:partiql-parser:0.14.6-SNAPSHOT from maven local and run code from parser package
  2. Confirmed I could pull in org.partiql:partiql-lang-kotlin:0.14.6-SNAPSHOT from maven local and run code from lang package
  3. With just the partiql-parser:0.14.6-SNAPSHOT dependency, confirmed that ANTLRv4 dependencies are under the org.partiql.thirdparty namespace. Confirmed that I could not import APIs from org.antlr.v4 directly.
  4. With just the partiql-parser:0.14.6-SNAPSHOT dependency and other ANTLR runtime versions (4.5.1, 4.13.1), confirmed there were no version conflicts when building and running parser code.
  5. Took a look at the POM file diffs with v0.14.5. Confirmed that for partiql-parser and partiql-lang that the ANTLR dependencies are removed; other dependencies are the same.

partiql-lang/build.gradle.kts Outdated Show resolved Hide resolved
partiql-planner/build.gradle.kts Show resolved Hide resolved
@alancai98 alancai98 dismissed RCHowell’s stale review May 14, 2024 22:24

prior suggestions addressed

@alancai98 alancai98 merged commit 5d49b21 into main May 14, 2024
10 checks passed
@alancai98 alancai98 deleted the shade-antlr branch May 14, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade gradle version to 8.0+ Shadow the ANTLRv4 runtime dependency to avoid conflicts.
3 participants