67

Say I want to add guice-assistedinject as a dependency in my project. It specifies the guice artifact as a dependency itself. How do I tell it to use the no_aop version of guice?

I know I can do the following, but can I do it in one step without excluding the guice module?

dependencies {
  compile (group: 'com.google.inject.extensions', name: 'guice-assistedinject', version: '3.0') {
    exclude module: 'guice'
  }
  compile group: 'com.google.inject', name: 'guice', version: '3.0', classifier: 'no_aop'
}
jgrowl
  • 2,117
  • 2
  • 17
  • 23

1 Answers1

104

There is no simpler solution. You can shorten the code by using short dependency notation (e.g. "com.google.inject:guice:3.0:no_aop").

Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
  • Will this work for a .jar artifact only? Will the same work for a .zip artifact as well i.e. guice-3.0-no_app.zip if it's available in Artifactory or similar binary repo. – AKS Jul 09 '14 at 15:29
  • 10
    Found answer: "com.google.inject:guice:3.0:no_app@zip" will work in that case. – AKS Jul 09 '14 at 19:53
  • 5
    If the module has a (correct) POM, `@zip` won't be needed. `@zip` essentially means "get just this zip artifact, no need to look at the POM, no need to get transitive dependencies". – Peter Niederwieser Jul 10 '14 at 05:05
  • 2
    any syntax with classifier without specifying a version. (a scenario where version is taken from bom) – c.sankhala Dec 03 '19 at 07:13