Skip to content

Commit

Permalink
Add github actions for publishing.
Browse files Browse the repository at this point in the history
  • Loading branch information
LexManos committed Oct 24, 2023
1 parent efc3e92 commit 75690cc
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 29 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish

on:
push:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:
uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@main
with:
java: 8
gradle_tasks: "publish"
artifact_name: "securemodules"
secrets:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }}
PROMOTE_ARTIFACT_USERNAME: ${{ secrets.PROMOTE_ARTIFACT_USERNAME }}
PROMOTE_ARTIFACT_PASSWORD: ${{ secrets.PROMOTE_ARTIFACT_PASSWORD }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
34 changes: 20 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import net.minecraftforge.gradleutils.PomUtils

plugins {
id 'java-library'
id 'maven-publish'
Expand All @@ -8,8 +10,8 @@ plugins {
}

group = 'net.minecraftforge'
version = gradleutils.getTagOffsetVersion()
logger.lifecycle('Version: ' + version)
version = gradleutils.tagOffsetVersion
print("Version: $version")

java {
toolchain.languageVersion = JavaLanguageVersion.of(16)
Expand Down Expand Up @@ -38,12 +40,12 @@ changelog {
jar {
manifest {
attributes([
'Specification-Title': 'securemodules',
'Specification-Vendor': 'forge',
'Specification-Version': gradleutils.gitInfo.tag,
'Implementation-Title': project.name,
'Specification-Title': 'SecureModules',
'Specification-Vendor': 'Forge Development LLC',
'Specification-Version': gradleutils.gitInfo.tag,
'Implementation-Title': 'SecureModules',
'Implementation-Version': project.version,
'Implementation-Vendor':'forge'
'Implementation-Vendor': 'Forge Development LLC'
] as LinkedHashMap)
}
}
Expand All @@ -53,17 +55,21 @@ license {
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = 'Secure Modular handler'
description = 'Making the Java modular system provide security information'
publications.register('mavenJava', MavenPublication) {
from components.java
artifactId = 'securemodules'
pom {
name = 'Secure Modular handler'
description = 'Making the Java modular system provide security information'
license PomUtils.Licenses.LGPLv2_1
developers {
developer PomUtils.Developers.cpw
developer PomUtils.Developers.LexManos
}
}
}
repositories {
maven gradleutils.getPublishingForgeMaven()
maven gradleutils.publishingForgeMaven
}
}

Expand Down
8 changes: 4 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
dependencyResolutionManagement {
versionCatalogs {
libs {
version('asm', '9.3')
version('asm', '9.6')
library('asm', 'org.ow2.asm', 'asm' ).versionRef('asm')
library('asm-tree', 'org.ow2.asm', 'asm-tree' ).versionRef('asm')
library('asm-commons', 'org.ow2.asm', 'asm-commons').versionRef('asm')
Expand All @@ -22,13 +22,13 @@ dependencyResolutionManagement {
library('junit-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
library('junit-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit')
library('junit-platform-launcher', 'org.junit.platform:junit-platform-launcher:1.10.0')
bundle('junit-runtime', ['junit-engine', 'junit-platform-launcher']) // Force Gradle to load the JUnit Platform Launcher from the module-path
bundle('junit-runtime', ['junit-engine', 'junit-platform-launcher'])

library('unsafe', 'net.minecraftforge:unsafe:0.9.0')
library('unsafe', 'net.minecraftforge:unsafe:0.9.2')
}
}
}

rootProject.name = 'securemodules'
rootProject.name = 'SecureModules'
include 'sm-jmh'
include 'sm-test'
2 changes: 1 addition & 1 deletion src/main/java/cpw/mods/cl/ModuleClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ModuleClassLoader extends SecureModuleClassLoader {
* API Ment for modders to consume
* ======================================================================
*/
public ModuleClassLoader(String name, Configuration config, @Deprecated List<ModuleLayer> parentLayers) {
public ModuleClassLoader(String name, Configuration config, List<ModuleLayer> parentLayers) {
super(name, config, parentLayers, null);
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
requires org.objectweb.asm;
requires org.objectweb.asm.tree;
requires java.base;

requires jdk.unsupported;
requires net.minecraftforge.unsafe;

// TODO: Move UnionFS out into its own project
// TODO: [SM] Move UnionFS out into its own project
provides java.nio.file.spi.FileSystemProvider
with cpw.mods.niofs.union.UnionFileSystemProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.stream.Stream;

public class SecureModuleClassLoader extends SecureClassLoader {
@SuppressWarnings("unused")
private static void log(String message) { System.out.println(message); } // TODO: [SM] Introduce proper logging framework

static {
Expand All @@ -53,7 +54,6 @@ private static void setupModularURLHandler() {
private final Map<ModuleReference, ModuleReader> moduleReaders = new ConcurrentHashMap<>();
private final List<ClassLoader> allParentLoaders;

@Deprecated(forRemoval = true)
protected ClassLoader fallbackClassLoader = ClassLoader.getPlatformClassLoader();

public SecureModuleClassLoader(String name, Configuration config, List<ModuleLayer> parentLayers) {
Expand Down Expand Up @@ -86,18 +86,18 @@ public SecureModuleClassLoader(String name, Configuration config, List<ModuleLay
this.allParentLoaders.removeAll(overlaping);


// So 'resolvedRoots' seems to be trying to be our special 'SecureJar' references, TODO: See if we actually need it.
// Find all modules for this config, if the reference is our special Secure reference, we can define packages with security info.
for (var module : config.modules()) {
var ref = module.reference();
this.ourModules.put(ref.descriptor().name(), ref);
for (var pkg : ref.descriptor().packages())
this.packageToOurModules.put(pkg, module);

if (ref instanceof SecureModuleReference smr) {
if (ref instanceof SecureModuleReference smr)
this.ourModulesSecure.put(smr.descriptor().name(), smr);
for (var pkg : smr.descriptor().packages())
this.packageToOurModules.put(pkg, module);
} else {
log("Invalid ModuleClassLoader module: " + module);
}
//else
// log("[SecureModuleClassLoader] Insecure module: " + module);

}

/*
Expand Down Expand Up @@ -371,7 +371,11 @@ protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundE
var parent = this.packageToParentLoader.get(pkg);
if (parent == null)
parent = fallbackClassLoader;
c = parent.loadClass(name);

if (parent == null)
c = super.loadClass(name, false);
else
c = parent.loadClass(name);
}
}
}
Expand Down

0 comments on commit 75690cc

Please sign in to comment.