title: Android Gradle Build System: Create Jar Not Library
body: <p>Currently I am working in eclipse. I want to migrate to Android Studio however I need to figure this out first: How do I create a jar for my project using the new android build system?</p>
  
  <p>My Project is setup as a library however there are only java files in the project. I don't need or want to export this as a library. I want to export the files as a .jar so it can easily be dropped into another project.</p>
  
  <p><strong>Update</strong>
  Here is my gradle file. <em>I cannot add the line <code>apply plugin java</code> because it is incompatible with the android plugin. The jar task is already included in the android plugin.</em></p>
  
  <pre><code>buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:0.4'
      }
  }
  apply plugin: 'android'
  
  dependencies {
      compile files('libs/android-support-v4.jar')
  }
  
  android {
      compileSdkVersion 17
      buildToolsVersion "17.0.0"
  
      defaultConfig {
          minSdkVersion 7
          targetSdkVersion 16
      }
  }
  
  sourceSets {
      main  {
          java {
              srcDir 'src/main/java'
          }
      }
  }
  task jar(type: Jar) {
      from sourceSets.main.java
  }
  </code></pre>
  
  <p>I'm running the script as:
  <code>gradle clean jar</code></p>
  
  <p>When I run the tasks, nothing happens... Why? What am I missing?</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>Below is the new gradle build file that I'm using. Notice the gradle version change due to android studio's latest update. Even with a simple <code>clean build</code> I get this error: <code>Project directory '&lt;my_workspace_path&gt;\Core2Project\build.gradle' is not a directory.</code> <strong>This error only happens in the build studio. Not when I run from the IDE. I've run into this same issue with another project as well. Turns out i'll get this error when I specify the file name to use in the build studio.</strong></p>
  
  <pre><code>buildscript {
      repositories {
          mavenCentral()
      }
      dependencies {
          classpath 'com.android.tools.build:gradle:0.5.+'
      }
  }
  apply plugin: 'android'
  
  dependencies {
      compile files('libs/android-support-v4.jar')
  }
  
  android {
      compileSdkVersion 17
      buildToolsVersion "17.0.0"
  
      defaultConfig {
          minSdkVersion 7
          targetSdkVersion 16
      }
  
      sourceSets {
          main  {
              java {
                  srcDir 'src/main/java'
              }
          }
      }
  }
  
  
  task jar(type: Jar) {
      from android.sourceSets.main.java
  }
  </code></pre>