|
1 | 1 | plugins { |
2 | 2 | java |
| 3 | + `maven-publish` |
3 | 4 | signing |
4 | 5 | id("org.jreleaser") version "1.17.0" |
5 | 6 | } |
@@ -57,6 +58,98 @@ tasks.jar { |
57 | 58 | } |
58 | 59 | } |
59 | 60 |
|
| 61 | +// https://docs.gradle.org/current/userguide/publishing_maven.html |
| 62 | +publishing { |
| 63 | + publications { |
| 64 | + create<MavenPublication>("mavenJava") { |
| 65 | + |
| 66 | + // dependencies |
| 67 | + from(components["java"]) |
| 68 | + |
| 69 | + versionMapping { |
| 70 | + usage("java-api") { |
| 71 | + fromResolutionOf("runtimeClasspath") |
| 72 | + } |
| 73 | + usage("java-runtime") { |
| 74 | + fromResolutionResult() |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + pom { |
| 79 | + name.set("FactSet Trading event-driven client library for Java") |
| 80 | + description.set("Event-driven api client for the FactSet Trading API") |
| 81 | + url.set("https://github.com/factset/enterprise-sdk-eventdriven-factsettrading-java") |
| 82 | + licenses { |
| 83 | + license { |
| 84 | + name.set("The Apache License, Version 2.0'") |
| 85 | + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + developers { |
| 90 | + developer { |
| 91 | + id.set("enterprisesdk") |
| 92 | + organization.set("FactSet") |
| 93 | + organizationUrl.set("https://developer.factset.com") |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + scm { |
| 98 | + connection.set("scm:git:git://github.com/factset/enterprise-sdk-eventdriven-factsettrading-java.git") |
| 99 | + developerConnection.set("scm:git:ssh://factset/enterprise-sdk-eventdriven-factsettrading-java.git") |
| 100 | + url.set("https://github.com/factset/enterprise-sdk-eventdriven-factsettrading-java/") |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + repositories { |
| 107 | + maven { |
| 108 | + var releasesRepoUrlEnv = System.getenv("MAVEN_RELEASES_URL") |
| 109 | + var snapshotsRepoUrlEnv = System.getenv("MAVEN_SNAPSHOTS_URL") |
| 110 | + var usernameEnv = System.getenv("JRELEASER_NEXUS2_USERNAME") |
| 111 | + var passwordEnv = System.getenv("JRELEASER_NEXUS2_PASSWORD") |
| 112 | + |
| 113 | + if (releasesRepoUrlEnv == null) { |
| 114 | + releasesRepoUrlEnv = "" |
| 115 | + project.logger.error("MAVEN_RELEASES_URL not set") |
| 116 | + } |
| 117 | + |
| 118 | + if (snapshotsRepoUrlEnv == null) { |
| 119 | + snapshotsRepoUrlEnv = "" |
| 120 | + project.logger.error("MAVEN_SNAPSHOTS_URL not set") |
| 121 | + } |
| 122 | + |
| 123 | + if (usernameEnv == null) { |
| 124 | + usernameEnv = "" |
| 125 | + project.logger.error("MAVEN_USERNAME not set") |
| 126 | + } |
| 127 | + |
| 128 | + if (passwordEnv == null) { |
| 129 | + passwordEnv = "" |
| 130 | + project.logger.error("MAVEN_PASSWORD not set") |
| 131 | + } |
| 132 | + |
| 133 | + val releasesRepoUrl = uri(releasesRepoUrlEnv) |
| 134 | + val snapshotsRepoUrl = uri(snapshotsRepoUrlEnv) |
| 135 | + url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl |
| 136 | + |
| 137 | + credentials { |
| 138 | + username = usernameEnv |
| 139 | + password = passwordEnv |
| 140 | + } |
| 141 | + |
| 142 | + authentication { |
| 143 | + create<BasicAuthentication>("basic") |
| 144 | + } |
| 145 | + } |
| 146 | + } |
| 147 | + |
| 148 | + signing { |
| 149 | + sign(publications["mavenJava"]) |
| 150 | + } |
| 151 | +} |
| 152 | + |
60 | 153 | configure<org.jreleaser.gradle.plugin.JReleaserExtension> { |
61 | 154 | gitRootSearch = true |
62 | 155 | project { |
|
0 commit comments