forked from awslabs/disco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
158 lines (139 loc) · 6.07 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
//common features available to the entire project
//TODO specify the versions of ByteBuddy and ASM in here, since they are used in a few places.
plugins {
id("com.github.johnrengelman.shadow") version "5.1.0" apply false
java
`maven-publish`
}
subprojects {
apply<JavaPlugin>()
version = "0.9.1"
repositories {
mavenCentral()
}
dependencies {
testCompile("org.mockito", "mockito-core", "1.+")
}
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
}
tasks {
pluginManager.withPlugin("com.github.johnrengelman.shadow") {
named<ShadowJar>("shadowJar") {
//suppress the "-all" suffix on the jar name, simply replace the default built jar instead (disco-java-agent-web-plugin-x.y.z.jar)
archiveClassifier.set(null as String?)
//Must relocate both of these inner dependencies of the Disco agent, to avoid conflicts in your customer's application
relocate("org.objectweb.asm", "software.amazon.disco.agent.jar.asm")
relocate("net.bytebuddy", "software.amazon.disco.agent.jar.bytebuddy")
}
//once gradle has made its default jar, follow up by producing the shadow/uber jar
assemble {
dependsOn(named<ShadowJar>("shadowJar"))
}
named<ShadowJar>("shadowJar") {
dependsOn(jar)
}
}
}
//we publish everything except example subprojects to maven. Projects which desire to be published to maven express the intent
//via a property called simply 'maven' in their gradle.properties file (if it exists at all).
//Each package to be published still needs a small amount of boilerplate to express whether is is a 'normal'
//library which expresses its dependencies, or a shadowed library which includes and hides them. For a normal one
//e.g. Core or Web, that boilerplate may look like:
// configure<PublishingExtension> {
// publications {
// named<MavenPublication>("maven") {
// from(components["java"])
// }
// }
// }
//
// whereas a shadowed artifact would be declared along the lines of:
//
// configure<PublishingExtension> {
// publications {
// named<MavenPublication>("maven") {
// artifact(tasks.jar.get())
// }
// }
// }
//
//which declares the jar and the jar alone as the artifact, suppressing the default behaviour of gathering dependency info
//
//TODO: find a way to express this just once in the block below, probably by inspecting the existence or absence
//of the shadow plugin, or the ShadowJar task. So far attempts to consolidate this logic have not succeeded, hence
//the current need for the above boilerplate.
//
//TODO: apply some continuous integration rules to publish to Maven automatically when e.g. version number increases
//
//Publication to local Maven is simply "./gradlew publishToMavenLocal"
if (hasProperty("maven")) {
apply(plugin = "maven-publish")
//create a task to publish our sources
tasks.register<Jar>("sourcesJar") {
from(sourceSets.main.get().allJava)
archiveClassifier.set("sources")
}
//create a task to publish javadoc
tasks.register<Jar>("javadocJar") {
from(tasks.javadoc)
archiveClassifier.set("javadoc")
}
//defer maven publish until the assemble task has finished, giving time for shadowJar to complete, if it is present
tasks.withType<AbstractPublishToMaven> {
dependsOn(tasks.assemble)
}
//all our maven publications have similar characteristics, declare as much as possible here at the top level
configure<PublishingExtension> {
repositories {
maven {
}
}
publications {
create<MavenPublication>("maven") {
artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
groupId = "software.amazon.disco"
pom {
name.set(groupId + ":" + artifactId)
description.set("Amazon Disco aspect oriented distributed systems comprehension toolkit")
url.set("https://github.com/awslabs/disco")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("connellp")
name.set("Paul Connell")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:git://github.com/awslabs/disco.git")
developerConnection.set("scm:git:ssh://github.com/awslabs/disco.git")
url.set("https://github.com/awslabs/disco")
}
}
}
}
}
}
}