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

Issue with unit tests in multi-module project #84

Open
erawhctim opened this issue Aug 21, 2018 · 4 comments
Open

Issue with unit tests in multi-module project #84

erawhctim opened this issue Aug 21, 2018 · 4 comments

Comments

@erawhctim
Copy link

I was seeing the unit testing issues described in #14, and successfully applied the solutions outlined - however when I try to declare the threetenabp dependencies in another module via gradle's api and testApi commands, I'm still seeing the ZoneRulesException: No time-zone data files registered error.

It's pretty clear that the change to api is the problem, but I'm just curious if someone knows why and/or how I can possibly change my gradle setup to get it to work? It's ideal to declare dependencies like this that are re-used throughout multiple modules in the base "core" module and let them transitively apply, instead of having to redeclare in every module's gradle file. Any help is appreciated :)

I have a core module and a main app module that depends on it, relevant info from gradle files below:

Declaring in app build.gradle (working):

implementation project(':core')

implementation 'com.jakewharton.threetenabp:threetenabp:1.0.4'
testImplementation 'org.threeten:threetenbp:1.3.2'

Declaring in core build.gradle (not working):

api 'com.jakewharton.threetenabp:threetenabp:1.0.4'
testApi 'org.threeten:threetenbp:1.3.2'
@HappyDr0id
Copy link

+1 I reproduce this exact issue with the multi-modules project I'm working on and the usage of testApi. If I move my test dependency to the specific module in which I need it instead of my core shared module with testImplementation, then my unit test works.

@dbarwacz
Copy link

I'm not very experienced in how gradle works in terms of icluding build dependencies, but from my understanding gradle won't include dependencies of your test dependencies in the resulting artifact. What it means is that test dependencies are not transitive, so you must include testImplementation in each module where you need it.

@matthandlersux
Copy link

since this has been open for a while, for anyone else who lands here, in a similar setup i ran into the same issue. adding the second line suggested above (testApi...) worked for me:

// in another module's build.gradle.kts
// ...
api("com.jakewharton.threetenabp:threetenabp:_")
testApi("org.threeten:threetenbp:_")

note that i have in versions.properties:

...
version.com.jakewharton.threetenabp..threetenabp=1.2.4
version.org.threeten..threetenbp=1.4.5
...

@BaloghTamas
Copy link
Contributor

since this has been open for a while, for anyone else who lands here, in a similar setup i ran into the same issue. adding the second line suggested above (testApi...) worked for me:

// in another module's build.gradle.kts
// ...
api("com.jakewharton.threetenabp:threetenabp:_")
testApi("org.threeten:threetenbp:_")

note that i have in versions.properties:

...
version.com.jakewharton.threetenabp..threetenabp=1.2.4
version.org.threeten..threetenbp=1.4.5
...

But don't forget that these versions use different TZDB versions, as ThreeTenBP 1.4.5 uses 2020b, while ThreeThenABP 1.2.4 uses 2020a.

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

5 participants