Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Spotless plugin #18

Merged
merged 14 commits into from
Feb 15, 2024
37 changes: 36 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,51 @@ java {
withSourcesJar()
}

sourceSets {
spotless
}

group 'net.neoforged.gradleutils'
version '3.0.0-alpha.10'
version '3.0.0-alpha.11'

repositories {
mavenCentral()
gradlePluginPortal()
}

// Spotless runs on J11
tasks.named('compileSpotlessJava', JavaCompile).configure {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(11)
}
}
tasks.named('compileSpotlessGroovy', GroovyCompile).configure {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(11)
}
}

if (System.getenv('GPP_KEY')) {
project.ext {
set('gradle.publish.key', System.getenv('GPP_KEY'))
set('gradle.publish.secret', System.getenv('GPP_SECRET'))
}
}

configurations {
spotlessImplementation.extendsFrom(api)
}

dependencies {
api 'org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r'
api 'io.github.gradle-nexus:publish-plugin:1.3.0'

api "net.neoforged:groovydslimprover:${gdi_version}"
api "net.neoforged:groovydslimprover:${gdi_version}:base"
api "net.neoforged:groovydslimprover:${gdi_version}:runtime"

spotlessImplementation(gradleApi())
spotlessImplementation 'com.diffplug.spotless:spotless-plugin-gradle:6.23.3'
}

sourceSets {
Expand Down Expand Up @@ -73,6 +96,7 @@ tasks.named('jar', Jar) {
license {
header(file('HEADER'))
skipExistingHeaders = true // Ignore existing license headers on files
exclude 'formatter-config.xml'
}

// Disable the license tasks for the template files
Expand All @@ -94,6 +118,13 @@ gradlePlugin {
tags.set(['versioning', 'changelog'])
implementationClass = 'net.neoforged.gradleutils.GradleUtilsPlugin'
}
gradleutilsSpotless {
id = 'net.neoforged.gradleutils.spotless'
displayName = 'GradleUtils Spotless'
description = 'A plugin that configures Spotless on projects'
tags.set(['spotless'])
implementationClass = 'net.neoforged.gradleutils.spotless.SpotlessPlugin'
}
}
}

Expand All @@ -102,6 +133,10 @@ final changelogTask = tasks.register('changelog', GenerateChangelogTask) {
it.changelogFile.set(layout.buildDirectory.file('changelog.txt'))
}

tasks.named('jar', Jar) {
from(sourceSets.spotless.output)
}

tasks.named('assemble') {
it.dependsOn changelogTask
}
Expand Down
Loading
Loading