This repository has been archived by the owner on Jan 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
build.gradle.kts
133 lines (122 loc) · 5.3 KB
/
build.gradle.kts
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
buildscript {
dependencies {
classpath("gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.8")
}
}
plugins {
java
}
apply(plugin = "java")
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = "com.github.sherter.google-java-format")
allprojects {
group = "com.newrelic.telemetry"
val release: String? by project
version = project.findProperty("baseVersion") as String + if("true" == release) "" else "-SNAPSHOT"
repositories {
mavenCentral()
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
// this is only needed for the working against unreleased otel-java snapshots
maven("https://oss.jfrog.org/artifactory/oss-snapshot-local")
}
tasks.withType<JavaCompile>().configureEach {
// compile all projects with Java 8
javaCompiler.set(javaToolchains.compilerFor {
languageVersion.set(JavaLanguageVersion.of(8))
})
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
// run tests in all projects with Java 11
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(11))
})
}
}
listOf(":opentelemetry-exporters-newrelic", ":opentelemetry-exporters-newrelic-auto").forEach {
project(it) {
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "signing")
tasks {
val taskScope = this
val sources = sourceSets
val sourcesJar by creating(Jar::class) {
dependsOn(JavaPlugin.CLASSES_TASK_NAME)
archiveClassifier.set("sources")
from(sources.main.get().allSource)
}
val javadocJar by creating(Jar::class) {
dependsOn(JavaPlugin.JAVADOC_TASK_NAME)
archiveClassifier.set("javadoc")
from(taskScope.javadoc)
}
val jar: Jar by taskScope
jar.apply {
manifest.attributes["Implementation-Version"] = project.version
manifest.attributes["Implementation-Vendor"] = "New Relic, Inc"
}
}
val useLocalSonatype = project.properties["useLocalSonatype"] == "true"
configure<PublishingExtension> {
publications {
create<MavenPublication>("mavenJava") {
artifact(file("$buildDir/libs/${project.name}-${project.version}.jar"))
artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
pom {
name.set(project.name)
description.set("Open Telemetry Java Exporters that send data to New Relic ingest.")
url.set("https://github.com/newrelic/opentelemetry-exporters-newrelic")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("newrelic")
name.set("New Relic")
email.set("[email protected]")
}
}
scm {
url.set("[email protected]:newrelic/opentelemetry-exporters-newrelic.git")
connection.set("scm:[email protected]:newrelic/opentelemetry-exporters-newrelicc.git")
}
}
}
}
repositories {
maven {
if (useLocalSonatype) {
val releasesRepoUrl = uri("http://localhost:8081/repository/maven-releases/")
val snapshotsRepoUrl = uri("http://localhost:8081/repository/maven-snapshots/")
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
} else {
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotsRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
configure<SigningExtension> {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publications["mavenJava"])
}
}
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
}
}
}