-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to install and run a production client and server as …
…well as moddev for testing FML. (#177)
- Loading branch information
Showing
19 changed files
with
1,223 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation "com.google.code.gson:gson:2.10.1" | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
} |
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,45 @@ | ||
package fmlbuild; | ||
|
||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.attributes.Attribute; | ||
import org.gradle.api.attributes.AttributeDisambiguationRule; | ||
import org.gradle.api.attributes.MultipleCandidatesDetails; | ||
|
||
/** | ||
* Adds the attributes used by NeoForge, NeoForm and Minecraft Gradle module metadata. | ||
*/ | ||
public class AttributesPlugin implements Plugin<Project> { | ||
private static final Attribute<String> ATTRIBUTE_DISTRIBUTION = Attribute.of("net.neoforged.distribution", String.class); | ||
private static final Attribute<String> ATTRIBUTE_OPERATING_SYSTEM = Attribute.of("net.neoforged.operatingsystem", String.class); | ||
|
||
@Override | ||
public void apply(Project project) { | ||
project.getDependencies().attributesSchema(attributesSchema -> { | ||
attributesSchema.attribute(ATTRIBUTE_DISTRIBUTION).getDisambiguationRules().add(DistributionDisambiguation.class); | ||
attributesSchema.attribute(ATTRIBUTE_OPERATING_SYSTEM).getDisambiguationRules().add(OperatingSystemDisambiguation.class); | ||
}); | ||
} | ||
} | ||
|
||
// The production server configuration has to be given the attribute to get server dependencies | ||
abstract class DistributionDisambiguation implements AttributeDisambiguationRule<String> { | ||
@Override | ||
public void execute(MultipleCandidatesDetails<String> details) { | ||
details.closestMatch("client"); | ||
} | ||
} | ||
|
||
/** | ||
* This disambiguation rule will select native dependencies based on the operating system Gradle is currently running on. | ||
*/ | ||
abstract class OperatingSystemDisambiguation implements AttributeDisambiguationRule<String> { | ||
@Override | ||
public void execute(MultipleCandidatesDetails<String> details) { | ||
details.closestMatch(switch (OperatingSystem.current()) { | ||
case LINUX -> "linux"; | ||
case MACOS -> "osx"; | ||
case WINDOWS -> "windows"; | ||
}); | ||
} | ||
} |
Oops, something went wrong.