From 1ecf0558a00bfda1433b8b07dcc891e57d5eb6b7 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Fri, 29 Jun 2018 12:40:22 +0200 Subject: [PATCH] Upload to S3 if `-PbuildNumber` is set, otherwise version is `foo.0-SNAPSHOT` published to local maven repo --- build.gradle | 52 +++++++++++++++++++++++++---------------------- gradle.properties | 1 + 2 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 gradle.properties diff --git a/build.gradle b/build.gradle index e00b131..59d3061 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,10 @@ import groovy.io.FileType apply plugin: 'java-library' -apply plugin: 'maven' +apply plugin: 'maven-publish' -version = '0.1.27' group = 'com.mojang' +version = project.hasProperty('buildNumber') ? "${project.majorMinor}.${project.buildNumber}" : "${project.majorMinor}.0-SNAPSHOT" task wrapper(type: Wrapper) { gradleVersion = '4.0' @@ -64,29 +64,33 @@ test { } } -def repoDir = new File(projectDir, "repo") -repoDir.mkdirs() - -uploadArchives { - repositories { - mavenDeployer { - repository(url: "file://" + repoDir.absolutePath) - - pom.project { - description 'Command Registration & Dispatch System' - url 'http://github.com/Mojang/brigadier' - } - } - } - - doLast { - // Purge all annoying files that arent needed - repoDir.traverse(type: FileType.FILES, nameFilter: ~/.*\.(xml|xml\.sha1|md5)$/) { - it.delete() +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + artifact sourcesJar + } + } +} + +task report { + doLast { + println "##teamcity[buildNumber '${project.version}']" + } +} + +if (version.endsWith("SNAPSHOT")) { + publishing.repositories { + mavenLocal() + } +} else { + publishing.repositories { + maven { + url "s3://minecraft-libraries/" + authentication { + awsIm(AwsImAuthentication) + } } } } -clean.doLast { - repoDir.deleteDir() -} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..8dee0e0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +majorMinor: 1.0 \ No newline at end of file