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

Split errors jar into client and server jars #122

Open
pnepywoda opened this issue Sep 6, 2018 · 1 comment
Open

Split errors jar into client and server jars #122

pnepywoda opened this issue Sep 6, 2018 · 1 comment

Comments

@pnepywoda
Copy link
Contributor

https://github.com/palantir/conjure-java-runtime-api/blob/develop/errors/src/main/java/com/palantir/conjure/java/api/errors/RemoteException.java should be in it's own jar - it's only necessary to use when constructing errors from http BODYs. Defining errors, e.g. ErrorType and SerializableError, have nothing to do with http BODY interpretation.

This should help with versioning the client/server parts of error handling independently.

@iamdanfox
Copy link
Contributor

This seems nice from a conceptual perspective, but for the http-remoting -> conjure-java-runtime migration, I don't think it's quite sufficient as the unwanted jars could end up on your compile classpath transitively from a variety of different places.

The current least-worst option I can think of is to add a gradle/ban-remoting-api.gradle file, with the following contents:

// Apply this snippet to all your java projects to ensure you don't have redundant 'catch' blocks
// for the old `com.palantir.remoting.api.errors.RemoteException` class.
// Old remoting-api jars are still allowed at runtime.

configurations.compileClasspath {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'com.palantir.remoting-api' && details.requested.name == 'errors') {
            details.useTarget group: 'com.palantir.conjure.java.api', name: 'errors', version: dependencyRecommendations.getRecommendedVersion('com.palantir.conjure.java.api', 'errors')
            details.because 'Should not compile against RemoteExceptions from both http-remoting-api and conjure-java-runtime-api.'
        }
    }
}

This ensures that when you're migrating from http-remoting-api to conjure-java-runtime, your codebase is guaranteed not to catch the old exception anymore (com.palantir.remoting.api.errors.RemoteException), but the jars will still be present at runtime (which is important for other users)

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

No branches or pull requests

2 participants