forked from corda/corda-gradle-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
227 lines (193 loc) · 7.26 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
import static org.gradle.api.JavaVersion.VERSION_1_8
import static org.gradle.jvm.toolchain.JavaLanguageVersion.of
plugins {
id 'org.jetbrains.kotlin.jvm' apply false
id 'com.gradle.plugin-publish' apply false
id 'com.jfrog.artifactory' apply false
id 'com.jfrog.bintray' apply false
}
ext {
vcsUrl = 'https://github.com/corda/corda-gradle-plugins'
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'idea'
version gradle_plugins_version
group 'net.corda.plugins'
java {
toolchain {
languageVersion = of(8)
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
tasks.withType(GroovyCompile).configureEach {
options.encoding = 'UTF-8'
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
// When writing Gradle plugins in Kotlin, we need to restrict
// ourselves to the same Kotlin API that Gradle itself uses.
// Gradle 4.10.x uses Kotlin 1.2.
// Gradle 5.x - 6.7.1 uses Kotlin 1.3.
// Gradle 6.8 uses Kotlin 1.4
jvmTarget = VERSION_1_8
apiVersion = '1.3'
languageVersion = '1.3'
freeCompilerArgs = ['-Xjvm-default=enable']
}
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
// Prevent the project from creating temporary files outside of the build directory.
systemProperty 'java.io.tmpdir', buildDir.absolutePath
// Tell the tests where Gradle's current module cache is.
// We need the tests to share this module cache to prevent the
// Gradle Test-Kit from downloading its own copy of Kotlin etc.
systemProperty 'test.gradle.user.home', project.gradle.gradleUserHomeDir
}
tasks.withType(ValidatePlugins).configureEach {
// Ask Gradle to tell us how to annotate tasks correctly.
enableStricterValidation = true
}
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
}
// Only the top-level projects are plugins, so only publish these ones.
// The "child projects" are the immediate children of the root. Any
// "grandchild" project is considered to be internal to its parent.
def publishProjects = project.childProjects.values()
configure(publishProjects) { Project subproject ->
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'com.gradle.plugin-publish'
evaluationDependsOn(subproject.path)
tasks.register('sourceJar', Jar) {
dependsOn subproject.classes
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
tasks.register('javadocJar', Jar) {
dependsOn subproject.javadoc
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
tasks.register('install') {
dependsOn 'publishToMavenLocal'
}
publishing {
publications {
create(subproject.name, MavenPublication) {
if (subproject.hasProperty('mavenArtifacts')) {
subproject.mavenArtifacts.call(it)
} else {
from components.java
}
groupId subproject.group
artifactId subproject.name
artifact tasks.sourceJar
artifact tasks.javadocJar
pom {
name = subproject.name
description = subproject.description
url = vcsUrl
scm {
url = vcsUrl
}
licenses {
license {
name = 'Apache-2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0'
distribution = 'repo'
}
}
developers {
developer {
id = 'R3'
name = 'R3'
email = '[email protected]'
}
}
}
if (subproject.hasProperty('mavenPom')) {
subproject.mavenPom.call(pom)
}
}
// Create a "special" artifact in the Maven repository so that
// Gradle's plugins {} block can find our plugins:
//
// This artifact would normally be created by setting:
//
// gradlePlugin {
// automatedPublishing = true
// }
//
// except that this would also discard all of our POM customisations.
subproject.extensions['gradlePlugin'].plugins.forEach { plugin ->
create(subproject.name + '-' + plugin.name, MavenPublication) {
groupId plugin.id
artifactId plugin.id + '.gradle.plugin'
pom {
packaging 'pom'
withXml {
def dependency = asNode().appendNode('dependencies').appendNode('dependency')
dependency.appendNode('groupId', subproject.group)
dependency.appendNode('artifactId', subproject.name)
dependency.appendNode('version', subproject.version)
}
}
}
}
}
}
bintray {
user = System.getenv('CORDA_BINTRAY_USER') ?: System.getProperty('corda.bintray.user')
key = System.getenv('CORDA_BINTRAY_KEY') ?: System.getProperty('corda.bintray.key')
publications = [subproject.name]
dryRun = (System.getenv('CORDA_BINTRAY_DRYRUN') != null || System.getProperty('corda.bintray.dryrun') != null)
pkg {
repo = 'corda'
name = subproject.name
userOrg = 'r3'
licenses = ['Apache-2.0']
version {
gpg {
sign = true
passphrase = System.getenv('CORDA_BINTRAY_GPG_PASSPHRASE')
}
}
}
}
}
artifactory {
publish {
contextUrl = artifactory_contextUrl
repository {
repoKey = 'corda-dev'
username = project.findProperty('cordaArtifactoryUsername') ?: System.getenv('CORDA_ARTIFACTORY_USERNAME') ?: System.getProperty('corda.artifactory.username')
password = project.findProperty('cordaArtifactoryPassword') ?: System.getenv('CORDA_ARTIFACTORY_PASSWORD') ?: System.getProperty('corda.artifactory.password')
}
defaults {
if (publishProjects.contains(project)) {
publications(project.name)
project.extensions['gradlePlugin'].plugins.forEach { plugin ->
publications(project.name + '-' + plugin.name)
}
}
}
}
}
wrapper {
gradleVersion = '6.7.1'
distributionType = Wrapper.DistributionType.ALL
}