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

Support excluding transitive dependencies in the dependencies DSL #107

Closed
bamboo opened this Issue Jul 28, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@bamboo
Member

bamboo commented Jul 28, 2016

And configuring additional dependency properties in a statically-typed/IDE friendly way:

        dependencies {

            default(group = "org.gradle", name = "foo", version = "1.0") {
                isForce = true
            }

            compile(group = "org.gradle", name = "bar") {
                exclude(module = "foo")
            }

            runtime("org.gradle:baz:1.0-SNAPSHOT") {
                isChanging = true
                isTransitive = false
            }

            testCompile(group = "junit", name = "junit")

            testRuntime(project(path = ":core")) {
                exclude(group = "org.gradle")
            }
        }

The current workaround is to cast the returned dependency to ModuleDependency and call exclude(Map<String, String>) which is not very convenient:

(compile("module-with-transitive-dependencies") as ModuleDependency).apply {
    exclude(mapOf("module" to "excluded-module"))
}

See the relevant section in the user guide.

@bamboo bamboo added this to the 0.3.1 milestone Jul 28, 2016

@bamboo bamboo self-assigned this Aug 2, 2016

@bamboo bamboo closed this in d7c261d Aug 2, 2016

bamboo added a commit that referenced this issue Aug 2, 2016

@jaredsburrows

This comment has been minimized.

Show comment
Hide comment
@jaredsburrows

jaredsburrows Jul 22, 2017

Contributor

@bamboo Has this been updated/fixed?

I still have to use that work around:

  (androidTestCompile(extra["mockitoKotlin"]) as ModuleDependency).apply {
    exclude(mapOf("group" to "net.bytebuddy"))
  }

Instead of what I want to use:

  androidTestCompile(extra["mockitoKotlin"]) { exclude(group = "net.bytebuddy") }
Contributor

jaredsburrows commented Jul 22, 2017

@bamboo Has this been updated/fixed?

I still have to use that work around:

  (androidTestCompile(extra["mockitoKotlin"]) as ModuleDependency).apply {
    exclude(mapOf("group" to "net.bytebuddy"))
  }

Instead of what I want to use:

  androidTestCompile(extra["mockitoKotlin"]) { exclude(group = "net.bytebuddy") }
@bamboo

This comment has been minimized.

Show comment
Hide comment
@bamboo

bamboo Jul 22, 2017

Member

Hi @jaredsburrows, the problem there is that extra["mockitoKotlin"] is not typed as String so the wrong overload is selected (the one which doesn't allow configuring the module dependency. This will work though:

    val mockitoKotlin: String by extra
    compile(mockitoKotlin) {
        exclude(group = "net.bytebuddy")
    }
Member

bamboo commented Jul 22, 2017

Hi @jaredsburrows, the problem there is that extra["mockitoKotlin"] is not typed as String so the wrong overload is selected (the one which doesn't allow configuring the module dependency. This will work though:

    val mockitoKotlin: String by extra
    compile(mockitoKotlin) {
        exclude(group = "net.bytebuddy")
    }
@jaredsburrows

This comment has been minimized.

Show comment
Hide comment
@jaredsburrows

jaredsburrows Jul 22, 2017

Contributor

@bamboo Thanks. Is there anyway to clean this up? To put this on a single line or at least inline val mockitoKotlin: String by extra?

Contributor

jaredsburrows commented Jul 22, 2017

@bamboo Thanks. Is there anyway to clean this up? To put this on a single line or at least inline val mockitoKotlin: String by extra?

@jaredsburrows

This comment has been minimized.

Show comment
Hide comment
@jaredsburrows

jaredsburrows Jul 22, 2017

Contributor

@bamboo For some reason, using String by extra does work either. It does not exclude the transitive dependency that I need excluded:

$ gradlew
WARNING: Conflict with dependency 'org.mockito:mockito-core' in project 'android-gif-example'. Resolved versions for app (2.8.9) and test app (2.8.47) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
WARNING: Conflict with dependency 'org.mockito:mockito-core' in project 'android-gif-example'. Resolved versions for app (2.8.9) and test app (2.8.47) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
WARNING: Conflict with dependency 'org.mockito:mockito-core' in project 'android-gif-example'. Resolved versions for app (2.8.9) and test app (2.8.47) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

Build cache is an incubating feature.

> Task :help

Welcome to Gradle 4.1-rc-1.

To run a build, run gradlew <task> ...

To see a list of available tasks, run gradlew tasks

To see a list of command-line options, run gradlew --help

To see more detail about a task, run gradlew help --task <task>


BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
Contributor

jaredsburrows commented Jul 22, 2017

@bamboo For some reason, using String by extra does work either. It does not exclude the transitive dependency that I need excluded:

$ gradlew
WARNING: Conflict with dependency 'org.mockito:mockito-core' in project 'android-gif-example'. Resolved versions for app (2.8.9) and test app (2.8.47) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
WARNING: Conflict with dependency 'org.mockito:mockito-core' in project 'android-gif-example'. Resolved versions for app (2.8.9) and test app (2.8.47) differ. See http://g.co/androidstudio/app-test-app-conflict for details.
WARNING: Conflict with dependency 'org.mockito:mockito-core' in project 'android-gif-example'. Resolved versions for app (2.8.9) and test app (2.8.47) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

Build cache is an incubating feature.

> Task :help

Welcome to Gradle 4.1-rc-1.

To run a build, run gradlew <task> ...

To see a list of available tasks, run gradlew tasks

To see a list of command-line options, run gradlew --help

To see more detail about a task, run gradlew help --task <task>


BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
@jaredsburrows

This comment has been minimized.

Show comment
Hide comment
@jaredsburrows

jaredsburrows Jul 26, 2017

Contributor

@bamboo Here is something that works and is less code all on 1 line:

 androidTestCompile(extra["mockitoKotlin"] as String) { exclude(group = "net.bytebuddy") }
Contributor

jaredsburrows commented Jul 26, 2017

@bamboo Here is something that works and is less code all on 1 line:

 androidTestCompile(extra["mockitoKotlin"] as String) { exclude(group = "net.bytebuddy") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment