forked from newrelic/newrelic-telemetry-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
121 lines (111 loc) · 4.49 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
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"
version = project.findProperty("releaseVersion") as String
repositories {
mavenCentral()
jcenter()
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
}
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
listOf(":telemetry-core", ":telemetry", ":telemetry-http-okhttp").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") {
from(components["java"])
artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
pom {
name.set(project.name)
description.set("Used to send telemetry data to New Relic")
url.set("https://github.com/newrelic/newrelic-telemetry-sdk-java")
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/newrelic-telemetry-sdk-java.git")
connection.set("scm:git:[email protected]:newrelic/newrelic-telemetry-sdk-java.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> {
sign(publications["mavenJava"])
}
}
credentials {
username = project.properties["sonatypeUsername"] as String?
password = project.properties["sonatypePassword"] as String?
}
}
}
}
}
}