unmock-plugin: "Error in opening zip file" when including the plugin twice
I am working on an Android project which uses Git as the version control system. Parts of the code are maintained in a Git submodule named commons in order to being used by other application projects as well. The commons submodule as well as the application module contain unit tests. In the past, I added the unmock-plugin version 0.5.0 in the commons submodule for being used by a subset of the tests. Tests in the commons submodule pass.
.
├── commons
│ ├── build.gradle // has the unmock-plugin
│ └── src
├── app
│ ├── build.gradle
│ ├── src
// commons submodule build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "de.mobilej.unmock:UnMockPlugin:0.5.0"
}
}
apply plugin: 'com.android.library'
apply plugin: 'de.mobilej.unmock'
android { /* ... */ }
unMock {
keep "android.database.DatabaseUtils"
keepStartingWith "android.text."
keepStartingWith "com.android.internal.util."
keepStartingWith "org.ccil.cowan.tagsoup."
}
Now, I want to reference the unmock-plugin in the application module as well since a subset of test there also require mocking parts of the Android framework.
.
├── commons
│ ├── build.gradle // has the unmock-plugin
│ └── src
├── app
│ ├── build.gradle // has the unmock-plugin
│ ├── src
// application module build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "de.mobilej.unmock:UnMockPlugin:0.5.0"
}
}
apply plugin: 'com.android.application'
apply plugin: 'de.mobilej.unmock'
android { /* ... */ }
unMock {
keep "android.net.Uri"
}
Shell / Jenkins
Running the tests of the application module fails with the following error message:
Execution failed for task ‘:commons:unMock’. error in opening zip file
Please note, that tests are executed by invoking Gradle on the shell. I noticed this when running the tests on Jenkins.
Android Studio
In contrast, when I manually run the tests of the application module they pass. If I run the tests of commons submodule they fail.
- app ✅
- commons ❌
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 19 (10 by maintainers)
At first it sounds similar to https://github.com/bjoernQ/unmock-plugin/issues/16 but it doesn’t make sense given the observations you made using Android Studio.
I successfully use similar setups but in my case the library projects and the app projects share the same root build.gradle defining the buildscript clause.
Maybe it’s possible to share the output of gradlew <testTask> --stacktrace ?
I will try to setup some test code with the same setup ( each module defining the buildscript clause individually ) to see if this is the cause of the problem.
Maybe you can also try to have a root build.gradle defining the buildscript clause? (I understand that it won’t be feasibly to have this setup with an independent Git submodule but maybe you can try it locally)