Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify a classifier in a gradle dependency's dependency?

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' } 
like image 297
jgrowl Avatar asked Nov 02 '12 02:11

jgrowl


People also ask

How do you define Gradle dependencies?

Gradle build script defines a process to build projects; each project contains some dependencies and some publications. Dependencies refer to the things that supports in building your project, such as required JAR file from other projects and external JARs like JDBC JAR or Eh-cache JAR in the class path.

How do you write a dependency in Gradle?

To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build.gradle file.

What is classpath in Gradle?

A configuration is simply a named set of dependencies. The compile configuration is created by the Java plugin. The classpath configuration is commonly seen in the buildSrc {} block where one needs to declare dependencies for the build. gradle, itself (for plugins, perhaps).


1 Answers

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").

like image 72
Peter Niederwieser Avatar answered Sep 30 '22 17:09

Peter Niederwieser