Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiplatform #2

Merged
merged 13 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ Annotations can be applied to mixin classes to toggle the whole mixin, or indivi

MixinConstraints is available through Maven Central.

The library currently only supports Fabric.

__Gradle__
```groovy
dependencies {
Expand All @@ -20,7 +18,7 @@ dependencies {
Next, you will need to bootstrap the library to affect your mixins.

The easiest way to do so is by using the provided Mixin Plugin by adding the following to your modid.mixins.json:
```json
```json5
{
"plugin": "com.moulberry.mixinconstraints.ConstraintsMixinPlugin",
}
Expand Down
82 changes: 0 additions & 82 deletions build.gradle

This file was deleted.

121 changes: 121 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import com.vanniktech.maven.publish.JavaLibrary
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.SonatypeHost

plugins {
java
idea
id("com.vanniktech.maven.publish") version("0.28.0") // `maven-publish` doesn't support new maven central
}

version = "1.0.1"
group = "com.moulberry.mixinconstraints"

idea.module.isDownloadSources = true

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}

repositories {
mavenCentral()
maven("https://maven.fabricmc.net/")
maven("https://repo.spongepowered.org/maven") // provides lexforge
maven("https://maven.neoforged.net/releases")
}

val fabric: SourceSet by sourceSets.creating {
compileClasspath += sourceSets.main.get().output
}

val forge: SourceSet by sourceSets.creating {
compileClasspath += sourceSets.main.get().output
}

val neoforge: SourceSet by sourceSets.creating {
compileClasspath += sourceSets.main.get().output
}

dependencies {
implementation("org.spongepowered:mixin:0.8.5")
implementation("org.ow2.asm:asm-tree:9.7")
implementation("org.slf4j:slf4j-api:2.0.12")
implementation("org.jetbrains:annotations:24.1.0")

"fabricImplementation"("net.fabricmc:fabric-loader:0.15.0")

"forgeImplementation"("net.minecraftforge:fmlloader:1.20.6-50.1.0")
"forgeImplementation"("net.minecraftforge:fmlcore:1.20.6-50.1.0")

"neoforgeImplementation"("net.neoforged.fancymodloader:loader:3.0.45")
}

tasks.jar {
from(fabric.output)
from(forge.output)
from(neoforge.output)
}

tasks.register<Jar>("sourcesJar") {
group = "build"
archiveClassifier.set("sources")
sourceSets.map { it.allSource }.forEach {
from(it)
}
}

mavenPublishing {
configure(JavaLibrary(JavadocJar.Javadoc(), true))

publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

signAllPublications()

coordinates("com.moulberry", "mixinconstraints", version.toString())

pom {
name = "MixinConstraints"
description = "Library to enable/disable mixins using annotations"
url = "https://github.com/Moulberry/MixinConstraints"
inceptionYear = "2024"
packaging = "jar"

licenses {
license {
name = "MIT License"
url = "https://opensource.org/license/mit"
}
}

developers {
developer {
name = "Moulberry"
url = "https://github.com/Moulberry"
}
}

contributors {
contributor {
name = "rdh"
url = "https://github.com/rhysdh540"
}
contributor {
name = "IThundxr"
url = "https://ithundxr.dev"
}
}

issueManagement {
system = "GitHub"
url = "https://github.com/Moulberry/MixinConstraints/issues"
}

scm {
url = "https://github.com/Moulberry/MixinConstraints/"
connection = "scm:git:git://github.com/Moulberry/MixinConstraints.git"
developerConnection = "scm:git:ssh://[email protected]/Moulberry/MixinConstraints.git"
}
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
17 changes: 9 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -144,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -201,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
11 changes: 0 additions & 11 deletions settings.gradle

This file was deleted.

10 changes: 10 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pluginManagement {
repositories {
maven("https://maven.wagyourtail.xyz/releases")
gradlePluginPortal()
}
}

rootProject.name = "MixinConstraints"

include("testmod")
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.moulberry.mixinconstraints;

import com.moulberry.mixinconstraints.util.Abstractions;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.Version;
import net.fabricmc.loader.api.VersionParsingException;

import static com.moulberry.mixinconstraints.util.MixinHacks.unchecked;

public class FabricAbstractionsImpl extends Abstractions {
@Override
protected boolean isDevEnvironment() {
return FabricLoader.getInstance().isDevelopmentEnvironment();
}

@Override
protected String getModVersion(String modId) {
return FabricLoader.getInstance().getModContainer(modId)
.map(container -> container.getMetadata()
.getVersion()
.getFriendlyString())
.orElse(null);
}

@Override
protected boolean isVersionInRange(String version, String minVersion, String maxVersion) {
try {
Version currentVersion = Version.parse(version);
Version min = minVersion == null ? null : Version.parse(minVersion);
Version max = maxVersion == null ? null : Version.parse(maxVersion);

if(min != null && max != null && min.compareTo(max) > 0) {
throw new IllegalArgumentException("minVersion (" + minVersion + ") is greater than maxVersion (" + maxVersion + ")");
}

return (min == null || currentVersion.compareTo(min) >= 0) && (max == null || currentVersion.compareTo(max) <= 0);

} catch (VersionParsingException e) {
throw unchecked(e);
}
}
}
Loading
Loading