Skip to content

Instantly share code, notes, and snippets.

@joninvski
Last active June 2, 2016 14:22
Show Gist options
  • Save joninvski/d206478ba24fb58da6d8 to your computer and use it in GitHub Desktop.
Save joninvski/d206478ba24fb58da6d8 to your computer and use it in GitHub Desktop.
Android development in vim

First put a the following init.d gradle script in ${HOME}/.gradle/init.d/ (currently in build.gradle but not working in init):

 allprojects {
      tasks.withType(Compile) { // Use JavaCompile for gradle > 2.0
          options.compilerArgs << "-Xlint:deprecation"
      }
      task printDependencies << {task -> println "Subproject -> $task.project.name" }
 }

subprojects {
ext.versionfile = new File('CLASSPATH_AUX')
versionfile.text = ''

printDependencies {
    afterEvaluate { Project project ->
        if (configurations.find { it.name == 'compile' }) {
            doLast {
                println "$project.configurations.compile.asPath\n"
                versionfile.text += "$project.configurations.compile.asPath" + ':'
            }
        }
        if (configurations.find { it.name == 'androidTestCompile' }) {
            doLast {
                println "$project.configurations.androidTestCompile.asPath\n"
                versionfile.text += "$project.configurations.androidTestCompile.asPath" + ':'
            }
        }
    }
  }

}

Then run:

source fill_classpath.sh

Although not strictly vim you may run in a parallel shell:

while true; do inotifywait -e close_write **/*.java **/*.gradle **/*.xml; ./gradlew iDebug; done
GRADLE_CP=$(cat CLASSPATH_AUX);
ANDROID_CP="/home/workspace/setup_my_new_computer/android/android-sdk-linux/platforms/android-20/android.jar";
JAR_CP=$(find . -name \*.jar | sed -e 's/$/:/g' | tr -d '\n');
SOURCE_CP=$(find . -type d -name java | sed -e 's/$/:/g' | tr -d '\n');
REST_CP=$(find . -type d -name debug | grep "[exploded|java|source|classes|\/r\/]" | grep -v "release" | sed -e 's/$/:/g' | tr -d '\n');
CLASSPATH="${CLASSPATH_AUX}:${ANDROID_CP}:${JAR_CP}:${SOURCE_CP}:${REST_CP}:${GRADLE_CP}";
# Remove empty paths (replace :: with :)
CLASSPATH="${CLASSPATH//::/:}"
export CLASSPATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment