Skip to content

Commit

Permalink
meet 1.8.X
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jul 23, 2022
1 parent 2541760 commit 41965ca
Show file tree
Hide file tree
Showing 15 changed files with 372 additions and 209 deletions.
20 changes: 2 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,6 @@ jobs:
- name: Upload to release
uses: JasonEtco/upload-to-release@master
with:
args: ./build/libs/${{ steps.fname.outputs.result }}-all.jar application/jar
args: ./build/libs/${{ steps.fname.outputs.result }}.jar application/jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload to curseforge
uses: itsmeow/curseforge-upload@v2
with:
token: ${{ secrets.CF_API_KEY }}
project_id: 403186
game_endpoint: minecraft
file_path: ./build/libs/${{ steps.fname.outputs.result }}-all.jar
changelog: See the github release for changes.
display_name: ${{ steps.fname.outputs.result }}
game_versions: 73250:1.18.1,73250:1.18,73242:1.17.1,70886:1.16.4,70886:1.16.3,70886:1.16.2,68722:1.15.2,64806:1.14.4,2:Java 17,2:Java 16,2:Java 8,68441:Fabric
release_type: release
relations: modmenu:optionalDependency,jsmacros:requiredDependency
- uses: actions/upload-artifact@v2
with:
name: ${{ steps.fname.outputs.result }}
path: ./build/libs/*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116 changes: 47 additions & 69 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,108 +1,86 @@
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'maven-publish'
id 'java'
id "com.github.johnrengelman.shadow" version "6.0.0"
id 'maven-publish'
id 'java'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name
version = project.mod_version
version = project.property("version")
group = project.maven_group

repositories {
flatDir {
dirs 'libs'
}
mavenCentral()
maven {
name "Modmuss50 Repository"
url 'https://maven.fabricmc.net/'
url 'https://jitpack.io'
metadataSources {
artifact()
}
}
maven { url 'https://maven.terraformersmc.com/releases/' }
maven { url 'https://jitpack.io' }
maven { url 'https://www.cursemaven.com' }
}

shadowJar {
dependencies {
include(dependency("org.python:jython-standalone:2.7.2"))
}
exclude("**/*.exe") //because curseforge
zip64 true
configurations {
jsmacrosExtensionInclude
}

dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

implementation 'com.google.guava:guava:31.1-jre'
implementation 'org.slf4j:slf4j-api:2.0.0-alpha7'
implementation 'com.google.code.gson:gson:2.9.0'
testImplementation 'org.slf4j:slf4j-simple:2.0.0-alpha7'
implementation 'javassist:javassist:3.12.1.GA'
implementation "com.github.jsmacros.jsmacros:jsmacros-1.19:${project.jsmacros_version}"

// https://mvnrepository.com/artifact/org.python/jython-standalone
implementation "org.python:jython-standalone:2.7.2"
jsmacrosExtensionInclude "org.python:jython-standalone:2.7.2"

modImplementation "com.github.wagyourtail:jsmacros:${project.jsmacros_version}"

//nullable not defined so...
implementation 'com.google.code.findbugs:jsr305:3.0.2'


testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
implementation 'org.jetbrains:annotations:16.0.2'
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
}

build.finalizedBy(shadowJar)


processResources {
inputs.property "version", project.version
filesMatching("jsmacros.ext.jython.json") {
expand "dependencies": configurations.jsmacrosExtensionInclude.files.collect { it.name }.join(" ")
}
}

filesMatching("fabric.mod.json") {
expand "version": project.version
compileJava {
options.encoding = "UTF-8"
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
options.release.set(17)
}

jar {
from "LICENSE"
from "LICENSE"
from (configurations.jsmacrosExtensionInclude.files) {
include '*'
into "META-INF/jsmacrosdeps"
}
}

test {
useJUnitPlatform()
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}

// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()

}
publications {
}
repositories {
}
}
15 changes: 4 additions & 11 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx3G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19
yarn_mappings=1.19+build.1
loader_version=0.13.3

# Mod Properties
mod_version = 1.1.5
maven_group = xyz.wagyourtail
archives_base_name = jsmacros-jython
version = 1.1.6
maven_group = xyz.wagyourtail
archives_base_name = jsmacros-jython

# Dependencies
jsmacros_version=f8d39357c0
prism_version=2.0.0
graal_version=21.2.0
jsmacros_version=f59d4b875d
113 changes: 113 additions & 0 deletions src/main/java/xyz/wagyourtail/jsmacros/jython/JythonExtension.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package xyz.wagyourtail.jsmacros.jython;

import com.google.common.collect.Sets;
import org.python.core.*;
import org.python.util.PythonInterpreter;
import xyz.wagyourtail.jsmacros.core.Core;
import xyz.wagyourtail.jsmacros.core.extensions.Extension;
import xyz.wagyourtail.jsmacros.core.language.BaseLanguage;
import xyz.wagyourtail.jsmacros.core.language.BaseWrappedException;
import xyz.wagyourtail.jsmacros.core.library.BaseLibrary;
import xyz.wagyourtail.jsmacros.jython.language.impl.JythonLanguageDescription;
import xyz.wagyourtail.jsmacros.jython.library.impl.FWrapper;

import java.io.File;
import java.util.Set;

public class JythonExtension implements Extension {
private static JythonLanguageDescription languageDescription;

@Override
public void init() {
Thread t = new Thread(() -> {
try (PythonInterpreter interp = JythonLanguageDescription.createInterp(new File("./"))) {
interp.exec("print(\"Jython Loaded.\")");
} catch(Exception e) {
e.printStackTrace();
}
});
t.start();
}

@Override
public int getPriority() {
return 0;
}

@Override
public String getLanguageImplName() {
return "jython";
}

@Override
public ExtMatch extensionMatch(File file) {
if (file.getName().endsWith(".py")) {
if (file.getName().contains(getLanguageImplName())) {
return ExtMatch.MATCH_WITH_NAME;
} else {
return ExtMatch.MATCH;
}
}
return ExtMatch.NOT_MATCH;
}

@Override
public String defaultFileExtension() {
return "py";
}

@Override
public BaseLanguage<?, ?> getLanguage(Core<?, ?> core) {
if (languageDescription == null) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(JythonExtension.class.getClassLoader());
languageDescription = new JythonLanguageDescription(this, core);
Thread.currentThread().setContextClassLoader(classLoader);
}
return languageDescription;
}

@Override
public Set<Class<? extends BaseLibrary>> getLibraries() {
return Sets.newHashSet(FWrapper.class);
}

@Override
public BaseWrappedException<?> wrapException(Throwable ex) {
if (ex instanceof PyException) {
String message = ((PyType) ((PyException) ex).type).fastGetName().replace("exceptions.", "");
if (ex instanceof PySyntaxError) {
if (((PyBaseExceptionDerived)((PySyntaxError) ex).value).args instanceof PyTuple) {
PyTuple exceptionData = (PyTuple) ((PyBaseExceptionDerived) ((PySyntaxError) ex).value).args;
message += ": " + exceptionData.get(0);
PyTuple locationData = (PyTuple) exceptionData.get(1);
String fileName = (String) locationData.get(0);
int line = (int) locationData.get(1);
int col = (int) locationData.get(2);
BaseWrappedException.SourceLocation loc = new BaseWrappedException.GuestLocation(new File(fileName), -1, -1, line, col);
return new BaseWrappedException<>(ex, message, loc, ((PyException) ex).traceback != null ? wrapTraceback(((PyException) ex).traceback) : null);
}
} else {
if (((PyException) ex).value instanceof PyString) message += ": " + ((PyException) ex).value.asString();
else if (ex.getCause() != null) {
String intMessage = ex.getCause().getMessage();
if (intMessage != null) message += ": " + intMessage;
}
return new BaseWrappedException<>(ex, message, null, ((PyException) ex).traceback != null ? wrapTraceback(((PyException) ex).traceback) : null);
}
}
return null;
}


public BaseWrappedException<?> wrapTraceback(PyTraceback traceback) {
BaseWrappedException.GuestLocation loc = new BaseWrappedException.GuestLocation(new File(traceback.tb_frame.f_code.co_filename), -1, -1, traceback.tb_lineno, -1);
return new BaseWrappedException<>(traceback, " at " + traceback.tb_frame.f_code.co_name, loc, traceback.tb_next != null ? wrapTraceback((PyTraceback) traceback.tb_next) : null);
}

@Override
public boolean isGuestObject(Object o) {
return o instanceof PyObject;
}

}

This file was deleted.

Loading

0 comments on commit 41965ca

Please sign in to comment.