How to add project as dependency and point to it's specific classifier?


(Maksim Kostromin) #1

Hello, all

I have ejb-services module which is basically regular java project with additional ejb-client jar:

task ejbClientJar(type: Jar) {
  classifier = "client"
  from sourceSets.main.output
  include "**/api/*.*"
  include "**/api/**/*.*"
}

jar.dependsOn(ejbClientJar)

Using maven, on client side we usually adding API dependency like so:

  <dependencies>
    <dependency>
      <groupId>daggerok</groupId>
      <artifactId>ejb-services</artifactId>
      <version>0.0.1</version>
      <type>ejb-client</type>
      <scope>provided</scope>
    </dependency>
  </dependencies>

To make things working I’m doing next workaround in my client apps:

dependencies {
  compileOnly(project(":ejb-services"))
}

but I would like to know if I can do similar to maven in gradle? something like this maybe?

dependencies {
  api(project(name: ":ejb-services", configuration: "client"))
}

I know about configuration, but not in details…
Only requirement here is dependency must be a project, not artifact from repo or some artifactory
Can anybody help me with a solution?
Thanks in advise

PS: current solution


Regards,
Maksim