-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle
129 lines (110 loc) · 4.42 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
plugins {
id 'org.spongepowered.plugin' version '0.9.0'
id "org.spongepowered.ore" version "0.9.0"
id 'com.github.johnrengelman.shadow' version '2.0.1'
id "com.jfrog.bintray" version "1.8.4"
id 'com.qixalite.spongestart2' version '3.2.3'
id 'signing'
}
group 'com.vcsajen'
version '1.2.0'
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = 1.8
project.tasks.assemble.dependsOn project.tasks.shadowJar
// Disable the 'jar' task
jar.enabled = false
repositories {
mavenCentral()
}
def bintrayVersion = getVersion()+(System.getenv('TRAVIS') ? "."+System.getenv('TRAVIS_BUILD_NUMBER') : ".0")
def bintrayProjName = rootProject.name
setVersion(getVersion()+(System.getenv('TRAVIS') ? "."+System.getenv('TRAVIS_BUILD_NUMBER') : ".0")+(System.getenv('TRAVIS_TAG') ? "" : (System.getenv('TRAVIS') ? "-"+System.getenv('TRAVIS_COMMIT').take(7) : "")+"-SNAPSHOT"))
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.allTasks.any { it instanceof Sign }) {
if (getSecret('CERT_KEY_ID')!=null) {
if (!file("./secring.gpg").exists()) {
new File("./secring.gpg").bytes = getSecret('CERT_PRIVATE_KEY_BASE64').decodeBase64()
}
allprojects {
ext."signing.keyId" = getSecret('CERT_KEY_ID') ?: ""
ext."signing.secretKeyRingFile" = "./secring.gpg"
ext."signing.password" = getSecret('CERT_PWD') ?: ""
}
}
}
}
static def getSecret(String secretname){
def result = System.getenv(secretname)
if (result != null && result != "") return result
def Properties props = new Properties()
def File secretFile = new File('secrets.properties')
if (!secretFile.exists()) return null
props.load(new FileInputStream(secretFile))
return props[secretname]
}
static String encodeHtmlEntities(String s) {
s.collectReplacements {
Character c ->
int codePoint = c.toString().codePointAt(0)
if (codePoint>0x007F) {
'&#x'+Integer.toHexString(codePoint)+';'
} else null
}
}
/*tasks.withType(Sign) {
onlyIf { getSecret('CERT_KEY_ID')!=null }
}*/
signing {
required { gradle.taskGraph.hasTask("oreDeploy") }
sign configurations.shadow
}
oreDeploy {
apiKey = getSecret('ORE_API_KEY') ?: '00000000000000000000000000000000'
recommended = isReleaseVersion
deploy = configurations.archives
channel = isReleaseVersion ? /*'release'*/'snapshot' : 'snapshot' //TODO: Fix when ORE fixes their bug
forumPost = isReleaseVersion
changelog = encodeHtmlEntities(isReleaseVersion ? 'See intermediate snapshot versions for changelog' :
"In the version "+getVersion()+", following changes were made:\r\n\r\n"+ //Useless padding to satisfy Ore's obsession with "min 15 characters"
(System.getenv('TRAVIS_COMMIT_MESSAGE') ? System.getenv('TRAVIS_COMMIT_MESSAGE') : 'Unknown')) //encodeHtmlEntities to circumvent Ore's Unicode bug
}
task signArchives(dependsOn: 'signShadow') {
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
shadow 'org.spongepowered:spongeapi:7.1.0'
compile 'com.flowpowered:flow-nbt:1.0.0'
compile group: 'com.mortennobel', name: 'java-image-scaling', version: '0.8.6'
compile group: 'com.jhlabs', name: 'filters', version: '2.0.235-1'
}
shadowJar {
classifier = null
relocate 'com.flowpowered.nbt', 'com.vcsajen.yourcustompaintings.com.flowpowered.flow-nbt'
relocate 'com.mortennobel.imagescaling', 'com.vcsajen.yourcustompaintings.com.mortennobel.imagescaling'
relocate 'com.jhlabs', 'com.vcsajen.yourcustompaintings.com.jhlabs'
}
bintray {
user = getSecret('BINTRAY_USER_NAME') ?: "user"
key = getSecret('BINTRAY_API_KEY') ?: "0000000000000000000000000000000000000000"
configurations = ['archives']
pkg {
repo = 'generic'
name = 'YourCustomPaintings'
publish = true
userOrg = user
licenses = ['MIT']
vcsUrl = 'https://github.com/VcSaJen/YourCustomPaintings.git'
version {
name = bintrayVersion.toString()
desc = bintrayProjName.toString() + bintrayVersion.toString()
released = new Date()
vcsTag = System.getenv('TRAVIS_TAG') ? System.getenv('TRAVIS_TAG') : System.getenv('TRAVIS_COMMIT')
}
}
}
spongestart {
minecraft '1.12.2'
forge '14.23.4.2705'
}