-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.gradle
204 lines (184 loc) · 9.25 KB
/
common.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
configure(rootProject) {
ext.gitHash = 'git log -1 --format=%H'.execute().text.trim()
}
subprojects {
version = rootProject.version
group = rootProject.group
ext.gitHash = rootProject.gitHash
}
allprojects {
repositories {
mavenCentral()
mavenLocal()
}
afterEvaluate { memberProject ->
configure(memberProject) {
// Configure Java and/or Scala.
if (plugins.hasPlugin('java') || plugins.hasPlugin('java-library') || plugins.hasPlugin('scala')) {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
tasks.register('sourcesJar', Jar) {
dependsOn classes
//noinspection GroovyAccessibility, GroovyAssignabilityCheck
archiveClassifier = 'sources'
if (sourceSets.main.hasProperty('allJava')) from sourceSets.main.allJava.srcDirs
if (sourceSets.main.hasProperty('allScala')) from sourceSets.main.allScala.srcDirs
}
tasks.register('javadocJar', Jar) {
//noinspection GroovyAccessibility, GroovyAssignabilityCheck
archiveClassifier = 'javadoc'
if (tasks.hasProperty('javadoc')) from javadoc.destinationDir
if (tasks.hasProperty('scaladoc')) from scaladoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
tasks.withType(JavaCompile).configureEach {
options.debug = true
options.encoding = 'UTF-8'
}
tasks.withType(Jar).configureEach {
manifest {
attributes(
'Implementation-Title': project.description,
'Implementation-Version': project.version,
'Implementation-Vendor': project.group,
'Source-Revision': gitHash
)
}
}
tasks.withType(Test).configureEach {
jvmArgs '-Xmx1024m', "-Djava.library.path=${buildDir}/lib"
}
// Input libraries shouldn't define concrete log bindings. Leave that to the application.
configurations.findAll { !it.name.endsWith('Classpath') }.each { configuration ->
configuration.dependencies.each { dependency ->
if (dependency.getClass().getSimpleName().contains("ExternalModuleDependency")) {
dependency.exclude group: 'org.slf4j', module: 'log4j-over-slf4j'
dependency.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
dependency.exclude group: 'org.slf4j', module: 'jcl-over-slf4j'
dependency.exclude group: 'ch.qos.logback', module: 'logback-classic'
}
}
}
// Make sure compile-only dependencies are NOT transitive. When they're transitive you can compile against
// an unexpected version of a transitive dependency.
configurations.findAll { (it.name == 'compileOnly') }.each { configuration ->
configuration.dependencies.each {
it.transitive = false
}
}
// Configure Idea for javadoc and source download.
if (plugins.hasPlugin('idea')) {
idea {
module {
downloadJavadoc = true
downloadSources = true
inheritOutputDirs = false
// Match the newer gradle conventions
if (sourceSets.main.hasProperty('allScala')) {
outputDir = file("$buildDir/classes/scala/main")
testOutputDir = file("$buildDir/classes/scala/test")
} else if (sourceSets.main.hasProperty('allJava')) {
outputDir = file("$buildDir/classes/java/main")
testOutputDir = file("$buildDir/classes/java/test")
}
}
}
}
}
// Configure standard publication.
if (plugins.hasPlugin('maven-publish')) {
publishing {
repositories {
if (version.endsWith('SNAPSHOT')) {
maven {
name = 'central-snapshot'
url = 'https://oss.sonatype.org/content/repositories/snapshots/'
if (project.hasProperty('sonatype_user')) {
credentials {
username = "${sonatype_user}"
password = "${sonatype_password}"
}
}
}
} else {
maven {
name = 'central-staging'
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
if (project.hasProperty('sonatype_user')) {
credentials {
username = "${sonatype_user}"
password = "${sonatype_password}"
}
}
}
}
}
if (sourceSets.main.allJava) {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = project.name
description = project.description
packaging = 'jar'
url = 'https://github.com/davidbuccola/' + rootProject.name
organization {
name = 'David Buccola'
url = 'https://github.com/davidbuccola'
}
developers {
developer {
id = 'davidbuccola'
name = 'David Buccola'
email = 'david.buccola@gmail.com'
}
}
scm {
url = 'git@github.com:davidbuccola/' + rootProject.name + '.git'
connection = 'scm:git:git@github.com:davidbuccola/' + rootProject.name + '.git'
developerConnection = 'scm:git:git@github.com:davidbuccola/' + rootProject.name + '.git'
}
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}
// //noinspection GroovyAssignabilityCheck
// parent {
// groupId 'org.sonatype.oss'
// artifactId 'oss-parent'
// version '7'
// }
}
}
}
}
}
}
// Configure Artifactory publication.
if (plugins.hasPlugin('com.jfrog.artifactory') && plugins.hasPlugin('maven-publish')) {
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = "libs-${project.version.endsWith('-SNAPSHOT') ? 'snapshot' : 'release'}-local"
username = artifactory_user
password = artifactory_password
}
defaults {
publications('mavenJava')
publishIvy = false
}
}
}
}
}
}
}