1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-31 09:37:56 +00:00

Update build.gradle to more closely match CC:T's

- Adds cct-javadoc fun and renables checkstyle (yay?)
 - Fixes a few javadoc and formatting issues
 - Cherry pick the docs so illuaminate doesn't complain
This commit is contained in:
Jonathan Coates
2021-11-27 09:32:25 +00:00
parent 73e3e237ad
commit 70a24d371d
55 changed files with 1530 additions and 71 deletions

View File

@@ -1,47 +1,68 @@
plugins {
id 'fabric-loom' version '0.9-SNAPSHOT'
id 'maven-publish'
//id "checkstyle"
id "checkstyle"
id "jacoco"
id "maven-publish"
id "com.github.hierynomus.license" version "0.16.1"
id "org.jetbrains.kotlin.jvm" version "1.5.21"
id 'fabric-loom' version '0.10-SNAPSHOT'
}
def javaVersion = JavaLanguageVersion.of(16)
java {
toolchain {
languageVersion = JavaLanguageVersion.of(16)
languageVersion = javaVersion
}
withSourcesJar()
withJavadocJar()
}
tasks.withType(JavaExec).configureEach {
javaLauncher = javaToolchains.launcherFor {
languageVersion = javaVersion
}
}
version = mod_version
group = "dan200.computercraft"
archivesBaseName = "cc-restiched"
archivesBaseName = "cc-restitched"
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://api.modrinth.com/maven'}
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/" }
maven {
name "SquidDev"
url "https://squiddev.cc/maven"
sourceSets {
main.resources {
srcDir 'src/generated/resources'
}
testMod {}
}
loom {
accessWidenerPath = file("src/main/resources/cc.accesswidener")
}
repositories {
mavenCentral()
maven {
name "SquidDev"
url "https://squiddev.cc/maven"
}
// TODO: Limit these to a set of groups.
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/" }
}
configurations {
shade
implementation.extendsFrom shade
cctJavadoc
}
dependencies {
//checkstyle 'com.puppycrawl.tools:checkstyle:8.45.1'
checkstyle "com.puppycrawl.tools:checkstyle:8.45"
minecraft "com.mojang:minecraft:${mc_version}"
//mappings "net.fabricmc:yarn:${mc_version}+build.${mappings_version}:v2"
mappings(minecraft.officialMojangMappings())
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"
@@ -52,7 +73,8 @@ dependencies {
modImplementation "me.shedaniel.cloth.api:cloth-utils-v1:${cloth_api_version}"
implementation 'com.electronwill.night-config:toml:3.6.3'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
shade 'org.squiddev:Cobalt:0.5.2-SNAPSHOT'
@@ -61,39 +83,114 @@ dependencies {
include 'com.electronwill.night-config:toml:3.6.3'
include "me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}"
modRuntime "me.shedaniel:RoughlyEnoughItems-api-fabric:6.0.254-alpha"
modRuntime "me.shedaniel:RoughlyEnoughItems-fabric:6.0.254-alpha"
modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-api-fabric:6.0.254-alpha"
modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:6.0.254-alpha"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.21'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1'
cctJavadoc 'cc.tweaked:cct-javadoc:1.4.1'
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
def hash = 'none'
Set<String> contributors = []
try {
hash = ["git", "-C", projectDir, "rev-parse", "HEAD"].execute().text.trim()
def blacklist = ['GitHub', 'dan200', 'Daniel Ratcliffe']
["git", "-C", projectDir, "log", "--format=tformat:%an%n%cn"].execute().text.split('\n').each {
if (!blacklist.contains(it)) contributors.add(it)
}
} catch (Exception e) {
e.printStackTrace()
}
inputs.property "commithash", hash
duplicatesStrategy = DuplicatesStrategy.INCLUDE
filesMatching(["fabric.mod.json", "data/computercraft/lua/rom/help/credits.txt"]) {
expand(
'version': mod_version,
'mcversion': mc_version,
'gitcontributors': contributors.sort(false, String.CASE_INSENSITIVE_ORDER).join('\n')
)
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
javadoc {
include "dan200/computercraft/api/**/*.java"
}
task luaJavadoc(type: Javadoc) {
description "Generates documentation for Java-side Lua functions."
group "documentation"
source = sourceSets.main.allJava
destinationDir = file("${project.docsDir}/luaJavadoc")
classpath = sourceSets.main.compileClasspath
options.docletpath = configurations.cctJavadoc.files as List
options.doclet = "cc.tweaked.javadoc.LuaDoclet"
options.noTimestamp = false
javadocTool = javaToolchains.javadocToolFor {
languageVersion = javaVersion
}
}
jar {
from "LICENSE"
manifest {
attributes([
"Specification-Title" : "computercraft",
"Specification-Version" : "1",
"Implementation-Title" : "CC: Restitched",
"Implementation-Version" : "${mod_version}",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
}
[compileJava, compileTestJava].forEach {
it.configure {
options.compilerArgs << "-Xlint" << "-Xlint:-processing"
}
}
sourcesJar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
// Check tasks
test {
useJUnitPlatform()
testLogging {
events "skipped", "failed"
}
}
jacocoTestReport {
dependsOn('test')
reports {
xml.required = true
html.required = true
}
}
check.dependsOn jacocoTestReport
import com.hierynomus.gradle.license.tasks.LicenseCheck
import com.hierynomus.gradle.license.tasks.LicenseFormat
@@ -113,7 +210,7 @@ license {
}
}
[licenseTest, licenseFormatTest].forEach {
[licenseTest, licenseFormatTest, licenseTestMod, licenseFormatTestMod].forEach {
it.configure {
include("**/*.java")
header file('config/license/main.txt')
@@ -126,9 +223,8 @@ gradle.projectsEvaluated {
}
}
task licenseAPI(type: LicenseCheck);
task licenseFormatAPI(type: LicenseFormat);
task licenseAPI(type: LicenseCheck)
task licenseFormatAPI(type: LicenseFormat)
[licenseAPI, licenseFormatAPI].forEach {
it.configure {
source = sourceSets.main.java