-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
244 lines (220 loc) · 7.83 KB
/
build.gradle
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
import org.labkey.gradle.plugin.LabKey
import org.labkey.gradle.util.GroupNames
import org.labkey.gradle.util.PomFileHelper
buildscript {
repositories {
mavenCentral {
content {
excludeGroupByRegex "org\\.labkey.*"
}
}
maven {
url = "${artifactory_contextUrl}/plugins-release-no-proxy"
mavenContent {
releasesOnly()
}
content {
includeGroup "org.labkey.build"
includeGroup "org.labkey.versioning"
}
}
if (gradlePluginsVersion.contains("SNAPSHOT"))
{
mavenLocal()
maven {
url = "${artifactory_contextUrl}/plugins-snapshot-local"
mavenContent {
snapshotsOnly()
}
content {
includeGroup "org.labkey.build"
includeGroup "org.labkey.versioning"
}
}
}
}
dependencies {
classpath "org.labkey.build:gradlePlugins:${gradlePluginsVersion}"
}
}
plugins {
id 'java-library'
id 'java'
id 'maven-publish'
id 'signing'
}
repositories {
mavenCentral()
maven {
url = "${artifactory_contextUrl}/libs-release-no-proxy"
if (hasProperty('artifactory_user') && hasProperty('artifactory_password'))
{
credentials {
username = artifactory_user
password = artifactory_password
}
authentication {
basic(BasicAuthentication)
// enable preemptive authentication to get around https://www.jfrog.com/jira/browse/RTFACT-4434
}
}
mavenContent {
releasesOnly()
}
}
}
group = "org.labkey.api"
version = "6.3.0-SNAPSHOT"
dependencies {
api "org.json:json:${jsonObjectVersion}"
api "org.apache.httpcomponents.client5:httpclient5:${httpclient5Version}"
api "org.apache.httpcomponents.core5:httpcore5:${httpcore5Version}"
implementation "commons-logging:commons-logging:${commonsLoggingVersion}"
implementation "commons-codec:commons-codec:${commonsCodecVersion}"
}
jar {
sourceCompatibility = project.sourceCompatibility
targetCompatibility = project.targetCompatibility
sourceSets
{
main {
java {
srcDirs = ['src']
}
}
}
}
base {
libsDirectory = layout.buildDirectory.dir('jar')
}
project.tasks.withType(JavaCompile).configureEach {
sourceCompatibility = project.ext.sourceCompatibility
targetCompatibility = project.ext.targetCompatibility
}
// The maven-publish plugin will, by default, publish a metadata file alongside the other
// artifacts. Its extension is .module, which might get confused with our own .module files.
// We could publish these files for everything but .module files, but for now we disable always
// https://docs.gradle.org/current/userguide/publishing_gradle_module_metadata.html
project.tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
project.tasks.register("fatJar", Jar) {
Jar jar ->
jar.description = "Generate single jar file containing the api and all its dependent classes"
jar.group = GroupNames.BUILD
jar.from sourceSets.main.output
jar.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
jar.from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
jar.setArchiveVersion(project.version)
jar.archiveClassifier.set(LabKey.FAT_JAR_CLASSIFIER)
jar.dependsOn project.tasks.jar
}
if (project.hasProperty('javaClientDir'))
{
project.tasks.register('deployFatJar', Copy) {
description = "Generate java client 'all' jar file and deploy to a given directory. For example, a host app other than LabKey Server"
from fatJar
into project.javaClientDir
}
}
project.tasks.register('javadocJar', Jar) {
Jar jar ->
jar.description = "Generate jar file of javadoc files"
jar.from project.tasks.javadoc.destinationDir
jar.group = GroupNames.DISTRIBUTION
jar.archiveClassifier.set(LabKey.JAVADOC_CLASSIFIER)
jar.dependsOn project.tasks.javadoc
}
project.tasks.register('sourcesJar', Jar) {
Jar jar ->
jar.description = "Generate jar file of source files"
jar.from project.sourceSets.main.allJava
jar.group = GroupNames.DISTRIBUTION
jar.archiveClassifier.set(LabKey.SOURCES_CLASSIFIER)
}
project.artifacts {
archives project.tasks.sourcesJar
archives project.tasks.javadocJar
archives project.tasks.fatJar
}
def libDescription = "The client-side library for Java developers is a separate JAR from the LabKey Server code base. It can be used by any Java program, including another Java web application."
project.publishing {
publications {
libs(MavenPublication) {
groupId = project.group
from components.java
artifact(sourcesJar) {
classifier = LabKey.SOURCES_CLASSIFIER
}
artifact(javadocJar) {
classifier = LabKey.JAVADOC_CLASSIFIER
}
artifact(fatJar) {
classifier = LabKey.FAT_JAR_CLASSIFIER
}
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = "LabKey Server Java Client API"
description = libDescription
url = PomFileHelper.LABKEY_ORG_URL
developers PomFileHelper.getLabKeyTeamDevelopers()
licenses PomFileHelper.getApacheLicense()
organization PomFileHelper.getLabKeyOrganization()
scm {
connection = 'scm:git:https://github.com/LabKey/labkey-api-java'
developerConnection = 'scm:git:https://github.com/LabKey/labkey-api-java'
url = 'scm:git:https://github.com/LabKey/labkey-api-java/labkey-client-api'
}
}
}
}
repositories {
if (project.hasProperty("sonatype_staging_url") && project.hasProperty("sonatype_username") && project.hasProperty("sonatype_password"))
{
maven {
url = sonatype_staging_url
credentials {
username = sonatype_username
password = sonatype_password
}
}
}
if (project.hasProperty('artifactory_user') && project.hasProperty('artifactory_password'))
{
maven {
url = project.version.contains("SNAPSHOT") ? "${artifactory_contextUrl}/libs-snapshot-local" : "${artifactory_contextUrl}/libs-release-local"
credentials {
username = artifactory_user
password = artifactory_password
}
authentication {
basic(BasicAuthentication)
// enable preemptive authentication to get around https://www.jfrog.com/jira/browse/RTFACT-4434
}
content {
includeGroup "org.labkey"
includeGroup "org.labkey.api"
includeGroup "org.labkey.module"
}
}
}
}
}
project.model {
tasks.publishLibsPublicationToMavenLocal {
enabled = false
}
}
if (project.hasProperty("signing.keyId") && project.hasProperty("signing.password") || project.hasProperty("signing.secretKeyRingFile"))
{
signing {
sign publishing.publications.libs
}
}