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

JAVA-2982: Follow-up to recent PR making ESRI an optional dependency #1580

Merged
merged 6 commits into from
Jan 25, 2022

Conversation

absurdfarce
Copy link
Contributor

@absurdfarce absurdfarce commented Jan 7, 2022

Follow up to recent PR (#1575) making ESRI an optional dependency.

I've empirically validated that as of this change the following statements are true:

  • The core JAR contains no classes from the ESRI jar (expected... this was true before and shouldn't have changed in this effort)
  • The shaded JAR contains no classes from the ESRI jar (new)
    • After 953c72f no classes from ESRI's transitive dependencies are included in the shaded JAR
  • Both the core and shaded JAR now declare an optional dependency on ESRI (new)
    • ESRI's transitive dependencies are also optional as well
  • All unit and integration tests still pass

<groupId>com.esri.geometry</groupId>
<artifactId>esri-geometry-api</artifactId>
<version>1.2.1</version>
</additionalDependency>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javadoc generation was throwing warnings about missing classes without this declaration in place

@@ -479,8 +479,9 @@ don't use any of the above features, you can safely exclude the dependency:
Our [geospatial types](../dse/geotypes/) implementation is based on the [Esri Geometry
API](https://github.com/Esri/geometry-api-java).

Esri is declared as a required dependency, but the driver can operate normally without it. If you
don't use geospatial types anywhere in your application, you can exclude the dependency:
For driver versions >= 4.4.0 and < 4.14.0 Esri is declared as a required dependency,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TinkerPop example explicitly referred to an inclusive range, but in this case I wanted the range to be inclusive on the low end but exclusive on the high end (in order to explicitly convey the idea that all drivers before the named version used a different behaviour). Since this changed the semantics slightly I thought that perhaps identifying versions via the >= and < syntax might be more explicit.

I'm open to other ideas of presenting this information if this isn't clear.

```

See the [integration](../manual/core/integration/#esri) section in the manual for more details.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very much based on the example used when TinkerPop was made optional.

I've explicitly added this in the 4.14.0 section under the assumption that changing a dependency from required to optional breaks backwards compat and thus requires at least a minor release.

@absurdfarce absurdfarce requested a review from adutra January 7, 2022 22:02
@@ -146,7 +146,6 @@
-->
<include>com.datastax.oss:java-driver-core</include>
<include>io.netty:*</include>
<include>com.esri.geometry:*</include>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit hesitant about this. Making a dependency optional and shading it are different concerns.

Initially, the decision to shade a dependency was taken by looking at the likelihood of a version conflict for a given dependency. For Esri, we deemed it high because the driver requires a very old Esri version.

I think we should keep shading Esri even if it is optional, wdyt? This means that in the shaded jar Esri would be present and shaded, just like it is now. I can't see a situation where this could be a problem for the end user.

Copy link
Contributor Author

@absurdfarce absurdfarce Jan 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point here... I'm just not sure I agree.

To be clear, the case you're describing is fairly precise. It would have to be something like the following:

  • The user's app uses ESRI 2.x for some other functionality in their app
  • The user's app also uses the (shaded) Java driver
  • The user runs this app against DSE
  • The user wants to leverage the geometric type support in DSE

This user will (possibly, even likely) experience a class conflict. But the cost for supporting this (quite limited case) is that every user of the shaded JAR has a larger JAR on their classpath. Initially it seemed like optimizing for the broad case made sense rather than doing so for the extremely precise case but I'm certainly open to argument.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every user of the shaded JAR has a larger JAR on their classpath

Well the shaded jar already has all of Netty in it, so adding Esri on top of it won't really make a noticeable size difference :-)

But OK, I don't mind if we stop shading Esri.

manual/core/integration/README.md Show resolved Hide resolved
manual/core/integration/README.md Show resolved Hide resolved
upgrade_guide/README.md Show resolved Hide resolved
@adutra
Copy link
Contributor

adutra commented Jan 24, 2022

@absurdfarce we are almost good to merge this but I wanted first your input on this:

spring-projects/spring-boot#29387

What should we do with org.json:json-api? I guess it should be made optional, or even removed completely from our pom (if we can keep the OSGi tests passing).

@absurdfarce
Copy link
Contributor Author

@adutra I looked at the Spring Boot issue briefly but I haven't really set out to address it specifically yet. We're still getting the transitive dependencies from the Esri lib (the JSON JAR and the older version of Jackson) included in the shaded JAR so I wanted to get that sorted out before considering the Spring issue (since they looked to be related).

More on that shortly (I hope).

@absurdfarce
Copy link
Contributor Author

Okay, I believe all the relevant issues are sorted out now. Would you mind taking another look @adutra to confirm that we're good?

@absurdfarce absurdfarce changed the title Follow-up to recent PR making ESRI an optional dependency JAVA-2982: Follow-up to recent PR making ESRI an optional dependency Jan 24, 2022
@absurdfarce absurdfarce requested a review from adutra January 24, 2022 21:15
Copy link
Contributor

@adutra adutra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I manually verified that the OSGi tests pass against DSE with geotypes, so we are good wrt to the org.json dependency there. I also manually confirmed that org.json is not present neither in driver-core nor driver-core-shaded, so we are good there too.

However I just spotted two bnd directives in driver-core-shaded that should be removed since they reference packages that are not shaded anymore. Please have a look.

@@ -340,7 +312,7 @@
<!--
1) Don't import packages shaded in the driver bundle. Note that shaded-guava lives
in its own bundle, so we must explicitly *not* mention it here.
-->!com.datastax.oss.driver.shaded.netty.*, !com.datastax.oss.driver.shaded.esri.*, !com.datastax.oss.driver.shaded.json.*, !com.datastax.oss.driver.shaded.codehaus.jackson.*, !com.datastax.oss.driver.shaded.fasterxml.jackson.*,
-->!com.datastax.oss.driver.shaded.netty.*, !com.datastax.oss.driver.shaded.json.*, !com.datastax.oss.driver.shaded.codehaus.jackson.*, !com.datastax.oss.driver.shaded.fasterxml.jackson.*,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed: we are still mentioning here two shaded packages that do not exist anymore:

  • com.datastax.oss.driver.shaded.json
  • com.datastax.oss.driver.shaded.codehaus.jackson

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch, you're absolutely right! I'll clean this up (and the one below) shortly.

@@ -366,7 +338,7 @@
1) The driver's packages (API and internal);
2) All shaded packages, except Guava which resides in a separate bundle.
-->
<Export-Package>com.datastax.oss.driver.api.core.*, com.datastax.oss.driver.internal.core.*, com.datastax.dse.driver.api.core.*, com.datastax.dse.driver.internal.core.*, com.datastax.oss.driver.shaded.netty.*, com.datastax.oss.driver.shaded.esri.*, com.datastax.oss.driver.shaded.json.*, com.datastax.oss.driver.shaded.codehaus.jackson.*, com.datastax.oss.driver.shaded.fasterxml.jackson.*,</Export-Package>
<Export-Package>com.datastax.oss.driver.api.core.*, com.datastax.oss.driver.internal.core.*, com.datastax.dse.driver.api.core.*, com.datastax.dse.driver.internal.core.*, com.datastax.oss.driver.shaded.netty.*, com.datastax.oss.driver.shaded.json.*, com.datastax.oss.driver.shaded.codehaus.jackson.*, com.datastax.oss.driver.shaded.fasterxml.jackson.*,</Export-Package>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Contributor

@adutra adutra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we are done \o/ :shipit:

@absurdfarce absurdfarce merged commit 415f789 into 4.x Jan 25, 2022
@absurdfarce absurdfarce deleted the optional_esri_dependency_followup branch January 25, 2022 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.

2 participants