Using Gradle to pack your java application as a fat jar

作者:Rui 发布时间:March 4, 2016 分类:JAVA,ANDROID 浏览:622

使用Gradle 将应用程序和依赖包打包到一个JAR内

jar {
    from {
        fileTree(dir: 'libs', include: '*.jar').collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }
}

Gradle 使用OSChina Maven 仓库

作者:Rui 发布时间:February 29, 2016 分类:JAVA,ANDROID 浏览:2,205

国内使用Maven官方仓库速度很慢,切换到国内镜像或者公司私服会提速很多。

修改项目根目录下的build.gradle,将所有的jcenter() 和mavenCentral() 全部替换成

allprojects {
    repositories {
        maven{ url 'http://maven.oschina.net/content/groups/public/'}
    }
}

如果项目多,可修改全局配置,将所有使用gradle的项目自动换成国内的镜像。

将下面这段Copy到名为init.gradle文件中,并保存到 USER_HOME/.gradle/文件夹下即可

allprojects{
    repositories {
        def REPOSITORY_URL = 'http://maven.oschina.net/content/groups/public'
        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                    remove repo
                }
            }
        }
        maven {
            url REPOSITORY_URL
        }
    }
}

init.gradle文件其实是Gradle的初始化脚本(Initialization Scripts),也是运行时的全局配置。
更详细的介绍请参阅 http://gradle.org/docs/current/userguide/init_scripts.html

Reference


Dependency Management
Change Gradle mavenCentral URL to My repo
What is included in JCenter repository in Gradle?

Gradle Plugin Develop

作者:Rui 发布时间:November 6, 2015 分类:JAVA,ANDROID 浏览:370

Gerrit Code Review 服务搭建

作者:Rui 发布时间:October 23, 2015 分类:JAVA,ANDROID 浏览:1,707

简介

Gerrit一种免费、开放源代码的代码审查和项目管理软件,同一个团队的软件程序员,可以相互审阅彼此修改后的程序代码,决定是否能够提交,退回或者继续修改,原先是为了管理Android计划而产生的,现在已成为很多开源项目的Code Review工具

下载

源码地址:https://gerrit.googlesource.com, gerrit的源码和相关插件的源码地址
https://gerrit.googlesource.com/gerrit 这个是gerrit的源码

我们可以直接下载已经打包的好的可执行安装包
http://gerrit-releases.storage.googleapis.com/index.html
选择一个合适的版本下载即可

安装

环境要求

  • JDK runtime 1.7 +
  • MySQL or PostgreSQL

配置 Java Strong Cryptography

为了支持超强密码加密:AES128CTR, AES256CTR, ARCFOUR256和ARCFOUR128,需要从Oracle 官网下载安装Java Cryptography Extension (JCE)

注意:安装JCE并不是必须的

  1. 下载JCE lib
    JDK7 JCE policy files
    JDK8 JCE policy files
  2. 解压缩JCE
    下载的文件里包含一下文件
    README.txt Information about JCE and installation guide
    local_policy.jar Unlimited strength local policy file
    US_export_policy.jar Unlimited strength US export policy file
  3. 依照README 安装JCE

数据库配置

MySQL

CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';
CREATE DATABASE reviewdb;
GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';
FLUSH PRIVILEGES;

阅读剩余部分...

Android: Jumbo Mode vs Multidex

作者:Rui 发布时间:October 21, 2015 分类:ANDROID 浏览:1,893

Jumbo Mode, when reading https://source.android.com/devices/tech/dalvik/dalvik-bytecode.html, the const-string/jumbo is the jumbo mode for string. It is about the opcode such that "op vAA, string@BBBBBBBB" versus "op vAA, string@BBBB", 32 bits versus 16 bit.

Multi Dex is to allow to load classes from more than one dex file. The primary classes.dex must contain the classes necessary for calling this class methods. Secondary dex files found in the application apk will be added to the classloader after first call to MultiDex.install(Context) see https://developer.android.com/reference/android/support/multidex/MultiDex.html


Tips:
https://source.android.com/devices/tech/
https://groups.google.com/forum/
https://developer.android.com/reference/android/support