feat: ported copyJar from fantabos.co client
also removed useless comments from the forge example
This commit is contained in:
parent
9f9292f26c
commit
d174f06d0e
2 changed files with 90 additions and 81 deletions
149
build.gradle
149
build.gradle
|
@ -9,37 +9,42 @@ buildscript {
|
|||
}
|
||||
}
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: "com.palantir.git-version"
|
||||
|
||||
version gitVersion()
|
||||
group = 'co.fantabos.boscovicino' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
group = 'co.fantabos.bscv'
|
||||
archivesBaseName = 'boscovicino'
|
||||
|
||||
project.ext {
|
||||
minecraftVersion = getProjectProperty("bscv.mc.version", "1.16.5")
|
||||
forgeVersion = getProjectProperty("bscv.forge.version", "1.16.5-36.2.39")
|
||||
copyJarDo = getProjectProperty("copyjar.do", "false")
|
||||
copyJarUseVersionSubDir = getProjectProperty("copyjar.useVersionSubDir", "false")
|
||||
copyJarKeepBackups = getProjectProperty("copyjar.keepBackups", "true")
|
||||
copyJarTargetGameDir = getProjectProperty("copyjar.targetGameDir", getOsGameDir())
|
||||
}
|
||||
|
||||
def getProjectProperty(String property, String fallback) { //allows for custom gradle.properties while retaining default fallback values
|
||||
return (project.hasProperty(property)) ? project.property(property) : fallback
|
||||
}
|
||||
|
||||
def getOsGameDir() {
|
||||
if (org.gradle.internal.os.OperatingSystem.current().isWindows())
|
||||
return System.getenv("APPDATA") + "/.minecraft"
|
||||
else if (org.gradle.internal.os.OperatingSystem.current().isMacOsX())
|
||||
return System.properties["user.home"] + "/Library/Application Support/minecraft"
|
||||
else
|
||||
return System.properties["user.home"] + "/.minecraft"
|
||||
}
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8.
|
||||
|
||||
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
||||
|
||||
minecraft {
|
||||
// The mappings can be changed at any time, and must be in the following format.
|
||||
// Channel: Version:
|
||||
// snapshot YYYYMMDD Snapshot are built nightly.
|
||||
// stable # Stables are built at the discretion of the MCP team.
|
||||
// official MCVersion Official field/method names from Mojang mapping files
|
||||
//
|
||||
// You must be aware of the Mojang license when using the 'official' mappings.
|
||||
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||
//
|
||||
// Use non-default mappings at your own risk. they may not always work.
|
||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings channel: 'official', version: '1.16.5'
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
mappings channel: 'official', version: "${project.ext.minecraftVersion}"
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
|
@ -50,32 +55,6 @@ minecraft {
|
|||
// "REGISTRIES": For firing of registry events.
|
||||
// "REGISTRYDUMP": For getting the contents of all registries.
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
// Recommended logging level for the console
|
||||
// You can set various levels here.
|
||||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
mods {
|
||||
bscv {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
// The markers can be changed as needed.
|
||||
// "SCAN": For mods scan.
|
||||
// "REGISTRIES": For firing of registry events.
|
||||
// "REGISTRYDUMP": For getting the contents of all registries.
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
// Recommended logging level for the console
|
||||
// You can set various levels here.
|
||||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
mods {
|
||||
|
@ -88,16 +67,10 @@ minecraft {
|
|||
data {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
// The markers can be changed as needed.
|
||||
// "SCAN": For mods scan.
|
||||
// "REGISTRIES": For firing of registry events.
|
||||
// "REGISTRYDUMP": For getting the contents of all registries.
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
// Recommended logging level for the console
|
||||
// You can set various levels here.
|
||||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||
|
@ -116,32 +89,9 @@ minecraft {
|
|||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
dependencies {
|
||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
||||
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
|
||||
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
|
||||
minecraft 'net.minecraftforge:forge:1.16.5-36.2.39'
|
||||
|
||||
// You may put jars on which you depend on in ./libs or you may define them like so..
|
||||
// compile "some.group:artifact:version:classifier"
|
||||
// compile "some.group:artifact:version"
|
||||
|
||||
// Real examples
|
||||
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
|
||||
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
|
||||
|
||||
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
|
||||
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
||||
|
||||
// These dependencies get remapped to your current MCP mappings
|
||||
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
||||
|
||||
// For more info...
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
|
||||
minecraft "net.minecraftforge:forge:${project.ext.forgeVersion}"
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading by the runtime..
|
||||
jar {
|
||||
archiveName = "${jar.baseName}.${jar.extension}"
|
||||
manifest {
|
||||
|
@ -157,11 +107,50 @@ jar {
|
|||
}
|
||||
}
|
||||
|
||||
// Example configuration to allow publishing using the maven-publish task
|
||||
// This is the preferred method to reobfuscate your jar file
|
||||
jar.finalizedBy('reobfJar')
|
||||
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
|
||||
//publish.dependsOn('reobfJar')
|
||||
|
||||
tasks.register('copyJar', Copy) {
|
||||
if(!project.ext.copyJarDo.toBoolean()) return
|
||||
def modDir = "${project.ext.copyJarTargetGameDir}/mods/"
|
||||
|
||||
//check if the per-version subdirectory is disabled
|
||||
if(project.ext.copyJarUseVersionSubDir.toBoolean())
|
||||
modDir = modDir + project.ext.minecraftVersion
|
||||
|
||||
// find previous jar (if it exists)
|
||||
final previousJars = project.fileTree(dir: modDir).matching {
|
||||
include project.archivesBaseName + '*'
|
||||
}.files
|
||||
|
||||
//change filename
|
||||
if (previousJars) {
|
||||
if(copyJarKeepBackups.toBoolean()) {
|
||||
//create .backups folder
|
||||
final backupDir = modDir + '/.backups/'
|
||||
project.file(backupDir).mkdirs()
|
||||
|
||||
for (File previousJar : previousJars) {
|
||||
final n = modDir + '/.backups/' + previousJar.getName() + '.bk'
|
||||
def f = project.file(n)
|
||||
def i = 1
|
||||
while (f.exists()) {
|
||||
f = project.file(n + '_' + i)
|
||||
i++
|
||||
}
|
||||
previousJar.renameTo(f)
|
||||
}
|
||||
} else
|
||||
previousJars
|
||||
.stream()
|
||||
.filter(f -> f.toString().toLowerCase().endsWith("jar")) //dont kill old backups but smite existing jars
|
||||
.forEach(f -> f.delete())
|
||||
}
|
||||
|
||||
//copy jar from build/libs to the forge mod folder
|
||||
//from shadowJar //we want the über version, not the small one
|
||||
from reobfJar
|
||||
into modDir
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
|
|
20
gradle.properties.example
Normal file
20
gradle.properties.example
Normal file
|
@ -0,0 +1,20 @@
|
|||
## The following is an example gradle.properties file.
|
||||
# You can use the gradle.properties file to customize several parts of the building process.
|
||||
# You don't necessarily have to use all the keys. You can delete them, there are fallback values.
|
||||
# Still, beware that misuse of the properties file may result in build failure.
|
||||
# You shouldn't touch the properties starting with "bscv" unless you really know what you are doing.
|
||||
|
||||
#The Minecraft version the client is for. Changing this may break things, take care.
|
||||
bscv.mc.version=1.16.5
|
||||
#The Forge version the client is built with. Minor version changes SHOULD work fine.
|
||||
bscv.forge.version=1.16.5-36.2.39
|
||||
#Tells build.gradle to automatically copy the resulting artifact to your mods folder.
|
||||
copyjar.do=false
|
||||
#Whether you want tha artifact to be stored in a version-specific subfolder (e.g. mods/1.12.2/).
|
||||
copyjar.useVersionSubDir=false
|
||||
#Saves old artifacts found in the mods folder in a .backup subfolder.
|
||||
copyjar.keepBackups=true
|
||||
#Tells the build.gradle where to find the game folder to copy the JAR in.
|
||||
#Only use this if you want to use the auto-copy feature with third party launchers such as PolyMC and MultiMC.
|
||||
#Note that, regardless of your OS, you should use "/" as folder separator.
|
||||
copyjar.targetGameDir=C:/Program Files/MultiMC/instances/BoSCoVicino/.minecraft
|
Loading…
Reference in a new issue