Gradle How to build several versions of a jar with different dependencies -


if tried solve similar problem before, please share solution. in gradle file have different subproject. of right able build rest-client core, there situation when rest-client should build db-client subproject. idea need able build rest-client different dependency. let 1 task builds rest-client dependency 1 project , task build rest-client dependency on 2 subproject.

project(':core') { apply plugin: "groovy" repositories { mavencentral() } dependencies { compile 'org.codehaus.groovy:groovy-all:2.4.5' testcompile "org.testng:testng:6.8.21" } }

//rest-client project specific stuff project(':rest-client') { apply plugin: "groovy" repositories { mavencentral() }

dependencies {     compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'     compile project(':core')     compile 'org.codehaus.groovy:groovy-all:2.4.5'     testcompile "org.testng:testng:6.8.21"  } jar {     configurations.runtime } 

}

//db-client project specific stuff project(':db-client') { apply plugin: "groovy" repositories { mavencentral() } dependencies { compile project(':core') compile 'org.codehaus.groovy:groovy-all:2.4.5' compile 'mysql:mysql-connector-java:5.1.37' //compile 'org.elasticsearch:elasticsearch:2.3.1' compile 'org.elasticsearch:elasticsearch-client-groovy:0.10.0' } }

sorry late response, if still need here example.

apply plugin: "groovy"  repositories {   mavencentral() }  configurations {   projectdep   librarydep }  project('core') {   apply plugin: "java"  }  dependencies {   projectdep project(':core')   librarydep 'my.project:project:0.1.0'    compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'   compile 'org.codehaus.groovy:groovy-all:2.4.5'   testcompile "org.testng:testng:6.8.21" }  jar {   configurations.librarydep }  task projectjar(type: jar) {   appendix = 'project'   sourcesets.main.output, configurations.projectdep, configurations.runtime } 

you have 2 jar tasks. jar takes declared dependencies compile,runtime , librarydep , projectjar takes compile,runtime , projectdep.

hope helps.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -