-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
182 lines (153 loc) · 5.51 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
apply plugin: 'java'
apply plugin: 'application'
//apply plugin: "sonar-runner"
//apply from: 'dependencies.gradle'
sourceCompatibility = 1.8
//删除父目录下的test,避免test task执行失败
delete "${buildDir}/classes/test"
mainClassName = ' '
buildscript {
repositories {
mavenCentral()
}
dependencies {
// classpath 'org.gradle.api.plugins:gradle-nexus-plugin:0.4'
classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1+'
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
}
//tasks.withType(Compile) {
// options.encoding = "UTF-8"
//}
//project.configurations.all {
// resolutionStrategy {
// cacheChangingModulesFor 0, 'seconds'
// resolutionRules.with {
// eachModule({ moduleResolve ->
// if (moduleResolve.request.version.endsWith('-SNAPSHOT')) {
// // This will cause the dependency to be refreshed once per build execution
// moduleResolve.cacheFor(0, SECONDS)
// // This would cause the dependency to be refreshed once per sub-project in a multi-project build. You wouldn't normally want that.
// // moduleResolve.refresh()
// }
// } as Action)
// eachArtifact({ artifactResolve ->
// if (artifactResolve.request.moduleVersionIdentifier.version.endsWith('-SNAPSHOT')) {
// artifactResolve.cacheFor(0, SECONDS)
// }
// } as Action)
// }
// }
//}
/** 此闭包内的声明子类皆可使用 */
allprojects {
group = 'cn.rxframework.utils'
version = '0.0.8'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'maven-publish-auth'
repositories {
mavenLocal()
// repositories { maven { url 'http://repo.rx.cn/content/groups/public/' } }
mavenCentral()
}
publishing {
task sourceJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
publications {
mavenJava(MavenPublication) { from components.java }
mavenJava(MavenPublication) {
artifact(sourceJar) {
classifier = "sources"
}
}
}
// repositories {
// maven {
// name = 'rx'
// url "http://repo.rx.cn/content/repositories/${project.version.endsWith('-SNAPSHOT') ? 'snapshots' : 'releases'}"
// }
// }
}
}
//拷贝根目录下的所有test到各自子module下
task "copytest" << {
def fromPath
def toPath
subprojects.each {
fromPath = "${project.buildDir}/classes/test/${it.name}"
toPath = "${it.buildDir}/classes/test"
copy {
from fromPath
into toPath
}
}
}
task createREADME() {
file("README.md").createNewFile()
}
subprojects {
task "createJavaProject" << {
sourceSets*.java.srcDirs*.each { it.mkdirs() }
sourceSets*.resources.srcDirs*.each { it.mkdirs() }
/** 可选生成子文件夹 */
// file("src/main/filters").mkdirs()
// file("src/main/assembly").mkdirs()
// file("src/main/config").mkdirs()
// file("src/main/scripts").mkdirs()
/** 填充文件,便于git提交 */
file("src/main/java/cn/rxframework/utils").mkdirs()
file("src/main/java/cn/rxframework/utils/package-info.java").createNewFile()
file("src/main/resources").mkdirs()
file("src/main/resources/spring.xml").createNewFile()
file("src/test/java/cn/rxframework/utils").mkdirs()
file("src/test/java/cn/rxframework/utils/package-info.java").createNewFile()
file("src/test/resources/spring.xml").createNewFile()
}
/** 有时候会报错,但需要执行 */
// task createREADME(){
// file("README.md").createNewFile()
// }
configurations {
provided
compile.extendsFrom provided
all*.exclude group: 'org.springframework', module: 'spring'
all*.exclude group: 'asm', module: 'asm'
all*.exclude group: 'log4j', module: 'log4j'
all*.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
dependencies {
// compile group: "cn.rx.common", name: "xxx", version: "$rxCommonVersion", changing: true
testCompile "junit:junit:4.11"
compile "commons-logging:commons-logging:$apacheCommonsLoggingVersion"
compile "org.slf4j:slf4j-api:$slf4jVersion"
// 加载libs目录下所有的jar
compile fileTree(dir: 'libs', include: ['*.jar'])
}
}
//configure(subprojects.findAll { it.name.contains('-service') }) {
// task createServiceProject(dependsOn: 'createJavaProject') << {
//
// file("src/main/resources/config").mkdirs()
// file("src/main/resources/config/main-conf.properties").createNewFile()
// file("src/main/resources/config/metadata.properties").createNewFile()
// }
//}
configure(subprojects.findAll { it.name.contains('war') }) {
apply plugin: 'war'
apply plugin: 'jetty'
// task createWebProject(dependsOn: 'createJavaProject') << {
// def webAppDir = file("$webAppDirName")
// webAppDir.mkdirs()
//
// file("src/main/resources/config").mkdirs()
// file("src/main/resources/config/main-conf.properties").createNewFile()
// file("src/main/resources/config/metadata.properties").createNewFile()
// }
}