-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
197 lines (172 loc) · 6.39 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
import static org.gradle.api.JavaVersion.VERSION_11
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id 'net.corda.cordapp.cordapp-configuration'
id 'org.jetbrains.kotlin.jvm' apply false
id 'org.jetbrains.dokka' apply false
id 'io.gitlab.arturbosch.detekt'
id 'com.jfrog.artifactory'
id 'jacoco'
id 'com.r3.internal.gradle.plugins.r3ArtifactoryPublish' apply true
id 'com.r3.internal.gradle.plugins.r3Publish' apply false
}
def revision = {
if (System.getenv("CORDA_REVISION")) {
return System.getenv("CORDA_REVISION")
}
try {
return "git rev-parse HEAD".execute().text.trim()
} catch (Exception error) {
logger.warn("git is unavailable in build environment", error)
"unknown"
}
}()
def remoteUrl = {
try {
return "git remote get-url origin".execute().text.trim()
} catch (Exception error) {
logger.warn("git is unavailable in build environment", error)
return "unknown"
}
}()
subprojects {
if (System.getenv("RELEASE_VERSION")?.trim()) {
version = System.getenv("RELEASE_VERSION")
} else {
def versionSuffix = System.getenv('VERSION_SUFFIX') ?: "0-SNAPSHOT"
version = "$confidential_id_release_version-$versionSuffix"
}
group confidential_id_release_group
repositories {
mavenCentral()
maven { url "$artifactoryContextUrl/corda-dependencies" }
//needed for C5 binaries
maven {
url = "$artifactoryContextUrl/corda-os-maven"
credentials {
username = findProperty('cordaArtifactoryUsername') ?: System.getenv('CORDA_ARTIFACTORY_USERNAME')
password = findProperty('cordaArtifactoryPassword') ?: System.getenv('CORDA_ARTIFACTORY_PASSWORD')
}
}
}
pluginManager.withPlugin('java-library') {
java {
sourceCompatibility = VERSION_11
targetCompatibility = VERSION_11
}
}
tasks.withType(KotlinCompile).configureEach {
kotlinOptions {
allWarningsAsErrors = true
languageVersion = "1.4"
apiVersion = "1.4"
jvmTarget = VERSION_11
javaParameters = true // Useful for reflection.
freeCompilerArgs += [
"-Xjvm-default=all",
// Prevent Kotlin from warning about kotlin.* classes inside the OSGi bundle.
"-Xskip-runtime-version-check",
"-java-parameters"
]
}
}
tasks.register('compileAll') { task ->
description = "Compiles all the Kotlin and Java classes, including all of the test classes."
group = "verification"
task.dependsOn tasks.withType(AbstractCompile)
}
}
def publishProjects = [project(":ci-workflows")]
configure(publishProjects) { subproject ->
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
pluginManager.withPlugin('java-library') {
apply plugin: 'org.jetbrains.dokka'
def jarTask = tasks.named('jar', Jar)
tasks.register('sourceJar', Jar) {
dependsOn subproject.classes
archiveBaseName = jarTask.flatMap { it.archiveBaseName }
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
tasks.register('javadocJar', Jar) {
description = 'Create JavaDoc Jar from Dokka docs'
group = 'documentation'
def dokkaHtml = tasks.named('dokkaHtml', org.jetbrains.dokka.gradle.DokkaTask)
from dokkaHtml.flatMap { it.outputDirectory }
archiveBaseName = jarTask.flatMap { it.archiveBaseName }
archiveClassifier = 'javadoc'
}
tasks.withType(Jar).matching { !(it.name ==~ /cp[bk]/) }.configureEach {
manifest {
attributes("Corda-Release-Version": archiveVersion.get())
attributes("Corda-Platform-Version": corda_platform_version)
attributes("Corda-Revision": revision)
attributes("Automatic-Module-Name": "${confidential_id_release_group}.${project.name.replace('-', '.')}")
attributes("Corda-Docs-Link": docsUrl)
attributes("Corda-License": licenseUrl)
}
}
}
tasks.register('install') {
dependsOn 'publishToMavenLocal'
}
publishing {
publications {
create(subproject.name, MavenPublication) {
evaluationDependsOn(subproject.path)
groupId subproject.group
artifactId subproject.name
pluginManager.withPlugin('java-library') {
from components.java
artifact tasks.named('sourceJar', Jar)
artifact tasks.named('javadocJar', Jar)
}
pluginManager.withPlugin('net.corda.plugins.cordapp-cpk') {
artifact tasks.named('cpk', Jar)
}
pom {
name = subproject.name
description = subproject.description
url = remoteUrl
licenses {
license {
name = licenseName
url = licenseUrl
distribution = licenseUrl
}
}
developers {
developer {
id = pomDeveloperId
name = pomDeveloperName
email = pomDeveloperEmail
}
}
scm {
url = remoteUrl
}
}
}
}
}
}
artifactory {
publish {
contextUrl = artifactoryContextUrl
repository {
repoKey = System.getenv('CORDA_PUBLISH_REPOSITORY_KEY') ?: 'corda-lib-dev'
username = project.findProperty('cordaArtifactoryUsername') ?: System.getenv('CORDA_ARTIFACTORY_USERNAME')
password = project.findProperty('cordaArtifactoryPassword') ?: System.getenv('CORDA_ARTIFACTORY_PASSWORD')
}
defaults {
if (publishProjects.contains(project)) {
publications(project.name)
}
}
}
}
wrapper {
gradleVersion = "6.8.3"
distributionType = Wrapper.DistributionType.ALL
}