From 5ff3ae6434753f8df27ac67354d312eff22d6c92 Mon Sep 17 00:00:00 2001 From: apemanzilla Date: Wed, 24 May 2017 12:35:41 -0400 Subject: [PATCH 1/3] Add Gradle task to generate contributor list --- .gitignore | 1 + build.gradle | 43 ++++++++++++++++++- .../computercraft/lua/rom/help/credits.txt | 23 ---------- 3 files changed, 42 insertions(+), 25 deletions(-) delete mode 100644 src/main/resources/assets/computercraft/lua/rom/help/credits.txt diff --git a/.gitignore b/.gitignore index 21b37972c..a674fc268 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ deploy .gradle luaj-2.0.3/lib luaj-2.0.3/*.jar +src/main/resources/assets/computercraft/lua/rom/help/credits.txt diff --git a/build.gradle b/build.gradle index af92f70e0..2e9cf921c 100644 --- a/build.gradle +++ b/build.gradle @@ -10,9 +10,11 @@ } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT' + classpath 'org.ajoberstar:gradle-git:1.6.0' } } apply plugin: 'net.minecraftforge.gradle.forge' +apply plugin: 'org.ajoberstar.grgit' /* // for people who want stable - not yet functional for MC 1.8.8 - we require the forgegradle 2.1 snapshot @@ -69,8 +71,42 @@ } } -processResources -{ +import org.ajoberstar.grgit.Grgit + +task contributors { + group = 'other' + description = 'Creates a contributors file based on the git commit history' + + + doLast { + def header = ''' +ComputerCraft was created by Daniel "dan200" Ratcliffe, with additional code by Aaron "Cloudy" Mills. +Thanks to nitrogenfingers, GopherATL and RamiLego for program contributions. +Thanks to Mojang, the Forge team, and the MCP team. +Uses LuaJ from http://luaj.sourceforge.net/ + +The ComputerCraft 1.76 update was sponsored by MinecraftU and Deep Space. +Visit http://www.minecraftu.org and http://www.deepspace.me/space-cadets to find out more. + +Join the ComputerCraft community online at http://www.computercraft.info +Follow @DanTwoHundred on Twitter! + +GitHub Contributors: +''' + def blacklist = ['GitHub', 'dan200', 'Daniel Ratcliffe'] + + def grgit = Grgit.open(dir: '.') + def history = grgit.log() + + Set contributors = [] + history.forEach { if(!blacklist.contains(it.committer.name)) contributors.add(it.committer.name) } + + def credits = file('src/main/resources/assets/computercraft/lua/rom/help/credits.txt') + credits.write(header + contributors.sort().join('\n')) + } +} + +processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version @@ -89,8 +125,11 @@ } } +processResources.dependsOn contributors + gradle.projectsEvaluated { tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint" } } + diff --git a/src/main/resources/assets/computercraft/lua/rom/help/credits.txt b/src/main/resources/assets/computercraft/lua/rom/help/credits.txt deleted file mode 100644 index ba6730ed5..000000000 --- a/src/main/resources/assets/computercraft/lua/rom/help/credits.txt +++ /dev/null @@ -1,23 +0,0 @@ -ComputerCraft was created by Daniel "dan200" Ratcliffe, with additional code by Aaron "Cloudy" Mills. -Thanks to nitrogenfingers, GopherATL and RamiLego for program contributions. -Thanks to Mojang, the Forge team, and the MCP team. -Uses LuaJ from http://luaj.sourceforge.net/ - -The ComputerCraft 1.76 update was sponsored by MinecraftU and Deep Space. -Visit http://www.minecraftu.org and http://www.deepspace.me/space-cadets to find out more. - -Join the ComputerCraft community online at http://www.computercraft.info -Follow @DanTwoHundred on Twitter! - -GitHub Contributors: -boq -Cruor -gegy1000 -JLLeitschuh -Lignum -ObloxCC -Restioson -SquidDev -timia2109 -Wilma456 -Wojbie From 3b6ed552e304a2f28e8dac8e12bccd98fa48c6f6 Mon Sep 17 00:00:00 2001 From: apemanzilla Date: Wed, 24 May 2017 12:42:49 -0400 Subject: [PATCH 2/3] Fix incorrect forEach usage --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2e9cf921c..e8a7d1b35 100644 --- a/build.gradle +++ b/build.gradle @@ -99,7 +99,7 @@ def history = grgit.log() Set contributors = [] - history.forEach { if(!blacklist.contains(it.committer.name)) contributors.add(it.committer.name) } + history.each { if(!blacklist.contains(it.committer.name)) contributors.add(it.committer.name) } def credits = file('src/main/resources/assets/computercraft/lua/rom/help/credits.txt') credits.write(header + contributors.sort().join('\n')) From 51b9f3ca3b771689f8a5065c8007a346680d9faa Mon Sep 17 00:00:00 2001 From: apemanzilla Date: Wed, 24 May 2017 13:20:46 -0400 Subject: [PATCH 3/3] Use template instead of separate task --- .gitignore | 1 - build.gradle | 60 ++++++------------- .../computercraft/lua/rom/help/credits.txt | 14 +++++ 3 files changed, 31 insertions(+), 44 deletions(-) create mode 100644 src/main/resources/assets/computercraft/lua/rom/help/credits.txt diff --git a/.gitignore b/.gitignore index a674fc268..21b37972c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,3 @@ deploy .gradle luaj-2.0.3/lib luaj-2.0.3/*.jar -src/main/resources/assets/computercraft/lua/rom/help/credits.txt diff --git a/build.gradle b/build.gradle index e8a7d1b35..3d1b50ac0 100644 --- a/build.gradle +++ b/build.gradle @@ -73,60 +73,34 @@ import org.ajoberstar.grgit.Grgit -task contributors { - group = 'other' - description = 'Creates a contributors file based on the git commit history' - - - doLast { - def header = ''' -ComputerCraft was created by Daniel "dan200" Ratcliffe, with additional code by Aaron "Cloudy" Mills. -Thanks to nitrogenfingers, GopherATL and RamiLego for program contributions. -Thanks to Mojang, the Forge team, and the MCP team. -Uses LuaJ from http://luaj.sourceforge.net/ - -The ComputerCraft 1.76 update was sponsored by MinecraftU and Deep Space. -Visit http://www.minecraftu.org and http://www.deepspace.me/space-cadets to find out more. - -Join the ComputerCraft community online at http://www.computercraft.info -Follow @DanTwoHundred on Twitter! - -GitHub Contributors: -''' - def blacklist = ['GitHub', 'dan200', 'Daniel Ratcliffe'] - - def grgit = Grgit.open(dir: '.') - def history = grgit.log() - - Set contributors = [] - history.each { if(!blacklist.contains(it.committer.name)) contributors.add(it.committer.name) } - - def credits = file('src/main/resources/assets/computercraft/lua/rom/help/credits.txt') - credits.write(header + contributors.sort().join('\n')) - } -} - processResources { - // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version - // replace stuff in mcmod.info, nothing else + def grgit = Grgit.open(dir: '.') + inputs.property "commithash", grgit.log(maxCommits: 1)[0].id + + def blacklist = ['GitHub', 'dan200', 'Daniel Ratcliffe'] + Set contributors = [] + + grgit.log().each { + if (!blacklist.contains(it.committer.name)) + contributors.add(it.committer.name) + } + from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' - - // replace version and mcversion - expand 'version':project.version, 'mcversion':project.minecraft.version - } - - // copy everything else, thats not the mcmod.info + include 'assets/computercraft/lua/rom/help/credits.txt' + + expand 'version':project.version, 'mcversion':project.minecraft.version, 'gitcontributors':contributors.sort().join('\n') + } + from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' + exclude 'assets/computercraft/lua/rom/help/credits.txt' } } -processResources.dependsOn contributors - gradle.projectsEvaluated { tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint" diff --git a/src/main/resources/assets/computercraft/lua/rom/help/credits.txt b/src/main/resources/assets/computercraft/lua/rom/help/credits.txt new file mode 100644 index 000000000..de50039e3 --- /dev/null +++ b/src/main/resources/assets/computercraft/lua/rom/help/credits.txt @@ -0,0 +1,14 @@ + +ComputerCraft was created by Daniel "dan200" Ratcliffe, with additional code by Aaron "Cloudy" Mills. +Thanks to nitrogenfingers, GopherATL and RamiLego for program contributions. +Thanks to Mojang, the Forge team, and the MCP team. +Uses LuaJ from http://luaj.sourceforge.net/ + +The ComputerCraft 1.76 update was sponsored by MinecraftU and Deep Space. +Visit http://www.minecraftu.org and http://www.deepspace.me/space-cadets to find out more. + +Join the ComputerCraft community online at http://www.computercraft.info +Follow @DanTwoHundred on Twitter! + +GitHub Contributors: +${gitcontributors}