forked from Mojang/DataFixerUpper
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
130 lines (111 loc) · 3.09 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import groovy.io.FileType
import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider
import com.amazonaws.services.s3.AmazonS3Client
apply plugin: 'java-library'
apply plugin: 'maven-publish'
group = 'com.mojang'
version = project.hasProperty('buildNumber') ? "${project.majorMinor}.${project.buildNumber}" : "${project.majorMinor}.0-SNAPSHOT"
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
buildscript {
repositories {
mavenCentral()
maven {
url "https://libraries.minecraft.net"
}
}
dependencies {
classpath 'com.amazonaws:aws-java-sdk:1.11.33'
}
}
repositories {
maven {
url "https://libraries.minecraft.net"
}
mavenCentral()
}
dependencies {
compile 'com.google.code.findbugs:jsr305:2.0.1'
compile 'com.google.code.gson:gson:2.8.0'
compile 'org.apache.logging.log4j:log4j-api:2.8.1'
compile 'com.google.guava:guava:21.0'
compile 'org.apache.commons:commons-lang3:3.5'
compile 'it.unimi.dsi:fastutil:8.2.1'
}
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']
}
}
}
artifacts {
archives jar
archives sourcesJar
}
test {
testLogging {
events "failed", "skipped"
showStandardStreams = true
showExceptions true
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
}
}
}
task report {
doLast {
println "##teamcity[buildNumber '${project.version}']"
}
}
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 {
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, "DataFixerUpperPublish").build()
def s3 = new AmazonS3Client(auth)
publishDir.eachFileRecurse {
if (!it.name.contains(".xml") && !it.name.contains(".md5") && it.isFile()) {
def relPath = publishDir.toPath().relativize(it.toPath()).toFile().toString().replaceAll('\\\\', '/')
uploadFile(s3, "minecraft-libraries", relPath, it)
}
}
}
}