Advertisement
masa-

malilib build.gradle

Apr 24th, 2019
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 3.40 KB | None | 0 0
  1. plugins {
  2.     id 'fabric-loom' version '0.2.2-SNAPSHOT'
  3. }
  4.  
  5. apply plugin: 'maven-publish'
  6.  
  7. sourceCompatibility = JavaVersion.VERSION_1_8
  8. targetCompatibility = JavaVersion.VERSION_1_8
  9.  
  10. ext.configFile = file "build.properties"
  11.  
  12. configFile.withReader {
  13.     def prop = new Properties()
  14.     prop.load(it)
  15.     project.ext.config = new ConfigSlurper().parse prop
  16. }
  17.  
  18. dependencies {
  19.     minecraft "com.mojang:minecraft:" + config.minecraft_version
  20.     mappings "net.fabricmc:yarn:" + config.mappings_version
  21.     modCompile "net.fabricmc:fabric-loader:" + config.fabric_loader_version
  22.     compile "com.google.code.findbugs:jsr305:3.0.2"
  23.  
  24.     // Fabric API. This is technically optional, but you probably want it anyway.
  25.     modCompile "net.fabricmc:fabric:" + config.fabric_version
  26. }
  27.  
  28. minecraft {
  29.     ext.mod_version = config.mod_version
  30.  
  31.     if (mod_version.endsWith('-dev')) {
  32.         mod_version = mod_version + "." + new Date().format('yyyyMMdd.HHmmss')
  33.     }
  34.  
  35.     //replaceIn "reference/MaLiLibReference.java"
  36.     //replace "@MOD_VERSION@", mod_version
  37. }
  38.  
  39. compileJava {
  40.     sourceCompatibility = JavaVersion.VERSION_1_8
  41.     targetCompatibility = JavaVersion.VERSION_1_8
  42.     options.encoding = 'UTF-8'
  43. }
  44.  
  45. group = config.group + "." + config.mod_id
  46. archivesBaseName = config.mod_file_name + '-' + config.minecraft_version_out
  47. version = project.minecraft.mod_version
  48.  
  49. processResources
  50. {
  51.     // this will ensure that this task is redone when the versions change.
  52.     //inputs.property "mod_version", project.minecraft.mod_version
  53.     //inputs.property "minecraft_version", project.config.minecraft_version
  54.  
  55.     inputs.property "mod_version", project.minecraft.mod_version
  56.  
  57.     from(sourceSets.main.resources.srcDirs) {
  58.         include "fabric.mod.json"
  59.         expand "mod_version": project.minecraft.mod_version
  60.     }
  61.  
  62.     from(sourceSets.main.resources.srcDirs) {
  63.         exclude "fabric.mod.json"
  64.     }
  65. }
  66.  
  67. // ensure that the encoding is set to UTF-8, no matter what the system default is
  68. // this fixes some edge cases with special characters not displaying correctly
  69. // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
  70. tasks.withType(JavaCompile) {
  71.     options.encoding = "UTF-8"
  72. }
  73.  
  74. // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
  75. // if it is present.
  76. // If you remove this task, sources will not be generated.
  77. task sourcesJar(type: Jar, dependsOn: classes) {
  78.     classifier = 'sources'
  79.     from sourceSets.main.allSource
  80. }
  81.  
  82. task deobfJar(type: Jar) {
  83.     from sourceSets.main.output
  84.     // This classifier is standard and should not be changed
  85.     classifier = 'deobf'
  86. }
  87.  
  88. // This section enables the last two tasks
  89. artifacts {
  90.     //archives sourcesJar
  91.     archives deobfJar
  92. }
  93.  
  94. tasks.publish.dependsOn build
  95. publishing {
  96.     publications {
  97.         mavenJava(MavenPublication) {
  98.             // old:
  99.             artifactId project.archivesBaseName
  100.             from components.java
  101.  
  102.             artifact deobfJar
  103.             artifact sourcesJar
  104.  
  105.             // new:
  106.             // add all the jars that should be included when publishing to maven
  107.             //artifact(jar)           { builtBy remapJar }
  108.             //artifact(sourcesJar)    { builtBy remapSourcesJar }
  109.         }
  110.     }
  111.  
  112.     repositories {
  113.         maven {
  114.             url "$projectDir/../../CommonMaven"
  115.         }
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement