强制Gradle/Maven刷新缓存并重新从Nexus下载依赖jar包

最近需要搭建一个Nexus私服,完全不能连接外网的那种,各种Jar包都是手动拷过来的,碰到需要gradle和maven强制重新下载依赖的问题。

问题

第一次上传某个jar包(比如junit-4.12.jar)到Nexus上,然后调用gradle build可以正确下载到依赖包。但如果手动删掉了本地缓存的jar包(在~/.gradle下),这时从Nexus的下载过程中断,或者Nexus上暂时不存在这个jar包,那么即使Nexus恢复了正常下载,下次执行gradle build时就一直提示不能够找到jar包。

FAILURE: Build failed with an exception.

- What went wrong:
Could not resolve all dependencies for configuration ':testCompile'.
> Could not find junit:junit:4.12.
  Searched in the following locations:
      http://localhost:8081/nexus/content/groups/public/junit/junit/4.12/junit-4.12.pom
      http://localhost:8081/nexus/content/groups/public/junit/junit/4.12/junit-4.12.jar
  Required by:
      org.codehaus.sonar:example-java-maven:1.0-SNAPSHOT

解决方案

回到自己的工作目录下,带参数执行gradle强制刷新~/.gradle下的文件缓存

1
gradle build --refresh-dependencies

继续阅读 More

好用的bash提示符和vim配置

定制bash命令行的提示信息,用彩色显示,还包括当前git branch等。
另外还有vi编辑器的配置,让电脑更好用。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
##### ~/.bashrc

alias ls="ls -G"
alias ll="ls -alG"

function parse_git_branch_and_add_brackets {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(. *\)/\ \1\]/'
}

export PS1="\[\e[32;40m\]\u@ \[\e[33;40m\]\w \[\033[0;34m\]\$(parse_gi t_branch_and_add_brackets) \[\033[0m\]\$ "



##### ~/.vimrc

set nocompatible
set cursorline
colorscheme torte
set number
syntax on

SVN pre-commit hook

某团队希望做到Continuous Code Review, 想在每次check-in 到SVN之前,先判断特定用户群体否在commit log里面包含了”Review By: xxx”的字样。

记得以前NSN里面有人用过这个法子,记不太清了。

于是研究了一下脚本,其实SVN/GIT都提供了类似的hook, 在<your repository>/hooks 目录下,都是shell或cmd脚本(要看服务器的操作系统了),会在不同的事件时触发。

为了实现更复杂的功能或者需要跨平台,那不妨用shell或cmd去调用Python脚本咯。

继续阅读 More