1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-26 15:32:17 +00:00
CC-Tweaked/build.gradle
2022-01-01 15:41:24 +00:00

250 lines
6.4 KiB
Groovy

plugins {
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(17)
java {
toolchain {
languageVersion = javaVersion
}
withSourcesJar()
withJavadocJar()
}
tasks.withType(JavaExec).configureEach {
javaLauncher = javaToolchains.launcherFor {
languageVersion = javaVersion
}
}
version = mod_version
group = "dan200.computercraft"
archivesBaseName = "cc-restitched"
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"
minecraft "com.mojang:minecraft:${mc_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"
modApi("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
modImplementation "com.terraformersmc:modmenu:${modmenu_version}"
modImplementation "me.shedaniel.cloth.api:cloth-utils-v1:${cloth_api_version}"
implementation 'com.electronwill.night-config:toml:3.6.3'
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
shade 'org.squiddev:Cobalt:0.5.2-SNAPSHOT'
include "me.shedaniel.cloth.api:cloth-utils-v1:${cloth_api_version}"
include 'com.electronwill.night-config:core:3.6.3'
include 'com.electronwill.night-config:toml:3.6.3'
include "me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}"
//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.2'
}
processResources {
inputs.property "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')
)
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
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
license {
mapping("java", "SLASHSTAR_STYLE")
strictCheck true
ext.year = Calendar.getInstance().get(Calendar.YEAR)
}
[licenseMain, licenseFormatMain].forEach {
it.configure {
include("**/*.java")
exclude("dan200/computercraft/api/**")
header file('config/license/main.txt')
}
}
[licenseTest, licenseFormatTest, licenseTestMod, licenseFormatTestMod].forEach {
it.configure {
include("**/*.java")
header file('config/license/main.txt')
}
}
gradle.projectsEvaluated {
tasks.withType(LicenseFormat) {
outputs.upToDateWhen { false }
}
}
task licenseAPI(type: LicenseCheck)
task licenseFormatAPI(type: LicenseFormat)
[licenseAPI, licenseFormatAPI].forEach {
it.configure {
source = sourceSets.main.java
include("dan200/computercraft/api/**")
header file('config/license/api.txt')
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()
}
}