forked from opensearch-project/opensearch-migrations
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
162 lines (144 loc) · 5.54 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
plugins {
id "com.dorongold.task-tree" version "2.1.1"
id 'io.freefair.lombok' version '8.6' apply false
id "com.diffplug.spotless" version '6.25.0'
id 'me.champeau.jmh' version '0.7.2' apply false
}
task buildDockerImages() {
dependsOn(':TrafficCapture:dockerSolution:buildDockerImages')
dependsOn(':DocumentsFromSnapshotMigration:buildDockerImages')
}
spotless {
format 'misc', {
target '**/*.gradle', '.gitattributes', '.gitignore'
targetExclude '**/build/**'
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
yaml {
target '**/*.yml'
targetExclude '**/node_modules/**', '**/opensearch-cluster-cdk/**', '**/cdk.out/**'
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}
subprojects {
apply plugin: 'jacoco'
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: "com.diffplug.spotless"
spotless {
java {
target "**/*.java"
targetExclude '**/build/**', ".gradle/**"
importOrder(
'java|javax',
'io.opentelemetry|com.google|com.fasterxml|org.apache|org.hamcrest|org.junit',
'org.opensearch',
'',
'\\#java|\\#org.apache|\\#org.hamcrest|\\#org.opensearch|\\#'
)
indentWithSpaces()
endWithNewline()
removeUnusedImports()
}
}
tasks.withType(Test) {
// Getting javadoc to compile is part of the test suite to ensure we are able to publish our artifacts
dependsOn project.javadoc
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
def excludedProjectPaths = [
':RFS',
':TrafficCapture',
':TrafficCapture:dockerSolution',
]
if (!(project.path in excludedProjectPaths)) {
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact javadocJar
artifact sourcesJar
group = 'org.opensearch.migrations.trafficcapture'
// support -Dbuild.version, but include default
version = System.getProperty("build.version", "0.1.0")
// support -Dbuild.snapshot=false, but default to true
if (System.getProperty("build.snapshot", "true") == "true") {
version += "-SNAPSHOT"
}
pom {
name = project.name
description = 'Everything opensearch migrations'
url = 'http://github.com/opensearch-project/opensearch-migrations'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
name = "OpenSearch"
url = "https://github.com/opensearch-project/opensearch-migrations"
}
}
scm {
connection = "scm:git@github.com:opensearch-project/opensearch-migrations.git"
developerConnection = "scm:git@github.com:opensearch-project/opensearch-migrations.git"
url = "git@github.com:opensearch-project/opensearch-migrations.git"
}
}
// Suppress POM metadata warnings for test fixtures
suppressPomMetadataWarningsFor('testFixturesApiElements')
suppressPomMetadataWarningsFor('testFixturesRuntimeElements')
}
}
repositories {
maven { url = "${rootProject.buildDir}/repository"}
maven {
url "https://aws.oss.sonatype.org/content/repositories/snapshots"
name = 'staging'
}
}
}
}
// Utility task to allow copying required libraries into a 'dependencies' folder for security scanning
tasks.register('copyDependencies', Sync) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from configurations.runtimeClasspath
into "${buildDir}/dependencies"
}
jacocoTestReport {
reports {
xml.required = true
xml.destination file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
html.required = true
html.destination file("${buildDir}/reports/jacoco/test/html")
}
}
}
task listPublishedArtifacts {
doLast {
subprojects.each { proj ->
def publishingExtension = proj.extensions.findByType(PublishingExtension)
if (publishingExtension) {
publishingExtension.publications.each { publication ->
if (publication instanceof MavenPublication) {
println "${publication.groupId}.${publication.artifactId}"
}
}
}
}
}
}