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

来源:互联网 发布:matlab矩阵中有未知数 编辑:程序博客网 时间:2024/06/04 18:06
[python] view plain copy 在CODE上查看代码片派生到我的代码片
  1. import glob,os,shutil  
  2. import distutils.dir_util,distutils.file_util  
  3.   
  4. def mvtoparent(d):  
  5.     for dpath,dnames,fnames in os.walk(d):  
  6.         for fname in fnames:  
  7.             if  os.path.splitext(fname)[1in ['.jar''.pom']:  
  8.                 print "move:", os.path.join(dpath,fname), os.path.join(os.path.dirname(dpath),fname)  
  9.                 shutil.move(os.path.join(dpath,fname), os.path.join(os.path.dirname(dpath),fname))  
  10.                   
  11. def splitdir(d):  
  12.     mvtoparent(d)  
  13.     subd = d.split('.')  
  14.     resdir='\\'.join(subd)  
  15.     print "copytree:", d, resdir  
  16.     os.system("xcopy %s %s /S /Y"%(d,resdir))  
  17.     print "rm:", d  
  18.     shutil.rmtree(d)  
  19.       
  20. basd = []  
  21. for dirpattern in ['org.*','com.*','net.*']:  
  22.     basd.extend(glob.glob(dirpattern))  
  23. print "convert dirs:", basd  
  24. for d in basd: splitdir(d)  

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

[java] view plain copy 在CODE上查看代码片派生到我的代码片
  1. buildscript {  
  2.     repositories {  
  3.         mavenLocal()  
  4.     }  
  5.     dependencies {  
  6.         classpath 'com.android.tools.build:gradle:1.0.1'  
  7.         classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.+'  
  8.   
  9.         // NOTE: Do not place your application dependencies here; they belong  
  10.         // in the individual module build.gradle files  
  11.     }  
  12. }  
  13.   
  14. allprojects {  
  15.     repositories {  
  16.         mavenLocal()  
  17.     }  
  18. }  
0 0
原创粉丝点击