标签:
task makeJar(type: Jar) {
    //指定生成的jar名
    baseName ‘plugin‘
    //从哪里打包class文件
    from(‘build/intermediates/classes/debug/com/xhrd/mobile/hybridframework/plugin/‘)
    //打包到jar后的目录结构
    into(‘com/xhrd/mobile/hybridframework/plugin/‘)
    //去掉不需要打包的目录和文件
    exclude(‘test/‘, ‘BuildConfig.class‘, ‘R.class‘)
    //去掉R$开头的文件
    exclude{ it.name.startsWith(‘R$‘);}
}
task makeJar2(type: Jar){
    archiveName = "myJarName.jar"
    from(‘build/intermediates/classes/debug/com/xhrd/mobile/hybridframework/plugin/‘){
        exclude(‘BuildConfig.class‘, ‘R.class‘)
        //去掉R$开头的文件
        exclude{ it.name.startsWith(‘R$‘);}
    }
    //打包到jar后的目录结构
    into(‘com/xhrd/mobile/hybridframework/plugin/‘)
}
http://stackoverflow.com/questions/11474729/how-to-build-sources-jar-with-gradle标签:
原文地址:http://www.cnblogs.com/maxinliang/p/4634206.html