-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
127 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/immaculate/groovy/net/neoforged/gradleutils/immaculate/ImmaculateConfiguration.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.gradleutils.immaculate | ||
|
||
import dev.lukebemish.immaculate.CheckTask | ||
import dev.lukebemish.immaculate.FormattingWorkflow | ||
import dev.lukebemish.immaculate.ImmaculateExtension | ||
import org.gradle.api.GradleException | ||
import org.gradle.api.Project | ||
|
||
/** | ||
* This is a separate class to avoid class-loading issues when immaculate is *not* applied to the project. | ||
*/ | ||
final class ImmaculateConfiguration { | ||
private ImmaculateConfiguration() { | ||
} | ||
|
||
static void apply(Project project) { | ||
final configPath = new File(project.rootDir, '.gradle/formatter-config.xml') | ||
|
||
final extract = project.tasks.register('extractGUImmaculateConfiguration', ExtractImmaculateConfiguration) { | ||
it.output.set(configPath) | ||
} | ||
|
||
project.tasks.withType(CheckTask).configureEach { | ||
it.dependsOn(extract) | ||
} | ||
|
||
var immaculate = (ImmaculateExtension) project.extensions.getByName("immaculate") | ||
|
||
immaculate.workflows.register("java") { | ||
configure(it, configPath) | ||
} | ||
} | ||
|
||
static void configure(FormattingWorkflow workflow, File configPath) { | ||
workflow.java() | ||
workflow.trailingNewline() | ||
workflow.noTabs() | ||
workflow.googleFixImports() | ||
workflow.toggleOff.set('spotless:off') | ||
workflow.toggleOn.set('spotless:on') | ||
workflow.eclipse { | ||
it.version '3.37.0' | ||
it.config.set(configPath) | ||
} | ||
|
||
// courtesy of diffplug/spotless#240 | ||
// https://github.com/diffplug/spotless/issues/240#issuecomment-385206606 | ||
workflow.custom 'noWildcardImports', { String fileContents -> | ||
if (fileContents.contains('*;\n')) { | ||
throw new GradleException('No wildcard imports are allowed!') | ||
} | ||
} | ||
|
||
workflow.custom 'noNotNull', { String fileContents -> | ||
if (fileContents.contains('@NotNull') || fileContents.contains('@Nonnull')) { | ||
throw new GradleException('@NotNull and @Nonnull are disallowed.') | ||
} | ||
} | ||
|
||
workflow.custom 'jetbrainsNullable', { String fileContents -> | ||
fileContents.replace('javax.annotation.Nullable', 'org.jetbrains.annotations.Nullable') | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 0 additions & 58 deletions
58
src/spotless/groovy/net/neoforged/gradleutils/spotless/SpotlessUtilsExtension.groovy
This file was deleted.
Oops, something went wrong.