title: Import swagger-codegen project into existing Android project
body: <p>Im trying to integrate a "module"-project generated by swagger-codegen, into my Android project.</p>
  
  <p>Haven't worked that much with gradle before and the swagger-codegen creates a quite messy build.gradle from my point of view.</p>
  
  <p>I have a hard time finding documentation on how to do this. And I feel a bit lost.</p>
  
  <p>I used this method described in the <a href="https://github.com/swagger-api/swagger-codegen/wiki/FAQ#android" rel="nofollow noreferrer">FAQ</a></p>
  
  <pre><code>mvn clean package
  java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
   -i http://petstore.swagger.io/v2/swagger.json \
   -l java --library=okhttp-gson \
   -o /var/tmp/java/okhttp-gson/ 
  </code></pre>
  
  <p>So fare I tried to copy the source from the project that was generated by swagger-codegen and merge the two gradle build files. I removed the Junit tests because I couldn't get the Junit dependency working (<a href="https://stackoverflow.com/questions/38638467/implementing-swagger-codegen-project-error23-17-failed-to-resolve-junitj/38648612?noredirect=1#comment64732498_38648612">Implementing Swagger-codegen project - Error:(23, 17) Failed to resolve: junit:junit:4.12</a>). But then I got stuck with some conflict between the plugins?</p>
  
  <pre><code>The 'java' plugin has been applied, but it is not compatible with the Android plugins.
  </code></pre>
  
  <p>Here's the build.gradle:</p>
  
  <pre><code>import static jdk.nashorn.internal.runtime.regexp.joni.ApplyCaseFold.apply
  
  apply plugin: 'idea'
  apply plugin: 'eclipse'
  
  group = 'io.swagger'
  version = '1.0.0'
  
  buildscript {
     repositories {
         jcenter()
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:2.1.2'
         // classpath 'com.android.tools.build:gradle:1.5.+'
         classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
     }
  }
  
  repositories {
     jcenter()
     maven { url 'http://repo1.maven.org/maven2' }
  }
  
  
  if(hasProperty('target') &amp;&amp; target == 'android') {
  
     apply plugin: 'com.android.library'
     apply plugin: 'com.github.dcendents.android-maven'
  
     android {
         compileSdkVersion 23
         buildToolsVersion '23.0.2'
         defaultConfig {
              minSdkVersion 14
              targetSdkVersion 23
         }
          compileOptions {
             sourceCompatibility JavaVersion.VERSION_1_7
             targetCompatibility JavaVersion.VERSION_1_7
         }
  
         // Rename the aar correctly
         libraryVariants.all { variant -&gt;
             variant.outputs.each { output -&gt;
                 def outputFile = output.outputFile
                 if (outputFile != null &amp;&amp;    outputFile.name.endsWith('.aar')) {
                      def fileName = "\u0024{project.name}-  \u0024{variant.baseName}-\u0024{version}.aar"
                  output.outputFile = new File(outputFile.parent, fileName)
              }
          }
      }
  
      dependencies {
          provided 'javax.annotation:jsr250-api:1.0'
      }
  }
  
  afterEvaluate {
      android.libraryVariants.all { variant -&gt;
          def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
          task.description = "Create jar artifact for ${variant.name}"
          task.dependsOn variant.javaCompile
          task.from variant.javaCompile.destinationDir
          task.destinationDir = project.file("${project.buildDir}/outputs/jar")
          task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
          artifacts.add('archives', task);
      }
  }
  
  task sourcesJar(type: Jar) {
      from android.sourceSets.main.java.srcDirs
      classifier = 'sources'
  }
  
  artifacts {
      archives sourcesJar
  }
  
  } else {
  
  apply plugin: 'java'
  apply plugin: 'maven'
  
  sourceCompatibility = JavaVersion.VERSION_1_7
  targetCompatibility = JavaVersion.VERSION_1_7
  
  install {
      repositories.mavenInstaller {
          pom.artifactId = 'XxxxXxxx'
      }
  }
  
      task execute(type:JavaExec) {
         main = System.getProperty('mainClass')
         classpath = sourceSets.main.runtimeClasspath
      }
  }
  
  dependencies {
      compile 'io.swagger:swagger-annotations:1.5.8'
      compile 'com.squareup.okhttp:okhttp:2.7.5'
      compile 'com.squareup.okhttp:logging-interceptor:2.7.5'
      compile 'com.google.code.gson:gson:2.6.2'
      compile 'joda-time:joda-time:2.9.3'
     // testCompile 'junit:junit:4.12'
  }
  </code></pre>
  
  <p>Am I doing something complete wrong here? What is the correct way to implement swagger-codegen code into my project?</p>