forked from gradle/gradle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
54 lines (47 loc) · 1.32 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
plugins {
java
`maven-publish`
}
group = "org.gradle.sample"
version = "1.0"
dependencies {
implementation("commons-collections:commons-collections:3.2.2")
}
repositories {
mavenCentral()
}
// tag::publish-modify-component[]
java {
withJavadocJar()
withSourcesJar()
}
val javaComponent = components["java"] as AdhocComponentWithVariants
javaComponent.withVariantsFromConfiguration(configurations["sourcesElements"]) {
skip()
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}
}
// end::publish-modify-component[]
// tag::repo-url-from-variable[]
// tag::repo-url-from-project-property[]
publishing {
repositories {
maven {
val releasesRepoUrl = layout.buildDirectory.dir("repos/releases")
val snapshotsRepoUrl = layout.buildDirectory.dir("repos/snapshots")
// end::repo-url-from-variable[]
url = uri(if (project.hasProperty("release")) releasesRepoUrl else snapshotsRepoUrl)
// end::repo-url-from-project-property[]
// tag::repo-url-from-variable[]
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
// tag::repo-url-from-project-property[]
}
}
}
// end::repo-url-from-project-property[]
// end::repo-url-from-variable[]