brigadier/build.gradle

134 lines
3.1 KiB
Groovy
Raw Normal View History

2017-06-21 08:29:26 -04:00
import groovy.io.FileType
2018-07-02 06:35:33 -04:00
import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider
import com.amazonaws.services.s3.AmazonS3Client
2017-06-21 08:29:26 -04:00
apply plugin: 'java-library'
apply plugin: 'maven-publish'
2014-09-15 06:03:39 -04:00
group = 'com.mojang'
version = project.hasProperty('buildNumber') ? "${project.majorMinor}.${project.buildNumber}" : "${project.majorMinor}.0-SNAPSHOT"
2014-09-15 06:03:39 -04:00
task wrapper(type: Wrapper) {
gradleVersion = '4.0'
2014-09-15 06:03:39 -04:00
}
2018-07-02 06:35:33 -04:00
buildscript {
repositories {
mavenCentral()
maven {
url "https://libraries.minecraft.net"
}
}
dependencies {
classpath 'com.amazonaws:aws-java-sdk:1.11.33'
}
}
2014-09-15 06:03:39 -04:00
repositories {
maven {
url "https://libraries.minecraft.net"
2014-09-15 06:03:39 -04:00
}
mavenCentral()
}
dependencies {
2017-06-21 08:21:15 -04:00
api 'com.google.guava:guava:21.0'
2018-05-02 05:24:29 -04:00
testCompile 'junit:junit-dep:4.10'
testCompile 'org.hamcrest:hamcrest-library:1.2.1'
testCompile 'org.mockito:mockito-core:1.8.5'
testCompile 'com.google.guava:guava-testlib:21.0'
testCompile 'org.openjdk.jmh:jmh-core:1.19'
testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.19'
2014-09-15 06:03:39 -04:00
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
resources {
srcDirs = ['src/main/resources']
}
}
test {
java {
srcDirs = ['src/test/java']
}
resources {
srcDirs = ['src/test/resources']
}
}
}
2014-09-15 06:03:39 -04:00
artifacts {
archives jar
archives sourcesJar
}
test {
testLogging {
events "failed", "skipped"
2017-06-21 08:36:17 -04:00
showStandardStreams = true
showExceptions true
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
2014-09-15 06:03:39 -04:00
}
}
}
2014-09-15 06:03:39 -04:00
task report {
2014-09-15 06:03:39 -04:00
doLast {
println "##teamcity[buildNumber '${project.version}']"
}
}
2018-07-02 06:35:33 -04:00
def publishDir = file("$buildDir/repo")
def uploadFile(s3, bucket, path, filename) {
println "Uploading $filename to $bucket as $path"
s3.putObject(bucket, path, filename)
}
clean.doLast {
delete publishDir
}
if (version.endsWith("SNAPSHOT")) {
publishing.repositories {
mavenLocal()
}
} else {
publishing.repositories {
maven {
2018-07-02 06:35:33 -04:00
url "$buildDir/repo"
}
}
publish.doLast {
def AWSRoleARN = (System.getenv("AWS_ROLE_ARN") != null && System.getenv("AWS_ROLE_ARN") != "" ? System.getenv("AWS_ROLE_ARN") : null)
if (AWSRoleARN == null) throw new GradleException("AWS Role has not been configured, use the `AWS_ROLE_ARN` environment variable")
def auth = new STSAssumeRoleSessionCredentialsProvider.Builder(AWSRoleARN, "JavaBrigadierPublish").build()
def s3 = new AmazonS3Client(auth)
publishDir.eachFileRecurse {
2018-07-02 07:09:12 -04:00
if (!it.name.contains(".xml") && !it.name.contains(".md5") && it.isFile()) {
2018-07-02 06:35:33 -04:00
def relPath = publishDir.toPath().relativize(it.toPath()).toFile().toString().replaceAll('\\\\', '/')
uploadFile(s3, "minecraft-libraries", relPath, it)
}
2014-09-15 06:03:39 -04:00
}
}
}