Skip to content

Commit 20d0cda

Browse files
committed
Configure remoteapi/java to be able to build and publish on its own
SVN r65357 |2020-04-14 20:18:55 +0000
1 parent 0fcf6c7 commit 20d0cda

File tree

8 files changed

+364
-20
lines changed

8 files changed

+364
-20
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
java/README.md -text
33
java/build.gradle -text
44
java/gradle.properties -text
5+
java/gradle/wrapper/gradle-wrapper.jar -text
6+
java/gradle/wrapper/gradle-wrapper.properties -text
7+
java/gradlew -text
8+
java/gradlew.bat -text
9+
java/settings.gradle -text
510
java/src/META-INF/services/java.sql.Driver -text
611
java/src/log4j.xml -text
712
java/src/org/labkey/remoteapi/ApiKeyCredentialsProvider.java -text

java/build.gradle

Lines changed: 80 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,56 @@ import org.labkey.gradle.plugin.LabKey
22
import org.labkey.gradle.util.BuildUtils
33
import org.labkey.gradle.util.GroupNames
44

5+
buildscript {
6+
repositories {
7+
jcenter()
8+
maven {
9+
url "${artifactory_contextUrl}/plugins-release"
10+
}
11+
if (gradlePluginsVersion.contains("SNAPSHOT"))
12+
{
13+
maven {
14+
url "${artifactory_contextUrl}/plugins-snapshot-local"
15+
}
16+
}
17+
}
18+
dependencies {
19+
classpath "org.labkey.build:gradlePlugins:${gradlePluginsVersion}"
20+
// N.B. We use the "old-fashioned" way of applying the artifactory plugin because if we use
21+
// the plugins block below and specify a version number, the following error happens if building
22+
// in conjunction with LabKey server (i.e., when including this project in the server's build.gradle
23+
// Error resolving plugin [id: 'com.jfrog.artifactory', version: '4.13.0', apply: false]
24+
// > Plugin request for plugin already on the classpath must not include a version
25+
// We could instead include the plugin without a version number, which would work until
26+
// some change in the latest version of the plugin came along that we aren't compatible with.
27+
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:${artifactoryPluginVersion}"
28+
}
29+
}
30+
531
plugins {
632
id 'java-library'
733
id 'java'
834
id 'maven-publish'
35+
id "com.jfrog.bintray" version "${bintrayPluginVersion}" apply false
36+
}
37+
38+
repositories {
39+
jcenter()
40+
maven {
41+
url "${artifactory_contextUrl}/libs-release"
42+
43+
if (hasProperty('artifactory_user') && hasProperty('artifactory_password'))
44+
{
45+
credentials {
46+
username = artifactory_user
47+
password = artifactory_password
48+
}
49+
authentication {
50+
basic(BasicAuthentication)
51+
// enable preemptive authentication to get around https://www.jfrog.com/jira/browse/RTFACT-4434
52+
}
53+
}
54+
}
955
}
1056

1157
buildDir = new File(project.rootProject.buildDir, "/remoteapi/java")
@@ -14,7 +60,7 @@ def artifactPrefix = 'labkey-client-api'
1460

1561
group "org.labkey.api"
1662
//Issue #39336 (comment 4): Updating to use SNAPSHOT until migration to git
17-
version "1.1.1-SNAPSHOT"
63+
version "1.2.0-SNAPSHOT"
1864

1965
dependencies {
2066
api "org.apache.httpcomponents:httpmime:${httpmimeVersion}"
@@ -165,24 +211,39 @@ project.afterEvaluate {
165211
}
166212
}
167213

168-
// Comment this out for now as we don't need to publish snapshot versions of the remoteapi jar file all the time since
169-
// we are referencing the release version in our builds and this code changes infrequently. Without a modification
170-
// to this file. this publishing fails when the LabKey version is a release version because the repository set for
171-
// publishing is a release repository, but the version set in this file will be a SNAPSHOT version. Could probalby be fixed
172-
// with some configuration work, but it will be easier once this is moved to its own git repository.
173-
// if (BuildUtils.shouldPublish(project))
174-
// {
175-
// project.artifactoryPublish {
176-
// project.tasks.each {
177-
// if (it instanceof Jar)
178-
// {
179-
// dependsOn it
180-
// }
181-
// }
182-
//// dependsOn pomFileTask
183-
// publications('libs')
184-
// }
185-
// }
214+
if (project.hasProperty('doClientApiPublishing'))
215+
{
216+
apply plugin: 'com.jfrog.artifactory'
217+
artifactory {
218+
contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver
219+
publish {
220+
repository {
221+
repoKey = BuildUtils.getRepositoryKey(project)
222+
if (project.hasProperty('artifactory_user') && project.hasProperty('artifactory_password'))
223+
{
224+
username = artifactory_user
225+
password = artifactory_password
226+
}
227+
maven = true
228+
}
229+
defaults
230+
{
231+
publishPom = true
232+
publishIvy = false
233+
}
234+
}
235+
}
236+
237+
project.artifactoryPublish {
238+
project.tasks.each {
239+
if (it instanceof Jar)
240+
{
241+
dependsOn it
242+
}
243+
}
244+
publications('libs')
245+
}
246+
}
186247

187248
}
188249
project.model {

java/gradle.properties

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1+
# the URL for the artifact repository where our build plugins are housed
2+
# as well as the build artifacts. (Be careful not to include a trailing slash
3+
# in the context URL or you will get a 500 error from artifactory.)
4+
artifactory_contextUrl=https://artifactory.labkey.com/artifactory
5+
16
# The source and target versions of Java for compilation tasks
27
# We target a very old version to stay compatible with SAS. Our SAS macros wrap the Java remoteapi and run in the
38
# SAS-bundled private JRE. Starting with SAS 9.4M6 (released in late 2018), the SAS Private JRE is based on Java 8.
49
# https://support.sas.com/en/documentation/third-party-software-reference/9-4/support-for-java.html
510
sourceCompatibility=1.8
611
targetCompatibility=1.8
712

13+
artifactoryPluginVersion=4.13.0
14+
bintrayPluginVersion=1.8.4
15+
gradlePluginsVersion=1.10.3
16+
817
fluentHcVersion=4.3.5
918

19+
httpmimeVersion=4.5.3
20+
21+
jsonSimpleVersion=1.1
22+
23+
opencsvVersion=2.3
24+
1025
#If iterating on the java client api and deploying it to a non-LabKey directory, uncomment and set this property (or set at command line),
1126
# and run the 'deployFatJar' task to create the jar with all dependencies and deploy it to the specified target. e.g., c:/somewhere/lib
12-
#javaClientDir=
27+
#javaClientDir=
28+
#buildFromSource=false
54.9 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

java/gradlew

Lines changed: 172 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)