build.gradle - How to give dependecies in multiproject in Gradle and what is the structure? -
i have multi project built using gradle has java project , it'll dependancy web project. when build eclipse have given depencies of javaproj , webproj webprojectear , works(after deployed).
.ear file needs created using single build run whcih has following content.
- lib javaproj.jar - meta-inf - webproj.war
my project structure follows
- javaproj build.gradle - webproj build.gradle - webprojear build.gradle - settings.gradle
i'm trying run webprojear/build.gradle file , given dependency follows in it.
project(':webprojear') { dependencies { compile project(':javaproj') compile project(':webproj') } }
it failed error "could not resolve dependencies configuration 'webprojear:testruntime' .when run build files separatly able create jar , war files.
please can me how dependencies should mentioned in build files. and, madatory locations have build.gradle file.
=== more information added original question here ===
my build files below. have made changes igor popov had mentioned.
// javaproj/build.gradle apply plugin: 'java' repositories { flatdir { dirs "../local-repo" } } sourcesets { main { java.srcdir "$projectdir/src" resources.srcdir "$projectdir/xml" } } jar { ('classes/com/nyl/xsl') { 'com/nyl/xsl' } } dependencies { compile group: 'slf4j-api' , name: 'slf4j-api' , version: '1.5.6' compile group: 'slf4j-jdk14' , name: 'slf4j-jdk14' , version: '1.5.6' compile group: 'com.ibm.xml.thinclient_1.0.0' , name: 'com.ibm.xml.thinclient_1.0.0' , version: '1.0.0' compile group: 'junit', name: 'junit', version: '4.11' compile group: 'saxon9' , name: 'saxon9' compile group: 'saxon9-dom' , name: 'saxon9-dom' compile group: 'xmlunit' , name: 'xmlunit' , version: '1.4' } ============================================== // webproj/build.gradle apply plugin: 'war' repositories { flatdir { dirs "../local-repo" } } webappdirname = 'webcontent' dependencies { providedcompile group: 'com.ibm.xml' , name: 'com.ibm.xml' providedcompile group: 'com.ibm.ws.prereq.xdi2' , name: 'com.ibm.ws.prereq.xdi2' providedcompile group: 'com.ibm.ws.xml.admin.metadata' , name: 'com.ibm.ws.xml.admin.metadata' providedcompile group: 'guava' , name: 'guava' , version: '11.0.2' providedcompile group: 'j2ee' , name: 'j2ee' providedcompile group: 'slf4j-api' , name: 'slf4j-api' , version: '1.5.6' providedcompile group: 'slf4j-log4j12' , name: 'slf4j-log4j12' , version: '1.5.6' } ==================================================== // webprojear/build.gradle apply plugin: 'java' apply plugin: 'ear' repositories { flatdir { dirs "../local-repo" } } dependencies { compile project(':javaproj') compile project(':webproj') } ear { appdirname 'src/main/app' libdirname 'app-inf/lib' ('../javaproj/build/libs') { 'lib' } ('../webproj/build/libs') { '/' } }
i know should contain in roojproj/build.gradle file. know needs changed in above files. thanks
the overall structure should like:
rootproj javaproj build.gradle webproj build.gradle webprojear build.gradle settings.gradle build.gradle
the settings.gradle
file should contain:
include 'javaproj', 'webproj', 'webprojear'
for webprojear/build.gradle
can remove project(':webprojear')
. should like:
dependencies { compile project(':javaproj') compile project(':webproj') }
to fix error get, should post dependencies webprojear
(if have others didn't include).
Comments
Post a Comment