-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
21 changed files
with
604 additions
and
342 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
plugins { | ||
id 'groovy-gradle-plugin' | ||
} |
81 changes: 81 additions & 0 deletions
81
buildSrc/src/main/groovy/neoforge.formatting-conventions.gradle
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,81 @@ | ||
import java.util.regex.Matcher | ||
|
||
project.plugins.apply('com.diffplug.spotless') | ||
|
||
final generatePackageInfos = tasks.register('generatePackageInfos', Task) { | ||
doLast { | ||
fileTree('src/main/java').each { javaFile -> | ||
def packageInfoFile = new File(javaFile.parent, 'package-info.java') | ||
if (!packageInfoFile.exists()) { | ||
def pkgName = javaFile.toString().replaceAll(Matcher.quoteReplacement(File.separator), '/') | ||
pkgName = pkgName.substring(pkgName.indexOf('net/neoforged/'), pkgName.lastIndexOf('/')) | ||
pkgName = pkgName.replaceAll('/', '.') | ||
|
||
def pkgInfoText = """ | ||
|@FieldsAreNonnullByDefault | ||
|@MethodsReturnNonnullByDefault | ||
|@ParametersAreNonnullByDefault | ||
|package $pkgName; | ||
| | ||
|import javax.annotation.ParametersAreNonnullByDefault; | ||
|import net.minecraft.FieldsAreNonnullByDefault; | ||
|import net.minecraft.MethodsReturnNonnullByDefault; | ||
""".stripMargin().trim() | ||
|
||
packageInfoFile.text = pkgInfoText | ||
} | ||
} | ||
} | ||
} | ||
|
||
spotless { | ||
java { | ||
endWithNewline() | ||
indentWithSpaces() | ||
removeUnusedImports() | ||
toggleOffOn() | ||
eclipse().configFile rootProject.file('codeformat/formatter-config.xml') | ||
importOrder() | ||
|
||
// courtesy of diffplug/spotless#240 | ||
// https://github.com/diffplug/spotless/issues/240#issuecomment-385206606 | ||
custom 'noWildcardImports', { String fileContents -> | ||
if (fileContents.contains('*;\n')) { | ||
throw new GradleException('No wildcard imports are allowed!') | ||
} | ||
} | ||
|
||
custom 'noNotNull', { String fileContents -> | ||
if (fileContents.contains('@NotNull') || fileContents.contains('@Nonnull')) { | ||
throw new GradleException('@NotNull and @Nonnull are disallowed.') | ||
} | ||
} | ||
bumpThisNumberIfACustomStepChanges(2) | ||
} | ||
} | ||
|
||
tasks.named('licenseFormat').configure { | ||
mustRunAfter generatePackageInfos | ||
} | ||
tasks.named('spotlessApply').configure { | ||
mustRunAfter generatePackageInfos | ||
mustRunAfter tasks.named('licenseFormat') | ||
} | ||
|
||
tasks.register('applyAllFormatting', Task) { | ||
dependsOn generatePackageInfos | ||
dependsOn tasks.named('licenseFormat') | ||
dependsOn tasks.named('spotlessApply') | ||
group = 'verification' | ||
} | ||
|
||
tasks.register('checkFormatting', Task) { | ||
dependsOn 'licenseCheck' | ||
dependsOn 'spotlessCheck' | ||
group = 'verification' | ||
} | ||
|
||
tasks.register('runUnitTests', Task) { | ||
group = 'verification' | ||
tasks.withType(Test).each { tsk -> it.dependsOn(tsk) } | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.neoforge.junit; | ||
|
||
import cpw.mods.modlauncher.Launcher; | ||
import net.minecraft.SharedConstants; | ||
import net.minecraft.server.Bootstrap; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.fml.common.asm.RuntimeDistCleaner; | ||
|
||
public class JUnitMain { | ||
public static void main(String[] args) { | ||
SharedConstants.tryDetectVersion(); | ||
Bootstrap.bootStrap(); | ||
|
||
// Load mods | ||
net.neoforged.neoforge.server.loading.ServerModLoader.load(); | ||
|
||
// We launch as a server, but we want client classes available | ||
((RuntimeDistCleaner) Launcher.INSTANCE.environment().findLaunchPlugin("runtimedistcleaner").orElseThrow()) | ||
.getExtension().accept(Dist.CLIENT); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/net/neoforged/neoforge/junit/package-info.java
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,13 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
@FieldsAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
@ParametersAreNonnullByDefault | ||
package net.neoforged.neoforge.junit; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
import net.minecraft.FieldsAreNonnullByDefault; | ||
import net.minecraft.MethodsReturnNonnullByDefault; |
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
Oops, something went wrong.