Skip to content

Instantly share code, notes, and snippets.

@trevorrjohn
Created December 11, 2014 04:24
Show Gist options
  • Save trevorrjohn/dae4dfd97381fe7f728e to your computer and use it in GitHub Desktop.
Save trevorrjohn/dae4dfd97381fe7f728e to your computer and use it in GitHub Desktop.
Fix order of dependencies for Intellij or Android Studio
#!/bin/sh
set -o pipefail
set -o errexit
set -o nounset
#set -o xtrace
__DIR__="$(cd "$(dirname "${0}")"; echo $(pwd))"
__BASE__="$(basename "${0}")"
__FILE__="${__DIR__}/${__BASE__}"
file="${__DIR__}/../*.iml"
tmp_file="/tmp/tmp.iml"
lines=$(cat ${file} | wc -l)
needed_lines=$((lines-3))
framework='<orderEntry type="jdk" jdkName="Android API [1-9]* Platform" jdkType="Android SDK" />'
sdk_form_framework=$(grep "${framework}" ${file})
head -n ${needed_lines} ${file} | grep -v "${framework}" > ${tmp_file}
cat << EOF >> ${tmp_file}
${sdk_form_framework}
</component>
</module>
EOF
mv ${tmp_file} ${file}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment