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
Getting pure-java modules with ThreeTenBP to play nice with ThreeTenABP? #47
Comments
In the Android app you can do something like: configurations.all {
resolutionStrategy {
dependencySubstitution {
substitute module('org.threeten:threetenbp') with module('com.jakewharton.threetenabp:threetenabp')
}
}
} Which should work, but I've never tested it. |
More details and options are here: https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html |
Thanks for the hint. I applied that snippet to app's build script and it's currently giving:
Could it be applying the substitution to threetenabp's internal dependency on org.threeten:threetenbp and causing recursion..? I'm creating a small sample project to continue investigating |
Ah, yes. It likely is because it isn't considering the classifier of the dependency. I'm not sure if there's a means of doing that or if that's a Gradle bug. |
I got it working like this:
I think, the substitution that @JakeWharton mentions in this comment should only be required when you use an external library which uses |
@tmtron thanks, your solution worked for me. This had a nice cascading benefit in that we could then convert 3 modules to pure-java modules, which brought our build time down from 4:19 to 3:41 (!) |
@tmtron Correct me if I'm wrong, but the reason your solution works is the Anyways, in my case, I needed the time-zone version of ThreeTenBackport in my Java-only module and I also couldn't make it a In my Java-only
In my Android
(sidenote: I'm using the new Just another solution in case it helps anyone! |
That's right. In your case you use I think which of the 2 ways you use depends on your project and is to some degree a matter of taste.
Well, the tz-info is not needed for compilation and |
Disclaimer: this is probably a gradle config issue rather than an issue with this library per-se. But hopefully this issue is relevant to android developers wanting to use JSR 310 in multi-module projects.
I have a pure java (non-android) gradle module called
common
with some utility functions for building ZonedDateTime objects. It depends on the standard jvm backport library (org.threeten:threetenbp
).What I'd like is to have the android app module depend on the
common
module to make use of these platform-independent utility functions, but depend on threetenABP instead for performance. Should this be possible? Attempting to do it naiively gives this build error:From what I understand, the same public classes and interfaces are in use in both modules (e.g. ZonedDateTime). It seems like something like gradle's
provided
keyword to have compilation succeed and yet use ABP at runtime would work, but I haven't had much success with it.Any thoughts?
The text was updated successfully, but these errors were encountered: