# Separate EARs pull in same dependencies

**URL:** <https://discuss.gradle.org/t/separate-ears-pull-in-same-dependencies/23584>\
**Category:** Help/Discuss\
**Created:** [August 3, 2017, 4:04pm UTC](https://discuss.gradle.org/t/separate-ears-pull-in-same-dependencies/23584 "2017-08-03T16:04:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![egarcol](https://avatars.discourse-cdn.com/v4/letter/e/e0b2c6/32.png) [@egarcol](https://discuss.gradle.org/u/egarcol)\
**Post date:** [August 3, 2017, 4:04pm UTC](https://discuss.gradle.org/t/separate-ears-pull-in-same-dependencies/23584/1 "2017-08-03T16:04:12Z")

</div>

Hi,

My gradle build consists of a build.gradle file and 2 separate gradle files (ear1.gradle and ear2.gradle).

The 2 EAR gradle files have a task each to build an EAR and separate dependencies.

The EARs are built separately but they both contain each others dependencies.

Any tips how I can build 2 EARs but with a set of separate dependecies ?

Thanks & Rgds

File 1:

apply plugin: ‘ear’

dependencies {  
deploy project(’:some-ejb’)  
deploy project(’:some\_other-ejb’)  
deploy project(path: ‘:some.war’, configuration: ‘archives’)  
}

task myEar(type: Ear) {  
classifier = 'xyz’  
manifest { attributes ‘Dependencies’: ‘com.some.api export’ }  
}

File 2:

apply plugin: ‘ear’

dependencies {  
deploy project(’:xyz-ejb’)  
deploy project(’:some\_other\_xyz-ejb’)  
deploy project(path: ‘:some\_xyz.war’, configuration: ‘archives’)  
}

task myEar(type: Ear) {  
classifier = 'xyz2’  
manifest { attributes ‘Dependencies’: ‘com.some.api export’ }  
}

build.gradle file:

apply from: ear1.gradle  
apply from: ear2.gradle

dependencies {  
earlib 'com.google.guava:guava’  
earlib 'org.jboss  
}

// some other tasks here
