`
Rainbow702
  • 浏览: 1064555 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类

windows下如何批量下载android源码

阅读更多


  为了在windows下批量下载Android的源码,上网查了一会,有些贴子建议使用SHELL脚本,有些是使用JAVA脚本,由于我本人对SHELL不懂,但对JAVA还是很熟的,所以,就选择了后者进行源码的下载。

 

原文地址:http://www.cnblogs.com/skyme/archive/2011/05/14/2046040.html

 

在网上找了好久都没有找到如何批量下载,只是找到有位通过角本执行来进行下载的。

试了一下在我机器上运行有问题,所以索性自己搞了一个出来。

首先根据官方的说法要下载git,这个无论如何是要下载的。

下载地址: http://code.google.com/p/msysgit/

点击安装(一路点击 Next 即可) 


 

安装完成后,在盘符上建立文件夹,我建在E:\Learning_stuff\android\src下

右键选择Git bash

弹出如下界面



 

下面就是整理下载的过程了,如果只需要下载其中的一个包,那么就不需要做下面的操作了,如果想下载全部源码就需要做一下处理,因为windows下是没有repo的

进入下载页面

http://android.git.kernel.org/

如果只下载一个,只需要

git clone git://android.git.kernel.org/ + project path.

将后面的project path改为下面第一列的内容即可。



 

这样对应的需要的包就可以下载了。

如果想下载所有的源码

在下载页面里进行选择

将页面中文件列表中的内容选择出来,并且放到文本文件中


 

 

把文件保存到androidURL.txt中

然后用程序来取出我们需要的信息

新建类ReplaceFile.java

public class ReplaceFile { /** * @param args */ public static void main(String[] args) { String fileName = "C:/androidURL.txt"; readFileByLines(fileName); } private static void readFileByLines(String fileName) { List<String> tmpList = new ArrayList<String>();// 用来存放修改后的url File file = new File(fileName); BufferedReader reader = null; try { System.out.println("以行为单位读取文件内容,一次读一整行:"); reader = new BufferedReader(new FileReader(file)); String tempString = null; int line = 1; // 一次读入一行,直到读入null为文件结束 while ((tempString = reader.readLine()) != null) { // 显示行号 String splitByStr = ".git"; int tmpI = tempString.indexOf(splitByStr); if (tmpI >= 0) { tempString = tempString.substring(0, tempString.indexOf(".git")); String gitGet = "git clone git://android.git.kernel.org/"; // System.out.println("line " + line + ": " + gitGet // + tempString + splitByStr); System.out.println(gitGet+ tempString + splitByStr); tmpList.add(gitGet+ tempString + splitByStr); } line++; } reader.close(); } catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e1) { } } } } }

 

 

取出得到的文件列表如下:

 

git clone git://android.git.kernel.org/device/common.git git clone git://android.git.kernel.org/device/google/accessory/arduino.git git clone git://android.git.kernel.org/device/google/accessory/demokit.git git clone git://android.git.kernel.org/device/htc/common.git git clone git://android.git.kernel.org/device/htc/dream-sapphire.git git clone git://android.git.kernel.org/device/htc/dream.git git clone git://android.git.kernel.org/device/htc/passion-common.git git clone git://android.git.kernel.org/device/htc/passion.git git clone git://android.git.kernel.org/device/htc/sapphire.git git clone git://android.git.kernel.org/device/sample.git git clone git://android.git.kernel.org/device/samsung/crespo.git git clone git://android.git.kernel.org/device/samsung/crespo4g.git git clone git://android.git.kernel.org/kernel/common.git
……………………………………

 

 

 

我是将信息直接输出到控制台,这个是比较新的版本,如果再有更新可以用以上的方法更新下面的配置文件

在git的控制台上


 

点击左上角点击编缉,粘贴

然后就是等待,等待...........

 

 

PS:我在下载的时候(2011-05-18),http://android.git.kernel.org/ 中共有268个PROJECT,下载完成后的总大小为14.4GB,所以,想下载的童鞋请准备好充足的空间啊,不然就杯具了哈。


 

如果以后,想对某个文件夹里的源码进行更新,只需要进入到该文件夹中,然后输入 "git pull " 就可以进行更新了。

 

最后一个附件为20011/08/14截取的所有 project path
 

  • 大小: 104.5 KB
  • 大小: 57.8 KB
  • 大小: 441 KB
  • 大小: 54.8 KB
  • 大小: 48.8 KB
  • 大小: 38.2 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics