gradle cache转为local Maven库,解决gradle编译依赖包时常被墙

来源:互联网 发布:菲律宾网络彩票合法吗 编辑:程序博客网 时间:2024/05/16 01:50
import glob,os,shutilimport distutils.dir_util,distutils.file_utildef mvtoparent(d):    for dpath,dnames,fnames in os.walk(d):        for fname in fnames:            if  os.path.splitext(fname)[1] in ['.jar', '.pom']:                print "move:", os.path.join(dpath,fname), os.path.join(os.path.dirname(dpath),fname)                shutil.move(os.path.join(dpath,fname), os.path.join(os.path.dirname(dpath),fname))                def splitdir(d):    mvtoparent(d)    subd = d.split('.')    resdir='\\'.join(subd)    print "copytree:", d, resdir    os.system("xcopy %s %s /S /Y"%(d,resdir))    print "rm:", d    shutil.rmtree(d)    basd = []for dirpattern in ['org.*','com.*','net.*']:    basd.extend(glob.glob(dirpattern))print "convert dirs:", basdfor d in basd: splitdir(d)

转换完成后,记得修改build.gradle:

buildscript {    repositories {        mavenLocal()    }    dependencies {        classpath 'com.android.tools.build:gradle:1.0.1'        classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.+'        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}allprojects {    repositories {        mavenLocal()    }}


0 0
原创粉丝点击