-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
177 lines (158 loc) · 4.28 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
buildscript {
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
maven {
name = "gradle"
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT"
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2"
}
}
apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: "maven-publish"
apply plugin: "org.sonarqube"
description = "Got Wood?"
def mod_file = getModFile()
def mc_version = "1.12"
def short_version = getVersion("VERSION", mod_file)
version = mc_version + "-" + short_version
group = "panda.gotwood"
archivesBaseName = "GotWood"
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
}
javadoc {
failOnError = false
}
class Secrets {
def data = null
def getProperty(String key) {
return data ? data[key] : ""
}
}
import groovy.json.JsonSlurper
def secretFile
if (System.getenv().SECRET_FILE) {
secretFile = file System.getenv().SECRET_FILE
} else {
secretFile = file "secret.json"
}
project.ext.secret = new Secrets()
if (secretFile.exists()) {
secretFile.withReader {
project.ext.secret.data = new JsonSlurper().parse it
}
}
minecraft {
version = "1.12.2-14.23.5.2836"
runDir = "run"
mappings = "stable_39"
// makeObfSourceJar = false
}
dependencies {}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
from (sourceSets.main.resources.srcDirs) {
include "mcmod.info"
expand "version": project.version, "mcversion": project.minecraft.version
}
from (sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
}
task deobfJar(type: Jar) {
classifier = "deobf"
from sourceSets.main.output
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc"
from javadoc.getDestinationDir()
}
artifacts {
// archives apiJar
archives deobfJar
archives sourceJar
archives javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
from components.java
artifact sourceJar {
classifier "sources"
}
/*
artifact apiJar {
classifier "api"
}
*/
artifact deobfJar {
classifier "deobf"
}
artifact javadocJar {
classifier "javadoc"
}
}
}
repositories {
maven {
credentials {
username secret.username
password secret.password
}
url secret.url
}
}
}
String getModFile() {
String path = ""
FileTree tree = fileTree(dir: "src/main/java")
tree.include "**/*.java"
tree.visit { element ->
if (element.file.isFile()) {
element.file.eachLine { String s ->
s = s.trim()
if (s.startsWith("@Mod(")) {
path = "src/main/java/$element.relativePath"
}
}
}
}
return path
}
String getVersion(String type, String mod_file) {
String major = "0"
String revision = "0"
String patch = "0"
String prefix = "public static final String $type = \""
File file = file(mod_file)
file.eachLine { String s ->
s = s.trim()
if (s.startsWith(prefix)) {
s = s.substring(prefix.length(), s.length() - 2)
String[] pts = s.split("\\.")
major = pts[0]
revision = pts[1]
patch = pts[2]
}
}
return "$major.$revision.$patch"
}
sonarqube {
properties {
property "sonar.host.url", secret.sonarHost
property "sonar.organization", secret.sonarOrganization
property "sonar.login", secret.sonarToken
property "sonar.projectName", project.archivesBaseName
property "sonar.projectKey", "$project.group:$project.archivesBaseName"
}
}