Skip to content

Commit f7e2833

Browse files
committed
init
1 parent 2f256be commit f7e2833

6,034 files changed

Lines changed: 133954 additions & 550464 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
*.bat text eol=crlf
33
*.patch text eol=lf
44
*.java text eol=lf
5-
*.gradle text eol=crlf
65
*.png binary
76
*.gif binary
87
*.exe binary

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ jobs:
4141
allowUpdates: true
4242
makeLatest: true
4343
removeArtifacts: true
44-
tag: "1.21.1-release"
44+
tag: "1.21.11-release"
4545
artifacts: ./neotenetlauncher/build/libs/*.jar
4646
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ build
4444
**/eclipse/
4545
**/runs/
4646

47-
**/out/
47+
**/out/

README.md

Lines changed: 0 additions & 93 deletions
This file was deleted.

build.gradle

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import java.util.regex.Matcher
2+
import java.util.regex.Pattern
3+
import net.neoforged.neodev.CheckSplitSources
4+
15
plugins {
26
id 'net.neoforged.gradleutils' version '4.0.1'
37
id 'dev.lukebemish.immaculate' version '0.1.6' apply false
@@ -6,9 +10,13 @@ plugins {
610
id 'neoforge.versioning'
711
}
812

13+
ext.isPreReleaseVersion = project.minecraft_version.contains('w') || project.minecraft_version.contains('-')
914

10-
project.version = '21.1.217'
11-
15+
if (isPreReleaseVersion) {
16+
project.version = "${project.neoforge_snapshot_next_stable}.0-alpha.${project.minecraft_version}.${(new Date()).format('yyyyMMdd.HHmmss', TimeZone.getTimeZone('UTC'))}"
17+
} else {
18+
project.version = gradleutils.version.toString()
19+
}
1220

1321
// Print version, generally useful to know - also appears on CI
1422
System.out.println("NeoForge version ${project.version}")
@@ -20,7 +28,7 @@ allprojects {
2028
apply plugin: 'java'
2129

2230
java.toolchain.languageVersion.set(JavaLanguageVersion.of(project.java_version))
23-
31+
2432
// Suppress removal and deprecation warnings during compilation
2533
tasks.withType(JavaCompile) {
2634
options.compilerArgs << "-Xlint:-removal" << "-Xlint:-deprecation" << "-Xlint:-dep-ann" << "-Xlint:-varargs"

buildSrc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The project consists of a project tree with the following structure:
1010
| Folder Path | Gradle Project Path | Applied Plugins | Description |
1111
|------------------------------------------------------------------------|----------------------|:------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
1212
| [`/build.gradle`](../build.gradle) | `:` | &mdash; | The root project. Since this project is reused for Kits, the root project name is based on the checkout folder, which actually can lead to issues if it is called `NeoForge`. |
13-
| [`/projects/neoforge/build.gradle`](../projects/neoforge/build.gradle) | `:neoforge` | [NeoDevPlugin](#neodevplugin) | The core NeoForge project, which produces the artifacts that will be published. |
13+
| [`/projects/neoforge/build.gradle`](../projects/neotenet/build.gradle) | `:neoforge` | [NeoDevPlugin](#neodevplugin) | The core NeoForge project, which produces the artifacts that will be published. |
1414
| [`/projects/base/build.gradle`](../projects/base/build.gradle) | `:base` | [NeoDevBasePlugin](#neodevbaseplugin) | A utility project that contains the Minecraft sources without any NeoForge additions. Can be used to quickly compare what NeoForge has changed. |
1515
| [`/tests/build.gradle`](../tests/build.gradle) | `:tests` | [NeoDevExtraPlugin](#neodevextraplugin) | Contains the game and unit tests for NeoForge. |
1616
| [`/testframework/build.gradle`](../testframework/build.gradle) | `:testframework` | [MinecraftDependenciesPlugin](#minecraftdependenciesplugin) | A library providing support classes around writing game tests. |

buildSrc/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ dependencies {
3636
implementation "io.codechicken:DiffPatch:${gradle.parent.ext.diffpatch_version}"
3737

3838
implementation "org.ow2.asm:asm:${gradle.parent.ext.asm_version}"
39+
40+
implementation "org.apache.maven:maven-artifact:3.8.5"
3941
}

buildSrc/src/main/groovy/neoforge.formatting-conventions.gradle

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,10 @@ abstract class GeneratePackageInfos extends DefaultTask {
1717
pkgName = pkgName.replaceAll('/', '.')
1818

1919
def pkgInfoText = """
20-
|@FieldsAreNonnullByDefault
21-
|@MethodsReturnNonnullByDefault
22-
|@ParametersAreNonnullByDefault
20+
|@NullMarked
2321
|package $pkgName;
2422
|
25-
|import javax.annotation.ParametersAreNonnullByDefault;
26-
|import net.minecraft.FieldsAreNonnullByDefault;
27-
|import net.minecraft.MethodsReturnNonnullByDefault;
23+
|import org.jspecify.annotations.NullMarked;
2824
""".stripMargin().trim()
2925

3026
packageInfoFile.text = pkgInfoText
@@ -34,6 +30,12 @@ abstract class GeneratePackageInfos extends DefaultTask {
3430
}
3531
final generatePackageInfos = tasks.register('generatePackageInfos', GeneratePackageInfos) {
3632
it.files.from fileTree("src/main/java")
33+
if (file("src/client/java").exists()) {
34+
it.files.from fileTree("src/client/java")
35+
}
36+
if (file("src/junit/java").exists()) {
37+
it.files.from fileTree("src/junit/java")
38+
}
3739
}
3840

3941
immaculate {
@@ -45,7 +47,7 @@ immaculate {
4547
toggleOff = 'spotless:off'
4648
toggleOn = 'spotless:on'
4749
eclipse {
48-
version '3.37.0'
50+
version project.jdt_core_version
4951
config = rootProject.file('codeformat/formatter-config.xml')
5052
}
5153

@@ -59,13 +61,14 @@ immaculate {
5961
}
6062

6163
custom 'noNotNull', { String fileContents ->
62-
if (fileContents.contains('@NotNull') || fileContents.contains('@Nonnull')) {
63-
throw new GradleException('@NotNull and @Nonnull are disallowed.')
64+
if (fileContents.contains('@NotNull') || fileContents.contains('@Nonnull') || fileContents.contains('@NonNull')) {
65+
throw new GradleException('Non-nullability annotations are disallowed.')
6466
}
6567
}
6668

67-
custom 'jetbrainsNullable', { String fileContents ->
68-
fileContents.replace('javax.annotation.Nullable', 'org.jetbrains.annotations.Nullable')
69+
custom 'jspecifyNullable', { String fileContents ->
70+
fileContents.replace('javax.annotation.Nullable', 'org.jspecify.annotations.Nullable')
71+
fileContents.replace('org.jetbrains.annotations.Nullable', 'org.jspecify.annotations.Nullable')
6972
}
7073
}
7174
}

buildSrc/src/main/java/net/neoforged/neodev/ApplyPatches.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import io.codechicken.diffpatch.util.Input.MultiInput;
55
import io.codechicken.diffpatch.util.Output.MultiOutput;
66
import io.codechicken.diffpatch.util.PatchMode;
7+
import java.io.IOException;
8+
import javax.inject.Inject;
79
import org.gradle.api.DefaultTask;
810
import org.gradle.api.Project;
911
import org.gradle.api.file.DirectoryProperty;
@@ -19,9 +21,6 @@
1921
import org.gradle.api.tasks.TaskAction;
2022
import org.gradle.work.DisableCachingByDefault;
2123

22-
import javax.inject.Inject;
23-
import java.io.IOException;
24-
2524
/**
2625
* Applies Java source patches to a source jar and produces a patched source jar as an output.
2726
* It can optionally store rejected hunks into a given folder, which is primarily used for updating
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package net.neoforged.neodev;
2+
3+
import java.io.File;
4+
import java.util.Arrays;
5+
import org.gradle.api.DefaultTask;
6+
import org.gradle.api.GradleException;
7+
import org.gradle.api.file.DirectoryProperty;
8+
import org.gradle.api.tasks.InputDirectory;
9+
import org.gradle.api.tasks.Optional;
10+
import org.gradle.api.tasks.TaskAction;
11+
12+
/**
13+
* This task fails the build if client classes are accidentally put into the common source-set
14+
* and vice-versa.
15+
*/
16+
public abstract class CheckSplitSources extends DefaultTask {
17+
/**
18+
* Configures the folder in the server source-set where someone might accidentally place client classes. Any files placed in this location will fail the build.
19+
*/
20+
@Optional
21+
@InputDirectory
22+
public abstract DirectoryProperty getServerClientFolder();
23+
24+
/**
25+
* Configures the root folder of the package structure that should be exclusive to the client source-set. If this folder has any siblings, the build fails since it
26+
* assumes someone accidentally added common code to the client source-set.
27+
*/
28+
@Optional
29+
@InputDirectory
30+
public abstract DirectoryProperty getClientClientFolder();
31+
32+
@TaskAction
33+
public void run() {
34+
if (getServerClientFolder().isPresent()) {
35+
var filesInServer = getServerClientFolder()
36+
.getAsFileTree()
37+
.filter(File::isFile)
38+
.getFiles()
39+
.stream()
40+
.map(File::toString)
41+
.sorted()
42+
.toList();
43+
44+
if (!filesInServer.isEmpty()) {
45+
throw new GradleException("Found classes under the client package that are placed in the common sourceset: " + String.join(", ", filesInServer));
46+
}
47+
}
48+
49+
// Check that the client package has no sibling packages in the client source-set
50+
if (getClientClientFolder().isPresent()) {
51+
final File clientFolder = getClientClientFolder().getAsFile().get();
52+
final File[] folders = clientFolder.getParentFile().listFiles();
53+
if (folders != null && (folders.length != 1 || !folders[0].equals(clientFolder))) {
54+
var siblings = Arrays.stream(folders).filter(f -> !f.equals(clientFolder)).map(File::getAbsolutePath).toList();
55+
56+
throw new GradleException("Found common files under the client sourceset: " + String.join(", ", siblings));
57+
}
58+
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)