Created
May 6, 2020 01:59
-
-
Save matshou/7d5028261f399d8769ec596219f8d833 to your computer and use it in GitHub Desktop.
Odyssey consuming Minecraft modding library CocoLib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
maven { url = 'https://files.minecraftforge.net/maven' } | |
jcenter() | |
mavenCentral() | |
} | |
dependencies { | |
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true | |
} | |
} | |
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: 'java' | |
version = "${minecraftVersion}-${modVersion}" | |
group = "io.${groupName}" | |
archivesBaseName = project.modId | |
// Need this here so eclipse task generates correctly. | |
compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' | |
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility | |
minecraft { | |
// The mappings can be changed at any time, and must be in the following format. | |
// snapshot_YYYYMMDD Snapshot are built nightly. | |
// stable_# Stables are built at the discretion of the MCP team. | |
// 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: 'snapshot', version: "${mappingBuild}-${mappingMCVersion}" | |
runs { | |
client { | |
workingDirectory project.file('run') | |
// Recommended logging data for a userdev environment | |
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' | |
// Recommended logging level for the console | |
property 'forge.logging.console.level', 'info' | |
mods { | |
odyssey { | |
source sourceSets.main | |
} | |
} | |
} | |
} | |
} | |
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:${minecraftVersion}-${forgeVersion}" | |
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api | |
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.6.2' | |
// https://mvnrepository.com/artifact/org.jetbrains/annotations | |
compile group: 'org.jetbrains', name: 'annotations', version: '19.0.0' | |
} | |
// Get properties into the manifest for reading by the runtime.. | |
jar { | |
manifest { | |
attributes([ | |
"Specification-Title": project.modId, | |
"Specification-Vendor": "${groupName}", | |
"Specification-Version": "1", // We are version 1 of ourselves | |
"Implementation-Title": project.name, | |
"Implementation-Version": "${version}", | |
"Implementation-Vendor": "${groupName}", | |
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), | |
]) | |
} | |
} | |
// Example configuration to allow publishing using the maven-publish task | |
// This is the preferred method to reobfuscate your jar file | |
jar.finalizedBy('reobfJar') | |
publishing { | |
publications { | |
mavenJava(MavenPublication) { | |
artifact jar | |
} | |
} | |
repositories { | |
maven { | |
url "file:///${project.projectDir}/mcmodsrepo" | |
} | |
} | |
} | |
// Generate sources when building mod | |
task sourcesJar(type: Jar, dependsOn: classes) { | |
classifier = 'sources' | |
from sourceSets.main.allSource | |
} | |
build.dependsOn sourcesJar | |
artifacts { | |
archives sourcesJar | |
} | |
// Process resources on build and make sure that variables are | |
// correctly inserted into mods.toml when the mod is built or run | |
processResources { | |
// This will ensure that this task is redone when the versions change. | |
inputs.property 'version', project.version | |
// Replace stuff in mods.toml, nothing else | |
from(sourceSets.main.resources.srcDirs) { | |
include 'META-INF/mods.toml' | |
// Replace version | |
expand 'version': project.version | |
} | |
// Copy everything else except the mods.toml | |
from(sourceSets.main.resources.srcDirs) { | |
exclude 'META-INF/mods.toml' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
maven { url = 'https://files.minecraftforge.net/maven' } | |
maven { url = 'https://repo.spongepowered.org/maven' } | |
jcenter() | |
mavenCentral() | |
} | |
dependencies { | |
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true | |
// https://github.com/SpongePowered/MixinGradle | |
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' | |
} | |
} | |
apply plugin: 'net.minecraftforge.gradle' | |
apply plugin: 'org.spongepowered.mixin' | |
apply plugin: 'eclipse' | |
apply plugin: 'maven-publish' | |
apply plugin: 'java-library' | |
version = "${minecraftVersion}-${modVersion}" | |
group = "io.${groupName}" | |
archivesBaseName = project.modId | |
// Need this here so eclipse task generates correctly. | |
compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' | |
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility | |
repositories { | |
mavenLocal() | |
maven { url 'https://repo.spongepowered.org/maven' } | |
} | |
mixin { | |
add sourceSets.main, "mixins.${modId}.refmap.json" | |
} | |
minecraft { | |
// The mappings can be changed at any time, and must be in the following format. | |
// snapshot_YYYYMMDD Snapshot are built nightly. | |
// stable_# Stables are built at the discretion of the MCP team. | |
// 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: 'snapshot', version: "${mappingBuild}-${mappingMCVersion}" | |
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. | |
// Default run configurations. | |
// These can be tweaked, removed, or duplicated as needed. | |
runs { | |
client { | |
workingDirectory project.file('run') | |
arg "-mixin.config=" + archivesBaseName + ".mixins.json" | |
// Recommended logging data for a userdev environment | |
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' | |
// Recommended logging level for the console | |
property 'forge.logging.console.level', 'info' | |
mods { | |
odyssey { | |
source sourceSets.main | |
} | |
} | |
} | |
server { | |
workingDirectory project.file('run') | |
arg "-mixin.config=" + archivesBaseName + ".mixins.json" | |
// Recommended logging data for a userdev environment | |
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' | |
// Recommended logging level for the console | |
property 'forge.logging.console.level', 'info' | |
mods { | |
odyssey { | |
source sourceSets.main | |
} | |
} | |
} | |
} | |
} | |
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:${minecraftVersion}-${forgeVersion}" | |
// https://mvnrepository.com/artifact/org.jetbrains/annotations | |
compile group: 'org.jetbrains', name: 'annotations', version: '19.0.0' | |
// https://github.com/SpongePowered/Mixin | |
compile "org.spongepowered:mixin:0.8.1-SNAPSHOT" | |
compile fg.deobf("io.yooksi:cocolib:${cocoLibVersion}") | |
// implementation "io.yooksi:cocolib:${cocoLibVersion}" | |
} | |
// Get properties into the manifest for reading by the runtime.. | |
jar { | |
manifest { | |
attributes([ | |
"Specification-Title": project.modId, | |
"Specification-Vendor": "${groupName}", | |
"Specification-Version": "1", // We are version 1 of ourselves | |
"Implementation-Title": project.name, | |
"Implementation-Version": "${version}", | |
"Implementation-Vendor": "${groupName}", | |
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), | |
"MixinConfigs": "${modId}.mixins.json" | |
]) | |
} | |
} | |
// Example configuration to allow publishing using the maven-publish task | |
// This is the preferred method to reobfuscate your jar file | |
jar.finalizedBy('reobfJar') | |
publishing { | |
publications { | |
mavenJava(MavenPublication) { | |
artifact jar | |
} | |
} | |
repositories { | |
maven { | |
url "file:///${project.projectDir}/mcmodsrepo" | |
} | |
} | |
} | |
// Generate sources when building mod | |
task sourcesJar(type: Jar, dependsOn: classes) { | |
classifier = 'sources' | |
from sourceSets.main.allSource | |
} | |
build.dependsOn sourcesJar | |
artifacts { | |
archives sourcesJar | |
} | |
// Process resources on build and make sure that variables are | |
// correctly inserted into mods.toml when the mod is built or run | |
processResources { | |
// This will ensure that this task is redone when the versions change. | |
inputs.property 'version', project.version | |
// Replace stuff in mods.toml, nothing else | |
from(sourceSets.main.resources.srcDirs) { | |
include 'META-INF/mods.toml' | |
// Replace version | |
expand 'version': project.version | |
} | |
// Copy everything else except the mods.toml | |
from(sourceSets.main.resources.srcDirs) { | |
exclude 'META-INF/mods.toml' | |
} | |
} | |
// Enable composite build by renaming .composite file | |
task enableCompositeBuild { | |
group = 'tools' | |
description = 'Enable composite build' | |
doLast { | |
File file_enabled = new File(".composite") | |
if (!file_enabled.exists()) | |
{ | |
File file_disabled = new File('.composite-disable') | |
if (file_disabled.exists()) | |
{ | |
if (file_disabled.renameTo('.composite')) { | |
logger.quiet("Composite build enabled") | |
} | |
else { | |
logger.quiet("ERROR: Unable to rename .composite-disable file") | |
} | |
} | |
else if (file_enabled.createNewFile()) { | |
logger.quiet("Composite build enabled, remember to write path to the build" + | |
" you want included inside the created '.composite' file") | |
} | |
else logger.quiet("ERROR: Unable to create .composite file") | |
} | |
else { | |
logger.quiet("Composite builds are already enabled") | |
} | |
} | |
} | |
// Disable composite build by renaming .composite file | |
task disableCompositeBuild { | |
group = 'tools' | |
description = 'Disable composite build' | |
doLast { | |
File file = new File(".composite") | |
if (file.renameTo('.composite-disable')) { | |
logger.quiet("Composite build successfully disabled") | |
} | |
else { | |
logger.quiet("ERROR: Unable to rename .composite file") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment