Advertisement
Gamebuster

Untitled

Sep 16th, 2020
1,464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 6.46 KB | None | 0 0
  1. buildscript {
  2.     repositories {
  3.         jcenter()
  4.         mavenCentral()
  5.         maven { url "https://files.minecraftforge.net/maven" }
  6.         mavenLocal()
  7.     }
  8.     dependencies {
  9.         classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
  10.         classpath('com.gamebuster19901:LicenseChecker'){
  11.             version {
  12.                 branch = "master"
  13.             }
  14.         }
  15.     }
  16. }
  17. apply plugin: 'net.minecraftforge.gradle'
  18. // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
  19. apply plugin: 'eclipse'
  20. apply plugin: 'maven-publish'
  21.  
  22. version = "1.15.2-1.7.2.0"
  23. group = "com.gamebuster19901" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
  24. archivesBaseName = "guncore"
  25.  
  26. sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
  27. compileJava {
  28.     sourceCompatibility = targetCompatibility = '1.8'
  29. }
  30.  
  31. minecraft {
  32.     // The mappings can be changed at any time, and must be in the following format.
  33.     // snapshot_YYYYMMDD   Snapshot are built nightly.
  34.     // stable_#         Stables are built at the discretion of the MCP team.
  35.  
  36.     // Use non-default mappings at your own risk. they may not always work.
  37.     // Simply re-run your setup task after changing the mappings to update your workspace.
  38.     mappings channel: 'snapshot', version: '20200916-1.15.1'
  39.     // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
  40.    
  41.     accessTransformer = file('src/main/resources/main/META-INF/accesstransformer.cfg')
  42.  
  43.     // Default run configurations.
  44.     // These can be tweaked, removed, or duplicated as needed.
  45.     runs {
  46.         client {
  47.             workingDirectory project.file('run')
  48.  
  49.             // Recommended logging data for a userdev environment
  50.             property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
  51.  
  52.             // Recommended logging level for the console
  53.             property 'forge.logging.console.level', 'debug'
  54.  
  55.             mods {
  56.                 guncore {
  57.                     source sourceSets.main
  58.                 }
  59.             }
  60.         }
  61.  
  62.         server {
  63.             workingDirectory project.file('run')
  64.  
  65.             // Recommended logging data for a userdev environment
  66.             property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
  67.  
  68.             // Recommended logging level for the console
  69.             property 'forge.logging.console.level', 'debug'
  70.  
  71.             mods {
  72.                 guncore {
  73.                     source sourceSets.main
  74.                 }
  75.             }
  76.         }
  77.     }
  78. }
  79.  
  80. dependencies {
  81.     // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
  82.     // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
  83.     // The userdev artifact is a special name and will get all sorts of transformations applied to it.
  84.     minecraft 'net.minecraftforge:forge:1.15.2-31.2.41'
  85.  
  86.     // You may put jars on which you depend on in ./libs or you may define them like so..
  87.     // compile "some.group:artifact:version:classifier"
  88.     // compile "some.group:artifact:version"
  89.  
  90.     // Real examples
  91.     // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev'  // adds buildcraft to the dev env
  92.     // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
  93.  
  94.     // The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
  95.     // provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
  96.  
  97.     // These dependencies get remapped to your current MCP mappings
  98.     // deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
  99.  
  100.     // For more info...
  101.     // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
  102.     // http://www.gradle.org/docs/current/userguide/dependency_management.html
  103.  
  104. }
  105.  
  106. // Example for how to get properties into the manifest for reading by the runtime..
  107. jar {
  108.     manifest {
  109.         attributes([
  110.             "Specification-Title": "guncore",
  111.             "Specification-Vendor": "examplemodsareus",
  112.             "Specification-Version": "1", // We are version 1 of ourselves
  113.             "Implementation-Title": project.name,
  114.             "Implementation-Version": "${version}",
  115.             "Implementation-Vendor" :"examplemodsareus",
  116.             "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
  117.         ])
  118.     }
  119. }
  120.  
  121. task checkVersion() {
  122.     def versionRegex = ~'(?i)version(?i-)\\s?=\\s?\\"[\\w.-]*\\"';
  123.    
  124.     def gradlef = project.buildscript.sourceFile.toString();
  125.     def dir = new File(gradlef).getParent().toString();
  126.    
  127.     String allContainingFiles =
  128.         new File(dir + '/src/main/java/com/gamebuster19901/guncore/Main.java').text +
  129.         new File(dir + '/src/main/resources/META-INF/mods.toml').text +
  130.         new File(gradlef).text
  131.        
  132.     allContainingFiles = allContainingFiles.replaceAll(' ','')
  133.        
  134.     def matcher = allContainingFiles =~ versionRegex
  135.    
  136.     assert matcher.find();
  137.     assert matcher.size() == 3;
  138.     assert matcher[0].equalsIgnoreCase(matcher[1]) && matcher[1].equalsIgnoreCase(matcher[2])
  139.  
  140.     logger.info("Version verified: " + matcher[0])
  141. }
  142.  
  143. task checkLicenses(type: JavaExec) {
  144.     classpath += sourceSets.main.runtimeClasspath
  145.     classpath += buildscript.configurations.classpath
  146.     println main = "com.gamebuster19901.license.LicenseChecker"
  147.     args = ['notBinary', 'silenceSkips', "classes:com.gamebuster19901.license.test.Test"]
  148. }
  149.  
  150. build.dependsOn checkVersion
  151. build.dependsOn checkLicenses
  152. build.finalizedBy publish
  153. jar.dependsOn checkLicenses
  154.  
  155. task applyLicenses(type: JavaExec) {
  156.     classpath += sourceSets.main.runtimeClasspath
  157.     classpath += buildscript.configurations.classpath
  158.     println main = "com.gamebuster19901.license.LicenseChecker"
  159.     args = ['notBinary', 'applyLicenses']
  160. }
  161.  
  162. task editLicenses(type:JavaExec) {
  163.     classpath += sourceSets.main.runtimeClasspath
  164.     classpath += buildscript.configurations.classpath
  165.     standardInput = System.in
  166.     println main = "com.gamebuster19901.license.create.CreateChecker"
  167.     args = ['notBinary', 'applyLicenses']
  168. }
  169.  
  170. task stripLicenses(type:JavaExec){
  171.     classpath += sourceSets.main.runtimeClasspath
  172.     classpath += buildscript.configurations.classpath
  173.     standardInput = System.in
  174.     println main = "com.gamebuster19901.license.LicenseChecker"
  175.     args = ['notBinary', 'stripLicenses']
  176. }
  177.  
  178. // Example configuration to allow publishing using the maven-publish task
  179. // we define a custom artifact that is sourced from the reobfJar output task
  180. // and then declare that to be published
  181. // Note you'll need to add a repository here
  182. def reobfFile = file("$buildDir/reobfJar/output.jar")
  183. def reobfArtifact = artifacts.add('default', reobfFile) {
  184.     type 'jar'
  185.     builtBy 'reobfJar'
  186. }
  187. publishing {
  188.     publications {
  189.         mavenJava(MavenPublication) {
  190.             artifact reobfArtifact
  191.         }
  192.     }
  193.     repositories {
  194.         mavenLocal()
  195.     }
  196. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement