Skip to content

Commit

Permalink
MixinBootstrap v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LXGaming committed Nov 27, 2019
1 parent dd2af8b commit 727009a
Show file tree
Hide file tree
Showing 7 changed files with 471 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
dist: trusty

language: java
jdk:
- openjdk8
- oraclejdk8

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

before_install:
- chmod +x ./gradlew

install:
- ./gradlew --refresh-dependencies

script:
- ./gradlew clean build

after_success:
- ./gradlew bintrayUpload

notifications:
email: false
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# MixinBootstrap

[![Build Status](https://api.travis-ci.com/LXGaming/MixinBootstrap.svg?branch=master)](https://travis-ci.com/LXGaming/MixinBootstrap)
[![License](https://lxgaming.github.io/badges/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Patreon](https://lxgaming.github.io/badges/Patreon-donate-yellow.svg)](https://www.patreon.com/lxgaming)
[![Paypal](https://lxgaming.github.io/badges/Paypal-donate-yellow.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CZUUA6LE7YS44&item_name=MixinBootstrap+(from+GitHub.com))

**MixinBootstrap** is a way of booting [Mixin](https://github.com/SpongePowered/Mixin) in a [MinecraftForge](https://github.com/MinecraftForge/MinecraftForge) production environment by utilizing a [ModLauncher](https://github.com/cpw/modlauncher) ITransformationService.

## Prerequisites
[MinecraftForge](https://github.com/MinecraftForge/MinecraftForge) must be running [ModLauncher](https://github.com/cpw/modlauncher) v4.2.0

## Usage
Simply drop the `MixinBootstrap-<VERSION>.jar` into the [MinecraftForge](https://github.com/MinecraftForge/MinecraftForge) mods folder

## Download
MixinBootstrap is available on [GitHub](https://github.com/LXGaming/MixinBootstrap/releases)

## License
MixinBootstrap is licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) license.
101 changes: 101 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
plugins {
id "java"
id "signing"
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

group = "io.github.lxgaming"
archivesBaseName = "MixinBootstrap"
version = "1.0.0"

configurations {
provided {
compile.extendsFrom(provided)
}

build.dependsOn("signJar")
}

repositories {
jcenter()
maven {
name = "minecraftforge"
url = "https://files.minecraftforge.net/maven"
}
maven {
name = "spongepowered"
url = "https://repo.spongepowered.org/maven"
}
}

dependencies {
provided("com.google.code.findbugs:jsr305:3.0.2")
provided("cpw.mods:modlauncher:4.2.0") {
exclude(module: "asm-analysis")
}
provided("net.sf.jopt-simple:jopt-simple:5.0.4")
provided("org.apache.logging.log4j:log4j-api:2.11.2")
compile("org.ow2.asm:asm-analysis:6.2") {
transitive = false
}
compile("org.ow2.asm:asm-util:6.2") {
transitive = false
}
compile("org.spongepowered:mixin:0.8-SNAPSHOT") {
transitive = false
}
}

jar {
from ((configurations.compile - configurations.provided).findAll({
it.isDirectory() || it.name.endsWith(".jar")
}).collect({
it.isDirectory() ? it : zipTree(it)
})) {

exclude("META-INF/services/cpw.mods.modlauncher.*")
exclude("META-INF/*.RSA")
exclude("META-INF/*.SF")
}

exclude("module-info.class")
}

processResources {
from("LICENSE")
rename("LICENSE", "LICENSE-" + archivesBaseName)
}

task signJar {
doFirst {
if (!project.hasProperty("signing.keyStorePath") || !project.hasProperty("signing.secretKeyRingFile")) {
project.logger.warn("========== [WARNING] ==========")
project.logger.warn("")
project.logger.warn(" This build is not signed! ")
project.logger.warn("")
project.logger.warn("========== [WARNING] ==========")
throw new StopExecutionException()
}
}

doLast {
configurations.archives.allArtifacts.files.each {
ant.signjar(
jar: it,
alias: project.property("signing.alias"),
storepass: project.property("signing.keyStorePassword"),
keystore: project.property("signing.keyStorePath"),
keypass: project.property("signing.keyStorePassword"),
preservelastmodified: project.property("signing.preserveLastModified"),
tsaurl: project.property("signing.timestampAuthority"),
digestalg: project.property("signing.digestAlgorithm")
)
project.logger.lifecycle("JAR Signed: " + it.name)

signing.sign(it)
project.logger.lifecycle("PGP Signed: " + it.name)
}
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx512M
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2019 Alex Thomson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.github.lxgaming.mixin.launch;

import cpw.mods.modlauncher.TransformingClassLoader;
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.ClassNode;

import java.nio.file.Path;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;

public class MixinLaunchPluginService implements ILaunchPluginService {

public static final String NAME = "mixinbootstrap";

private static final List<String> SKIP_PACKAGES = Arrays.asList(
"org.objectweb.asm.",
"org.spongepowered.asm.launch.",
"org.spongepowered.asm.lib.",
"org.spongepowered.asm.mixin.",
"org.spongepowered.asm.service.",
"org.spongepowered.asm.util."
);

@Override
public String name() {
return MixinLaunchPluginService.NAME;
}

@Override
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty) {
throw new UnsupportedOperationException("Outdated ModLauncher");
}

@Override
public boolean processClass(Phase phase, ClassNode classNode, Type classType) {
throw new UnsupportedOperationException("Outdated ModLauncher");
}

@Override
public EnumSet<Phase> handlesClass(Type classType, boolean isEmpty, String reason) {
return EnumSet.noneOf(Phase.class);
}

@Override
public boolean processClass(Phase phase, ClassNode classNode, Type classType, String reason) {
return false;
}

@Override
public void addResources(List<Map.Entry<String, Path>> resources) {
}

@Override
public void initializeLaunch(ITransformerLoader transformerLoader, Path[] specialPaths) {
TransformingClassLoader classLoader = (TransformingClassLoader) Thread.currentThread().getContextClassLoader();
classLoader.addTargetPackageFilter(name -> SKIP_PACKAGES.stream().noneMatch(name::startsWith));
}

@Override
public <T> T getExtension() {
return null;
}
}
Loading

0 comments on commit 727009a

Please sign in to comment.