123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- plugins {
- id("fabric-loom") version "0.4.5"
- id("maven-publish")
- id("java")
- id("java-library")
- id("net.minecrell.licenser") version("0.4.1")
- id("com.matthewprenger.cursegradle") version("1.4.0")
- id("net.corda.plugins.jar-filter") version("5.0.8") apply false
- }
- import net.fabricmc.loom.task.RemapJarTask
- import java.text.SimpleDateFormat
- sourceCompatibility = targetCompatibility = 1.8
- archivesBaseName = "RoughlyEnoughItems"
- group = "me.shedaniel"
- version = project.mod_version
- minecraft {
- accessWidener = file("src/main/resources/rei.aw")
- }
- license {
- header rootProject.file('HEADER')
- include '**/*.java'
- }
- repositories {
- maven { url "https://dl.bintray.com/shedaniel/legacy-yarn-updated" }
- }
- jar {
- from "LICENSE"
- }
- processResources {
- filesMatching('fabric.mod.json') {
- expand 'version': project.version
- }
- inputs.property "version", project.version
- }
- dependencies {
- minecraft("com.mojang:minecraft:${project.minecraft_version}")
- mappings("me.shedaniel:legacy-yarn:${project.yarn_version}:v2")
- modApi("net.fabricmc:fabric-loader:${project.fabricloader_version}")
- modApi("net.fabricmc.fabric-api:fabric-api:${project.fabric_api}") {
- exclude(module: "fabric-dimensions-v1")
- exclude(module: "fabric-biomes-v1")
- exclude(module: "fabric-events-interaction-v0")
- }
- modApi("me.shedaniel.cloth:cloth-events:${cloth_events_version}") {
- transitive = false
- }
- modApi("me.shedaniel.cloth:config-2:${cloth_config_version}") {
- exclude module: "fabric-api"
- }
- modApi("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig1u}") {
- exclude module: "fabric-api"
- }
- modApi("org.jetbrains:annotations:18.0.0")
- modCompileOnly("io.github.prospector:modmenu:${modmenu_version}") {
- transitive = false
- }
- modRuntime("io.github.prospector:modmenu:${modmenu_version}") {
- transitive = false
- }
- afterEvaluate {
- def listAdded = new ArrayList(Arrays.asList((api_exculde as String).split(',')))
- def eachDep = { dep ->
- for (apiIncludeDepStr in (api_include as String).split(',')) {
- if (apiIncludeDepStr.isEmpty()) continue
- def apiIncludeGroup = apiIncludeDepStr.split(':')[0]
- def apiIncludeDep = apiIncludeDepStr.split(':')[1]
- if (dep.module.id.group == apiIncludeGroup && dep.module.id.name.startsWith(apiIncludeDep)) {
- def version = dep.module.id.version.indexOf('@') >= 0 ? dep.module.id.version.substring(0, dep.module.id.version.indexOf('@')) : dep.module.id.version
- def mavenDep = "${dep.module.id.group}:${dep.module.id.name}:$version"
- if (!(mavenDep in listAdded)) {
- include(mavenDep) {
- transitive = false
- }
- listAdded.add(mavenDep)
- }
- break
- }
- }
- }
- configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.each eachDep
- configurations.runtimeClasspath.resolvedConfiguration.firstLevelModuleDependencies.each eachDep
- }
- }
- task jarFilter(type: net.corda.gradle.jarfilter.JarFilterTask) {
- jars remapJar
- annotations {
- forRemove = [
- "org.jetbrains.annotations.NotNull",
- "org.jetbrains.annotations.Nullable",
- "org.jetbrains.annotations.ApiStatus\$Experimental",
- "org.jetbrains.annotations.ApiStatus\$Internal",
- "org.jetbrains.annotations.ApiStatus\$ScheduledForRemoval",
- "org.jetbrains.annotations.ApiStatus\$AvailableSince",
- "org.jetbrains.annotations.ApiStatus\$NonExtendable",
- "org.jetbrains.annotations.ApiStatus\$OverrideOnly"
- ]
- }
- }
- task copyJarFilter(type: Copy) {
- from jarFilter
- into "${project.buildDir}/filtered-libs/"
- rename { "${project.archivesBaseName}-${project.version}.jar" }
- }
- task sourcesJar(type: Jar, dependsOn: classes) {
- classifier("sources")
- from sourceSets.main.allSource
- }
- task remapMavenJar(type: RemapJarTask, dependsOn: jar) {
- afterEvaluate {
- input = file("${project.buildDir}/libs/${archivesBaseName}-${version}-dev.jar")
- archiveName = "${archivesBaseName}-${version}.jar"
- addNestedDependencies = false
- }
- }
- def releaseChangelog = "No changelog"
- /* Thank you modmenu & fablabs */
- task releaseOnCf {
- def df = new SimpleDateFormat("yyyy-MM-dd HH:mm")
- df.setTimeZone(TimeZone.getTimeZone("UTC"))
- def branch
- if (System.env.BRANCH_NAME) {
- branch = System.env.BRANCH_NAME
- branch = branch.substring(branch.lastIndexOf("/") + 1)
- } else {
- branch = "git rev-parse --abbrev-ref HEAD".execute().in.text.trim()
- }
- if (branch == "HEAD") {
- branch = "git rev-parse --short HEAD".execute().in.text.trim()
- }
- def time = df.format(new Date())
- def changes = new StringBuilder()
- changes << "<h2>REI v$project.version for $project.supported_version</h2>Updated at <b>$time</b>.<br><a href=\"https://www.github.com/shedaniel/RoughlyEnoughItems/commits/$branch\">Click here for changelog</a>"
- def proc = "git log --max-count=200 --pretty=format:%s".execute()
- proc.in.eachLine { line ->
- def processedLine = line.toString()
- if (!processedLine.contains("New translations") && !processedLine.contains("Merge") && !processedLine.contains("branch")) {
- changes << "<br>- ${processedLine.capitalize()}"
- }
- }
- proc.waitFor()
- releaseChangelog = changes.toString()
- dependsOn tasks.getByName("curseforge")
- }
- curseforge {
- if (project.hasProperty('danielshe_curse_api_key') || System.getenv('danielshe_curse_api_key') != null) {
- apiKey = project.hasProperty('danielshe_curse_api_key') ? project.property('danielshe_curse_api_key') : System.getenv('danielshe_curse_api_key')
- project {
- id = "310111"
- releaseType = "beta"
- changelogType = "html"
- changelog = releaseChangelog
- addGameVersion "1.16-Snapshot"
- addGameVersion "Java 8"
- addGameVersion "Fabric"
- relations {
- requiredDependency "fabric-api"
- embeddedLibrary "cloth"
- embeddedLibrary "cloth-config"
- embeddedLibrary "auto-config-updated-api"
- }
- mainArtifact(file("${project.buildDir}/filtered-libs/${project.archivesBaseName}-${project.version}.jar")) {
- displayName = "[Fabric $project.supported_version] v$project.version"
- }
- addArtifact(file("${project.buildDir}/libs/${project.archivesBaseName}-${project.version}-sources.jar")) {
- displayName = "[Fabric $project.supported_version] v$project.version Sources"
- }
- afterEvaluate {
- uploadTask.dependsOn("copyJarFilter")
- }
- }
- }
- options {
- forgeGradleIntegration = false
- javaVersionAutoDetect = false
- }
- }
- publishing {
- publications {
- mavenJava(MavenPublication) {
- artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}.jar")) {
- builtBy remapMavenJar
- }
- artifact(sourcesJar) {
- builtBy remapSourcesJar
- }
- }
- }
- repositories {
- if (project.hasProperty('danielshe_pass')) {
- maven {
- url = "http://deploy.modmuss50.me/"
- credentials {
- username = "danielshe"
- password = project.getProperty('danielshe_pass')
- }
- }
- }
- }
- }
|