Skip to content

Commit

Permalink
v0.0.5 updates (#3)
Browse files Browse the repository at this point in the history
* upgraded for v1.21 spigot

* added unit test for delegate

* added api-version in plugin.yml

* fixed naming problem

* changed script loading mechanism for file

* fixed services cannot depend other service classes

* optimized reloading mechanism

* added install module api
  • Loading branch information
eric2788 authored Dec 20, 2024
1 parent 8e98b60 commit bb7dedf
Show file tree
Hide file tree
Showing 21 changed files with 390 additions and 207 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/1.21.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: build artifacts for 1.21
on:
push:
branches:
- feat/1.21
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
id: checkout-source
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'adopt'
- name: 'Package Jar'
run: mvn -B package --file ./pom.xml
- name: 'upload artifacts'
id: upload-artifacts
uses: actions/upload-artifact@v4
with:
name: groovier-plugin
path: './groovier-plugin/target'
8 changes: 1 addition & 7 deletions groovier-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
<parent>
<artifactId>groovier</artifactId>
<groupId>org.groovier</groupId>
<version>0.0.4</version>
<version>0.0.51-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>groovier-engine</artifactId>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>


<dependencies>
<dependency>
<groupId>org.groovier</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.ericlam.mc.groovier;

import com.google.inject.Module;

/**
* groovier addon
*/
public interface GroovierAddon {

/**
* install guice module
* @param module module
*/
void installModule(Module module);
}
10 changes: 2 additions & 8 deletions groovier-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@
<parent>
<artifactId>groovier</artifactId>
<groupId>org.groovier</groupId>
<version>0.0.4</version>
<version>0.0.51-SNAPSHOT</version>
</parent>


<modelVersion>4.0.0</modelVersion>

<artifactId>groovier-plugin</artifactId>
<version>${project.parent.version}.2</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>

<version>${project.parent.version}-1.21</version>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GroovierCacheManager implements ScriptCacheManager {

@Override
boolean isCached(File content) throws IOException {
return this.isCached(content.text)
return false // let it load by groovy class loader
}

@Override
Expand All @@ -20,7 +20,6 @@ class GroovierCacheManager implements ScriptCacheManager {

@Override
Class<?> getScriptOrLoad(String content, GroovyClassLoader classLoader) throws Exception {

var md5 = generateMD5(content)
cached.add(md5)
if (this.scriptCacheMap.containsKey(md5)) {
Expand All @@ -35,10 +34,9 @@ class GroovierCacheManager implements ScriptCacheManager {

@Override
Class<?> getScriptOrLoad(File file, GroovyClassLoader classLoader) throws Exception {
return this.getScriptOrLoad(file.text, classLoader)
return classLoader.parseClass(file) // groovy class loader already cached the script
}


private static def generateMD5(String s){
MessageDigest.getInstance("MD5").digest(s.bytes).encodeHex().toString()
}
Expand Down
Loading

0 comments on commit bb7dedf

Please sign in to comment.