|
| 1 | +import org.labkey.gradle.util.BuildUtils |
| 2 | +import org.labkey.gradle.util.GroupNames |
| 3 | +import org.labkey.gradle.util.PomFileHelper |
| 4 | +import org.labkey.gradle.plugin.extension.TeamCityExtension |
| 5 | + |
| 6 | +buildscript { |
| 7 | + repositories { |
| 8 | + jcenter() |
| 9 | + maven { |
| 10 | + url "${artifactory_contextUrl}/plugins-release" |
| 11 | + } |
| 12 | + if (gradlePluginsVersion.contains("SNAPSHOT")) |
| 13 | + { |
| 14 | + maven { |
| 15 | + url "${artifactory_contextUrl}/plugins-snapshot-local" |
| 16 | + } |
| 17 | + } |
| 18 | + } |
| 19 | + dependencies { |
| 20 | + classpath "org.labkey.build:gradlePlugins:${gradlePluginsVersion}" |
| 21 | + // N.B. We use the "old-fashioned" way of applying the artifactory plugin because if we use |
| 22 | + // the plugins block below and specify a version number, the following error happens if building |
| 23 | + // in conjunction with LabKey server (i.e., when including this project in the server's build.gradle |
| 24 | + // Error resolving plugin [id: 'com.jfrog.artifactory', version: '4.13.0', apply: false] |
| 25 | + // > Plugin request for plugin already on the classpath must not include a version |
| 26 | + // We could instead include the plugin without a version number, which would work until |
| 27 | + // some change in the latest version of the plugin came along that we aren't compatible with. |
| 28 | + classpath "org.jfrog.buildinfo:build-info-extractor-gradle:${artifactoryPluginVersion}" |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +plugins { |
| 33 | + id 'java' |
| 34 | + id 'maven-publish' |
| 35 | +} |
| 36 | + |
| 37 | +repositories { |
| 38 | + maven { |
| 39 | + url "${artifactory_contextUrl}/libs-release" |
| 40 | + |
| 41 | + if (hasProperty('artifactory_user') && hasProperty('artifactory_password')) |
| 42 | + { |
| 43 | + credentials { |
| 44 | + username = artifactory_user |
| 45 | + password = artifactory_password |
| 46 | + } |
| 47 | + authentication { |
| 48 | + basic(BasicAuthentication) |
| 49 | + // enable preemptive authentication to get around https://www.jfrog.com/jira/browse/RTFACT-4434 |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +// TODO remove once client-api distribution no longer requires this |
| 56 | +buildDir = new File(project.rootProject.buildDir, "/remoteapi/sas") |
| 57 | + |
| 58 | +group 'org.labkey.api' |
| 59 | + |
| 60 | +version '1.0.0-SNAPSHOT' |
| 61 | + |
| 62 | +// We add the TeamCity extension here if it doesn't exist because we will use the build |
| 63 | +// number property from TeamCity in the distribution artifact names, if present. |
| 64 | +TeamCityExtension teamCityExt = project.getExtensions().findByType(TeamCityExtension.class) |
| 65 | +if (TeamCityExtension.isOnTeamCity(project) && teamCityExt == null) |
| 66 | + project.extensions.create("teamCity", TeamCityExtension, project) |
| 67 | + |
| 68 | +configurations { |
| 69 | + remoteApi |
| 70 | +} |
| 71 | + |
| 72 | +BuildUtils.addLabKeyDependency(project: project, config: "remoteApi", depProjectPath: BuildUtils.getRemoteApiProjectPath(gradle), depVersion: project.labkeyClientApiVersion) |
| 73 | + |
| 74 | +// TODO change name and destination once client-api no longer requires this |
| 75 | +project.task("distribution", |
| 76 | + group: GroupNames.DISTRIBUTION, |
| 77 | + description: "Create a zip file for the SAS API client distribution containing the SAS macros, java client api jar and its dependencies", |
| 78 | + type: Zip, |
| 79 | + {Zip zip -> |
| 80 | + zip.from (project.file("macros")) |
| 81 | + zip.from project.configurations.remoteApi |
| 82 | + zip.into zip.archiveBaseName |
| 83 | + zip.destinationDirectory = project.rootProject.file("dist/client-api/sas") |
| 84 | + } |
| 85 | +) |
| 86 | + |
| 87 | +artifacts { |
| 88 | + archives project.tasks.distribution |
| 89 | +} |
| 90 | + |
| 91 | +project.afterEvaluate { |
| 92 | + project.publishing { |
| 93 | + publications { |
| 94 | + libs(MavenPublication) { |
| 95 | + groupId = project.group |
| 96 | + artifact project.tasks.distribution |
| 97 | + pom { |
| 98 | + name = "LabKey Server SAS Client API" |
| 99 | + description = "Library of macros for use in accessing LabKey Server via SAS" |
| 100 | + url = PomFileHelper.LABKEY_ORG_URL |
| 101 | + developers PomFileHelper.getLabKeyTeamDevelopers() |
| 102 | + licenses PomFileHelper.getApacheLicense() |
| 103 | + organization PomFileHelper.getLabKeyOrganization() |
| 104 | + scm { |
| 105 | + connection = 'scm:git:https://github.com/LabKey/labkey-api-java/sas' |
| 106 | + developerConnection = 'scm:git:https://github.com/LabKey/labkey-api-java/sas' |
| 107 | + url = 'scm:git:https://github.com/LabKey/labkey-api-java/sas' |
| 108 | + } |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | + if (project.hasProperty('doClientApiPublishing')) |
| 114 | + { |
| 115 | + apply plugin: 'com.jfrog.artifactory' |
| 116 | + artifactory { |
| 117 | + contextUrl = "${artifactory_contextUrl}" //The base Artifactory URL if not overridden by the publisher/resolver |
| 118 | + publish { |
| 119 | + repository { |
| 120 | + repoKey = BuildUtils.getRepositoryKey(project) |
| 121 | + if (project.hasProperty('artifactory_user') && project.hasProperty('artifactory_password')) |
| 122 | + { |
| 123 | + username = artifactory_user |
| 124 | + password = artifactory_password |
| 125 | + } |
| 126 | + maven = true |
| 127 | + } |
| 128 | + defaults |
| 129 | + { |
| 130 | + publishPom = true |
| 131 | + publishIvy = false |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + |
| 136 | + project.artifactoryPublish { |
| 137 | + publications('libs') |
| 138 | + } |
| 139 | + } |
| 140 | + } |
| 141 | + project.model { |
| 142 | + tasks.publishLibsPublicationToMavenLocal { |
| 143 | + enabled = false |
| 144 | + } |
| 145 | + } |
| 146 | +} |
0 commit comments