Skip to content

Commit b3bd65e

Browse files
committed
Create template architectury project
1 parent 62afe9a commit b3bd65e

File tree

30 files changed

+344
-501
lines changed

30 files changed

+344
-501
lines changed

build.gradle

Lines changed: 48 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,70 @@
11
plugins {
2-
id 'fabric-loom' version '1.7-SNAPSHOT'
3-
id 'maven-publish'
2+
id 'dev.architectury.loom' version '1.6-SNAPSHOT' apply false
3+
id 'architectury-plugin' version '3.4-SNAPSHOT'
4+
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
45
}
56

6-
version = project.mod_version
7-
group = project.maven_group
8-
9-
base {
10-
archivesName = project.archives_base_name
7+
architectury {
8+
minecraft = project.minecraft_version
119
}
1210

13-
repositories {
14-
// Add repositories to retrieve artifacts from in here.
15-
// You should only use this when depending on other mods because
16-
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
17-
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
18-
// for more information about repositories.
19-
maven { url "https://maven.shedaniel.me/" }
20-
maven { url "https://maven.terraformersmc.com/releases/" }
21-
maven {
22-
name = "Terraformers"
23-
url = "https://maven.terraformersmc.com/"
24-
}
25-
exclusiveContent {
26-
forRepository {
27-
maven {
28-
name = "Modrinth"
29-
url = "https://api.modrinth.com/maven"
30-
}
31-
}
32-
filter {
33-
includeGroup "maven.modrinth"
34-
}
35-
}
11+
allprojects {
12+
group = rootProject.maven_group
13+
version = rootProject.mod_version
3614
}
3715

38-
loom {
39-
splitEnvironmentSourceSets()
16+
subprojects {
17+
apply plugin: 'dev.architectury.loom'
18+
apply plugin: 'architectury-plugin'
19+
apply plugin: 'maven-publish'
4020

41-
mods {
42-
"too-many-entities" {
43-
sourceSet sourceSets.main
44-
sourceSet sourceSets.client
45-
}
21+
base {
22+
// Set up a suffixed format for the mod jar names, e.g. `example-fabric`.
23+
archivesName = "$rootProject.archives_name-$project.name"
4624
}
4725

48-
}
49-
50-
dependencies {
51-
// To change the versions see the gradle.properties file
52-
minecraft "com.mojang:minecraft:${project.minecraft_version}"
53-
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
54-
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
55-
56-
// Fabric API. This is technically optional, but you probably want it anyway.
57-
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
58-
59-
// Cloth config
60-
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.clothconfig_version}") {
61-
exclude(group: "net.fabricmc.fabric-api")
26+
repositories {
27+
// Add repositories to retrieve artifacts from in here.
28+
// You should only use this when depending on other mods because
29+
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
30+
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
31+
// for more information about repositories.
6232
}
63-
include "me.shedaniel.cloth:cloth-config-fabric:${project.clothconfig_version}"
6433

65-
// Mod menu
66-
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}") {
67-
exclude(group: "net.fabricm.fabric-api")
34+
dependencies {
35+
minecraft "net.minecraft:minecraft:$rootProject.minecraft_version"
36+
mappings "net.fabricmc:yarn:$rootProject.yarn_mappings:v2"
6837
}
6938

70-
// Entity Culling
71-
modImplementation "maven.modrinth:entityculling:${project.entityculling_version}"
72-
}
73-
74-
processResources {
75-
inputs.property "version", project.version
39+
java {
40+
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
41+
// if it is present.
42+
// If you remove this line, sources will not be generated.
43+
withSourcesJar()
7644

77-
filesMatching("fabric.mod.json") {
78-
expand "version": project.version
45+
sourceCompatibility = JavaVersion.VERSION_17
46+
targetCompatibility = JavaVersion.VERSION_17
7947
}
80-
}
81-
82-
tasks.withType(JavaCompile).configureEach {
83-
it.options.release = project.java_version as Integer
84-
}
85-
86-
java {
87-
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
88-
// if it is present.
89-
// If you remove this line, sources will not be generated.
90-
withSourcesJar()
91-
92-
sourceCompatibility = JavaVersion.VERSION_21
93-
targetCompatibility = JavaVersion.VERSION_21
94-
}
9548

96-
jar {
97-
from("LICENSE") {
98-
rename { "${it}_${project.base.archivesName.get()}" }
49+
tasks.withType(JavaCompile).configureEach {
50+
it.options.release = 17
9951
}
100-
}
10152

102-
// configure the maven publication
103-
publishing {
104-
publications {
105-
create("mavenJava", MavenPublication) {
106-
artifactId = project.archives_base_name
107-
from components.java
53+
// Configure Maven publishing.
54+
publishing {
55+
publications {
56+
mavenJava(MavenPublication) {
57+
artifactId = base.archivesName.get()
58+
from components.java
59+
}
10860
}
109-
}
11061

111-
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
112-
repositories {
113-
// Add repositories to publish to here.
114-
// Notice: This block does NOT have the same function as the block in the top level.
115-
// The repositories here will be used for publishing your artifact, not for
116-
// retrieving dependencies.
62+
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
63+
repositories {
64+
// Add repositories to publish to here.
65+
// Notice: This block does NOT have the same function as the block in the top level.
66+
// The repositories here will be used for publishing your artifact, not for
67+
// retrieving dependencies.
68+
}
11769
}
118-
}
70+
}

common/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
architectury {
2+
common rootProject.enabled_platforms.split(',')
3+
}
4+
5+
dependencies {
6+
// We depend on Fabric Loader here to use the Fabric @Environment annotations,
7+
// which get remapped to the correct annotations on each platform.
8+
// Do NOT use other classes from Fabric Loader.
9+
modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"
10+
11+
// Architectury API. This is optional, and you can comment it out if you don't need it.
12+
modImplementation "dev.architectury:architectury:$rootProject.architectury_api_version"
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.github.discusser.toomanyentities;
2+
3+
public final class ExampleMod {
4+
public static final String MOD_ID = "too-many-entities";
5+
6+
public static void init() {
7+
// Write common init code here.
8+
}
9+
}
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
{
22
"required": true,
33
"package": "io.github.discusser.toomanyentities.mixin",
4-
"compatibilityLevel": "JAVA_21",
4+
"compatibilityLevel": "JAVA_17",
5+
"minVersion": "0.8",
6+
"client": [
7+
],
8+
"mixins": [
9+
],
510
"injectors": {
611
"defaultRequire": 1
712
}
8-
}
13+
}

fabric/build.gradle

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
plugins {
2+
id 'com.github.johnrengelman.shadow'
3+
}
4+
5+
architectury {
6+
platformSetupLoomIde()
7+
fabric()
8+
}
9+
10+
configurations {
11+
common {
12+
canBeResolved = true
13+
canBeConsumed = false
14+
}
15+
compileClasspath.extendsFrom common
16+
runtimeClasspath.extendsFrom common
17+
developmentFabric.extendsFrom common
18+
19+
// Files in this configuration will be bundled into your mod using the Shadow plugin.
20+
// Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files.
21+
shadowBundle {
22+
canBeResolved = true
23+
canBeConsumed = false
24+
}
25+
}
26+
27+
dependencies {
28+
modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version"
29+
30+
// Fabric API. This is technically optional, but you probably want it anyway.
31+
modImplementation "net.fabricmc.fabric-api:fabric-api:$rootProject.fabric_api_version"
32+
33+
// Architectury API. This is optional, and you can comment it out if you don't need it.
34+
modImplementation "dev.architectury:architectury-fabric:$rootProject.architectury_api_version"
35+
36+
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
37+
shadowBundle project(path: ':common', configuration: 'transformProductionFabric')
38+
}
39+
40+
processResources {
41+
inputs.property 'version', project.version
42+
43+
filesMatching('fabric.mod.json') {
44+
expand version: project.version
45+
}
46+
}
47+
48+
shadowJar {
49+
configurations = [project.configurations.shadowBundle]
50+
archiveClassifier = 'dev-shadow'
51+
}
52+
53+
remapJar {
54+
input.set shadowJar.archiveFile
55+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.github.discusser.toomanyentities.fabric;
2+
3+
import net.fabricmc.api.ModInitializer;
4+
5+
import io.github.discusser.toomanyentities.ExampleMod;
6+
7+
public final class ExampleModFabric implements ModInitializer {
8+
@Override
9+
public void onInitialize() {
10+
// This code runs as soon as Minecraft is in a mod-load-ready state.
11+
// However, some things (like resources) may still be uninitialized.
12+
// Proceed with mild caution.
13+
14+
// Run our common setup.
15+
ExampleMod.init();
16+
}
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package io.github.discusser.toomanyentities.fabric.client;
2+
3+
import net.fabricmc.api.ClientModInitializer;
4+
5+
public final class ExampleModFabricClient implements ClientModInitializer {
6+
@Override
7+
public void onInitializeClient() {
8+
// This entrypoint is suitable for setting up client-specific logic, such as rendering.
9+
}
10+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"schemaVersion": 1,
3+
"id": "too-many-entities",
4+
"version": "${version}",
5+
"name": "Too Many Entities",
6+
"description": "This is an example description! Tell everyone what your mod is about!",
7+
"authors": [
8+
"Me!"
9+
],
10+
"contact": {
11+
"homepage": "https://fabricmc.net/",
12+
"sources": "https://github.com/FabricMC/fabric-example-mod"
13+
},
14+
"license": "CC0-1.0",
15+
"icon": "assets/too-many-entities/icon.png",
16+
"environment": "*",
17+
"entrypoints": {
18+
"main": [
19+
"io.github.discusser.toomanyentities.fabric.ExampleModFabric"
20+
],
21+
"client": [
22+
"io.github.discusser.toomanyentities.fabric.client.ExampleModFabricClient"
23+
]
24+
},
25+
"mixins": [
26+
"too-many-entities.mixins.json"
27+
],
28+
"depends": {
29+
"fabricloader": ">=0.16.0",
30+
"minecraft": "~1.20.1",
31+
"java": ">=17",
32+
"architectury": ">=9.2.14",
33+
"fabric-api": "*"
34+
},
35+
"suggests": {
36+
"another-mod": "*"
37+
}
38+
}

forge/build.gradle

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
plugins {
2+
id 'com.github.johnrengelman.shadow'
3+
}
4+
5+
loom {
6+
forge {
7+
mixinConfig "too-many-entities.mixins.json"
8+
}
9+
}
10+
11+
architectury {
12+
platformSetupLoomIde()
13+
forge()
14+
}
15+
16+
configurations {
17+
common {
18+
canBeResolved = true
19+
canBeConsumed = false
20+
}
21+
compileClasspath.extendsFrom common
22+
runtimeClasspath.extendsFrom common
23+
developmentForge.extendsFrom common
24+
25+
// Files in this configuration will be bundled into your mod using the Shadow plugin.
26+
// Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files.
27+
shadowBundle {
28+
canBeResolved = true
29+
canBeConsumed = false
30+
}
31+
}
32+
33+
dependencies {
34+
forge "net.minecraftforge:forge:$rootProject.forge_version"
35+
36+
// Architectury API. This is optional, and you can comment it out if you don't need it.
37+
modImplementation "dev.architectury:architectury-forge:$rootProject.architectury_api_version"
38+
39+
common(project(path: ':common', configuration: 'namedElements')) { transitive false }
40+
shadowBundle project(path: ':common', configuration: 'transformProductionForge')
41+
}
42+
43+
processResources {
44+
inputs.property 'version', project.version
45+
46+
filesMatching('META-INF/mods.toml') {
47+
expand version: project.version
48+
}
49+
}
50+
51+
shadowJar {
52+
configurations = [project.configurations.shadowBundle]
53+
archiveClassifier = 'dev-shadow'
54+
}
55+
56+
remapJar {
57+
input.set shadowJar.archiveFile
58+
}

forge/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
loom.platform = forge

0 commit comments

Comments
 (0)