forked from jerryting/base-nio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
143 lines (125 loc) · 3.78 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* @author : DJ@201509
* @summary: Java application 's gradle build script
* @cmd & task: gradle build
* gradle eclipse
* gradle cleanEclipse
* gradle publish
* gradle release
* gredle version
*/
import java.util.regex.Pattern
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'at.bxm.svntools'
tasks.withType(JavaCompile){
options.encoding = 'UTF-8'
}
sourceCompatibility = 1.7
ext{
artifactIdName = 'polarlight-basenio'
groupId = 'com.polarlight.commons'
authSvnUser='builder'
authSvnPwd='builder'
}
archivesBaseName = artifactIdName
version = "2.0.2"
repositories { //mvn中央库依赖配置
maven {url 'http://192.168.1.8:8081/nexus/content/groups/public'}
jcenter()
//mavenCentral()
}
dependencies { //依赖包声明
compile 'log4j:log4j:1.2.16'
compile 'org.slf4j:slf4j-api:1.6.2'
compile 'org.slf4j:slf4j-log4j12:1.6.2'
}
sourceSets {
main {
java {
srcDir 'src/java'
}
resources {
srcDir 'src/resources'
}
}
}
jar {
manifest {
attributes 'Implementation-Title': 'polarlight-basenio-v2',
'Implementation-Version': version
}
}
publishing { //发布到mvn中央库
publications {
mavenJava(MavenPublication) {
from components.java
groupId 'com.polarlight.commons'
artifactId artifactIdName
version version
}
}
repositories {
maven {
url "http://192.168.1.8:8081/nexus/content/repositories/releases"
// url "$buildDir/repo"
credentials {
username = 'deployment'
password = 'www.ixinyou.com'
}
}
}
}
buildscript { // svn plugin
repositories {
/*maven {
url 'https://plugins.gradle.org/m2/'
}*/
jcenter()
}
dependencies {
classpath "at.bxm.gradleplugins:gradle-svntools-plugin:1.2.1"
}
}
task versionInfo <<{
println "::Build version is $version"
println "::Current svn revision is $svntools.info.revisionNumber"
}
task svnTag (type: at.bxm.gradleplugins.svntools.tasks.SvnTag){
svnUrl = 'http://192.168.1.101/svn/polarlight/trunk/client-android/basenio-2.0-beta'
username = authSvnUser
password = authSvnPwd
def tagPath = "basenio-2.0/"
tagName = tagPath+"$project.archivesBaseName-$project.version-SNAPSHOT"
commitMessage = "Release version $tagName"
replaceExisting = true
}
task increaseVersion << { //版本号自增长
def buildFile = file("build.gradle")
def pattern = Pattern.compile('version[\\s]*=[\\s]*"(\\d+)\\.(\\d+)\\.(\\d+)"')
def buildText = buildFile.getText()
def matcherVersionNumber = pattern.matcher(buildText)
matcherVersionNumber.find()
def majorVersion = Integer.parseInt(matcherVersionNumber.group(1))
def minorVersion = Integer.parseInt(matcherVersionNumber.group(2))
def buildVersion = Integer.parseInt(matcherVersionNumber.group(3))
def mNextVersion = majorVersion + '.' + minorVersion + '.' + (buildVersion + 1)
def buildFileContent = matcherVersionNumber.replaceAll('version = ' + '"' + mNextVersion + '"')
buildFile.write(buildFileContent)
println '::increaseVersion next version is '+ mNextVersion
}
task commitChangedGradle (type: at.bxm.gradleplugins.svntools.tasks.SvnCommit){
username = authSvnUser
password = authSvnPwd
source << file("build.gradle")
commitMessage = "Release version $project.version"
}
task release (dependsOn: ['clean','build','svnTag','increaseVersion','commitChangedGradle']){
}
release.mustRunAfter commitChangedGradle
commitChangedGradle.mustRunAfter increaseVersion
increaseVersion.mustRunAfter svnTag
svnTag.mustRunAfter build
build.mustRunAfter clean
build.dependsOn versionInfo,clean