title: In gradle: How to build two fat jars, identical except for different dependency?
body: <p>I have a gradle project that successfully builds a fat jar (i.e. containing its own dependencies).  What I need, however, is for it to build two jars:</p>
  
  <ul>
  <li>one with this dependency: compile('postgresql:postgresql:8.4-702.jdbc4')</li>
  <li>the other with this dependency: compile('org.postgresql:postgresql:42.1.1.jre7')</li>
  </ul>
  
  <p>Apart from that, they should be identical.</p>
  
  <p>Can I do this in gradle?</p>
  
  <p>I have the requirement that I can only call gradle once (i.e. can't call gradle once for each jar).</p>
  
  <p>The relevant parts of my gradle file look like this:</p>
  
  <pre><code>buildscript {
      ext {
          springBootVersion = '1.3.1.RELEASE'
      }
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
          classpath("io.spring.gradle:dependency-management-plugin:0.5.4.RELEASE")
      }
  }
  
  apply plugin: 'java'
  apply plugin: 'eclipse'
  apply plugin: 'idea'
  apply plugin: 'spring-boot'
  apply plugin: "io.spring.dependency-management"
  
  jar {
      baseName = 'demo'
      version = '0.0.1-SNAPSHOT'
  }
  sourceCompatibility = 1.8
  targetCompatibility = 1.8
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
  
      ...
  
      compile('org.postgresql:postgresql:42.1.1.jre7') // or compile('postgresql:postgresql:8.4-702.jdbc4')
  
      ...
  }
  
  eclipse {
      classpath {
           containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
           containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8'
      }
  }
  
  ...
  
  task wrapper(type: Wrapper) {
      gradleVersion = '2.9'
  }
  </code></pre>