-
Notifications
You must be signed in to change notification settings - Fork 280
/
build.gradle
170 lines (139 loc) · 4.58 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
import org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://plugins.gradle.org/m2' }
mavenCentral()
}
dependencies {
classpath ('com.anatawa12.forge:ForgeGradle:1.2-1.0.+') {changing = true}
}
}
apply plugin: 'forge'
apply plugin: 'curseforge'
if(Files.exists(Paths.get("curseforge.properties"))) {
// Load CurseForge configuration
ext.cfprops = parseConfig(file("curseforge.properties"))
}
def version_name = version = mod_version
if(!mod_build_number.isEmpty()) {
version_name = mod_version + "_X" + mod_build_number
version = "[${version_name}]"
}
group = "com.hbm" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "HBM-NTM"
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "eclipse"
}
// A little hack to fix codechicken's crazy maven structure (at least in 1.7.10)
eclipse.classpath.file.whenMerged { cp ->
// Find all codechicken source jars
def srcent = cp.entries.findAll { entry -> entry.path.contains("codechicken") && entry.path.endsWith("-src.jar") }
// Remove them from classpath
cp.entries.removeAll srcent
// Map the source entries to their dev counterparts based on basename
Map<String, File> srcmap = new HashMap<String, File>()
srcent.forEach { entry ->
def file = new File(entry.path)
srcmap.put(file.getName().replace("-src.jar", "-dev.jar"), file)
}
// Create file reference factory
def fileref = new FileReferenceFactory()
// Find all codechicken development jars
cp.entries.findAll { entry -> entry.path.contains("codechicken") && entry.path.endsWith("-dev.jar") }.forEach { entry ->
File srcmapping = new File(entry.path) // Initialize the srcmapping from the dev jar path
srcmapping = srcmap.get(srcmapping.getName()) // Transform it using the sourcemap
entry.sourcePath = fileref.fromFile(srcmapping) // Set the source path
}
}
repositories {
maven {
name = 'ModMaven'
url = 'https://modmaven.dev'
}
maven {
name = "gt"
url = "https://gregtech.mechaenetia.com/"
}
//maven {
// name = "CurseForge"
// url = "https://minecraft.curseforge.com/api/maven/"
//}
}
dependencies {
implementation 'codechicken:CodeChickenCore:1.7.10-1.0.4.29:dev'
compileOnly 'codechicken:CodeChickenCore:1.7.10-1.0.4.29:src'
implementation 'codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev'
compileOnly 'codechicken:CodeChickenLib:1.7.10-1.1.3.140:src'
implementation 'codechicken:NotEnoughItems:1.7.10-1.0.3.74:dev'
compileOnly 'codechicken:NotEnoughItems:1.7.10-1.0.3.74:src'
compileOnly "inventorytweaks:InventoryTweaks:1.59-dev:deobf"
implementation "li.cil.oc:OpenComputers:MC1.7.10-1.5.+:api"
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
filesMatching('mcmod.info') {
// replace version, mcversion and credits
expand([
version: version_name,
credits: project.credits
])
}
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
// add AT to meta-inf
jar {
manifest {
attributes 'FMLAT': 'HBM_at.cfg'
}
}
task version {
doFirst {
println project.version
}
}
if(Files.exists(Paths.get("curseforge.properties"))) {
curse {
apiKey = cfprops.api_key
projectId = cfprops.project_id
releaseType = "release"
displayName = "Hbm's Nuclear Tech Mod " + version_name.replace("_", "") + " for Minecraft 1.7.10"
gameVersions.addAll([
"Forge",
"Java 8",
"Client", "Server"
])
if (Files.exists(Paths.get("changelog"))) {
changelog = String.join("\r\n", Files.readAllLines(Paths.get("changelog")))
// Perform a backup of the changelog and create a new file for next changes
doLast {
Files.move(Paths.get("changelog"), Paths.get("changelog.bak"), StandardCopyOption.REPLACE_EXISTING)
Files.createFile(Paths.get("changelog"))
}
}
}
}
// Properties file parsing helper
static def parseConfig(File config) {
config.withReader {
def prop = new Properties()
prop.load(it)
return (new ConfigSlurper().parse(prop))
}
}