-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
213 lines (175 loc) · 6.48 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// NEW build file
// a mix of various kotlin conventions and styles
// some dependencies are implicit, unfortunately, and that will have to be remedied
// ISSUE: POM not created in root project...but may be after maven-local-publish.....
plugins {
id("java-library")
id("maven-publish")
id("signing")
}
allprojects {
group = "net.xyzsd.plurals"
version = "41" // version should be == CLDR version for clarity
// use 'rootProject.name' (from settings.gradle.kts) for base name
repositories {
mavenCentral()
gradlePluginPortal()
}
// to create reproducible builds ...
tasks.withType<AbstractArchiveTask>().configureEach {
isReproducibleFileOrder = true
isPreserveFileTimestamps = false
dirMode = 775
fileMode = 664
archiveVersion.set("${project.version}")
}
}
configure(subprojects) {
apply<MavenPublishPlugin>()
apply<JavaLibraryPlugin>()
apply<SigningPlugin>()
pluginManager.withPlugin("java-library") {
configure<JavaPluginExtension> {
withSourcesJar()
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
}
}
tasks.withType<JavaCompile>().configureEach {
options.isIncremental = false
options.encoding = "UTF-8" // this is important, particularly for tests
}
tasks.withType<Javadoc>().configureEach {
options.encoding = "UTF-8"
}
}
// todo : put below in tasks block, with artifacts {} block
// create aggregate artifacts:
// 1) source (w/o tests)
// 2) jar (w/o generator)
// 3) javadocs
// create aggregated javadocs
val agroDoc by tasks.registering(Javadoc::class) {
dependsOn(":shared:build")
dependsOn(":plurals:build")
dependsOn(":maker:executeMaker")
description = "Aggregated Javadocs"
group = JavaBasePlugin.DOCUMENTATION_GROUP
title = "${rootProject.name} API (complete) version ${project.version}"
val javadocOptions = options as CoreJavadocOptions
javadocOptions.addStringOption("Xdoclint:none", "-quiet")
options.encoding = "UTF-8"
val sourceSets = allprojects
.mapNotNull { it.extensions.findByType<SourceSetContainer>() }
.map { it.named("main") }
classpath = files(sourceSets.map { set -> set.map { it.output + it.compileClasspath } })
setSource(sourceSets.map { set -> set.map { it.allJava } })
setDestinationDir(file("$buildDir/javadoc"))
}
// archive name structure: [archiveBaseName]-[archiveAppendix]-[archiveVersion]-[archiveClassifier].[archiveExtension]
val agroDocJar by tasks.registering(Jar::class) {
dependsOn("agroDoc")
group = JavaBasePlugin.DOCUMENTATION_GROUP
archiveBaseName.set(rootProject.name)
archiveVersion.set("${project.version}")
archiveClassifier.set("javadoc")
from(agroDoc)
}
// see:
// https://stackoverflow.com/questions/52596968/build-source-jar-with-gradle-kotlin-dsl
val agroSourcesJar by tasks.creating(Jar::class) {
description = "Aggregated Source"
archiveClassifier.set("sources")
dependsOn(":maker:executeMaker")
dependsOn(":plurals:compileJava")
// brittle... but works
from("${project.rootDir}/${project(":shared").name}/src/main/java")
from("${project.rootDir}/${project(":plurals").name}/src/main/java")
from("${project.rootDir}/${project(":maker").name}/src/main/java")
from("${project.rootDir}/${project(":maker").name}/build/generated-source/main")
}
tasks.withType<Jar>().configureEach {
// using automatic modules for now
manifest {
val moduleName = "${rootProject.group}.${project.name}";
attributes.set("Automatic-Module-Name", moduleName)
}
includeEmptyDirs = false
// we only want classes from 'plurals' and 'shared'
from("${project(":shared").buildDir}/classes/java/main/")
from("${project(":plurals").buildDir}/classes/java/main/")
from("$projectDir/LICENSE")
}
// put in tasks block
artifacts {
archives(agroDocJar)
archives(agroSourcesJar)
archives(tasks.jar)
}
// if not working ('no actions') try publish to maven local for testing
configure<PublishingExtension> {
publications {
val main by creating(MavenPublication::class) {
artifact(agroDocJar)
artifact(agroSourcesJar)
from(components["java"])
pom {
artifactId = project.name
name.set("CLDR Plural Rules")
description.set("CLDR-based pluralization handling for Java")
url.set("https://github.com/xyzsd/cldr-plural-rules")
inceptionYear.set("2020")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
comments.set("A business-friendly OSS license")
}
license {
name.set("The MIT License")
url.set("https://opensource.org/licenses/MIT")
comments.set("A GPL/LGPL compatible OSS license")
}
}
developers {
developer {
id.set("xyzsd")
name.set("Zach Del")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:git://github.com/xyzsd/cldr-plural-rules.git")
developerConnection.set("scm:git:ssh://[email protected]:xyzsd/cldr-plural-rules.git")
url.set("")
}
}
}
}
repositories {
maven {
name = "OSSRH"
setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2")
credentials {
// obtained from gradle.properties in GRADLE_USER_HOME
credentials(PasswordCredentials::class)
}
}
}
}
// if 'no signatory' error, make sure GRADLE_USER_HOME is set
// to point to the gradle.properties file containing keyID/password/etc.
configure<SigningExtension> {
val publishing: PublishingExtension by project
sign(publishing.publications)
}
/*
tasks.withType<PublishToMavenLocal>().configureEach {
doLast {
copy {
// from("${buildDir}/publications/main/pom-default.xml")
to("${buildDir}/libs/${project.name}-${version}.pom")
}
}
}
*/