|
| 1 | +apply plugin: 'maven-publish' |
| 2 | +apply plugin: 'signing' |
| 3 | + |
| 4 | +publishing { |
| 5 | + boolean snapshotPublication = rootProject.version.endsWith("SNAPSHOT") |
| 6 | + |
| 7 | + repositories { |
| 8 | + maven { |
| 9 | + def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots" |
| 10 | + def releasesRepoUrl = "https://oss.sonatype.org/content/repositories/releases" |
| 11 | + url = snapshotPublication ? snapshotsRepoUrl : releasesRepoUrl |
| 12 | + name = "Sonatype" |
| 13 | + |
| 14 | + credentials { |
| 15 | + def uName = "" |
| 16 | + def passwd = "" |
| 17 | + int r |
| 18 | + def stream = new FileInputStream(fileOrTempFile(".credentials/sonatype-username.cred")) |
| 19 | + while ((r = stream.read()) != -1) uName = (uName + (char) r) |
| 20 | + stream = new FileInputStream(fileOrTempFile(".credentials/sonatype-password.cred")) |
| 21 | + while ((r = stream.read()) != -1) passwd = (passwd + (char) r) |
| 22 | + |
| 23 | + username uName |
| 24 | + password passwd |
| 25 | + } |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + publications { |
| 30 | + mavenJava(MavenPublication) { |
| 31 | + artifactId = 'vban-api' |
| 32 | + artifact jar |
| 33 | + version = rootProject.version |
| 34 | + |
| 35 | + pom { |
| 36 | + name = "VBAN-API" |
| 37 | + description = "Java Library for handling VB-Audio's VBAN API" |
| 38 | + inceptionYear = '2019' |
| 39 | + |
| 40 | + licenses { |
| 41 | + license { |
| 42 | + name = 'The Apache License, Version 2.0' |
| 43 | + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + developers { |
| 48 | + developer { |
| 49 | + id = "burdoto" |
| 50 | + name = "Tobias Burdow" |
| 51 | + email = "burdoto@outlook.com" |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + scm { |
| 56 | + connection = 'scm:git:https://github.com/burdoto/VBAN-API/VBAN-API.git' |
| 57 | + developerConnection = 'scm:git:git@github.com:burdoto/VBAN-API.git' |
| 58 | + url = 'https://github.com/burdoto/VBAN-API' |
| 59 | + } |
| 60 | + |
| 61 | + issueManagement { |
| 62 | + system = 'GitHub' |
| 63 | + url = 'https://github.com/burdoto/VBAN-API/issues' |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +signing { |
| 71 | + if (new File(".credentials/sonatype-password.cred").exists()) { |
| 72 | + useGpgCmd() |
| 73 | + for (def pub : publishing.publications) |
| 74 | + sign pub |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +static File fileOrTempFile(String name) { |
| 79 | + def file = new File(name) |
| 80 | + if (file.exists()) return file |
| 81 | + return File.createTempFile(name, "") |
| 82 | +} |
0 commit comments