Skip to content
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: 2 additions & 2 deletions .github/workflows/check-spotless.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: License Check
name: Spotless Check

on:
push:
Expand All @@ -10,5 +10,5 @@ jobs:
call-check:
uses: SpongePowered/.github/.github/workflows/shared-check-spotless.yaml@master
with:
runtime_version: 17
runtime_version: 21
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:
call-build:
uses: SpongePowered/.github/.github/workflows/shared-ci.yaml@master
with:
runtime_version: 17
runtime_version: 21
extra_gradle_publish_params: closeAndReleaseSonatypeStagingRepository
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ jobs:
call-analyze:
uses: SpongePowered/.github/.github/workflows/shared-codeql-analysis.yaml@master
with:
runtime_version: 17
runtime_version: 21
secrets: inherit
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tasks {
links(
"https://logging.apache.org/log4j/2.x/javadoc/log4j-api/",
"https://checkerframework.org/api/",
"https://maven.apache.org/ref/3.8.6/maven-artifact/apidocs",
"https://maven.apache.org/ref/3.9.16/maven-artifact/apidocs",
"https://jd.spongepowered.org/plugin-meta/0.8.2/"
)
}
Expand Down Expand Up @@ -75,8 +75,7 @@ indraCrossdoc {
}

dependencies {
api("org.spongepowered:plugin-meta:0.8.2")
api("org.apache.maven:maven-artifact:3.8.6")
api("org.spongepowered:plugin-meta:0.9.0-SNAPSHOT")
api("org.apache.logging.log4j:log4j-api:2.17.0")
compileOnlyApi("org.checkerframework:checker-qual:3.26.0")
}
Expand Down
20 changes: 15 additions & 5 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import org.spongepowered.plugin.builtin.StandardPluginMetadataReader;
import org.spongepowered.plugin.discovery.PluginMetadataReader;
import org.spongepowered.plugin.discovery.PluginResourceLocator;
import org.spongepowered.plugin.builtin.jvm.locator.ClasspathPluginResourceLocator;
import org.spongepowered.plugin.builtin.jvm.locator.DirectoryPluginResourceLocator;
import org.spongepowered.plugin.builtin.jvm.locator.EnvironmentPluginResourceLocator;

module org.spongepowered.plugin.spi {
requires transitive org.spongepowered.plugin.metadata;
requires transitive org.apache.logging.log4j;
Expand All @@ -7,9 +14,12 @@
exports org.spongepowered.plugin.builtin;
exports org.spongepowered.plugin.builtin.jvm;
exports org.spongepowered.plugin.builtin.jvm.locator;
exports org.spongepowered.plugin.discovery;

provides PluginResourceLocator with
ClasspathPluginResourceLocator,
DirectoryPluginResourceLocator,
EnvironmentPluginResourceLocator;

provides org.spongepowered.plugin.PluginResourceLocatorService with
org.spongepowered.plugin.builtin.jvm.locator.ClasspathPluginResourceLocatorService,
org.spongepowered.plugin.builtin.jvm.locator.DirectoryPluginResourceLocatorService,
org.spongepowered.plugin.builtin.jvm.locator.EnvironmentPluginResourceLocatorService;
}
provides PluginMetadataReader with StandardPluginMetadataReader;
}
5 changes: 4 additions & 1 deletion src/main/java/org/spongepowered/plugin/PluginContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ public interface PluginContainer extends ResourceQueryable {
/**
* @return The instance
*/
Object instance();
@Deprecated(forRemoval = true, since = "0.5.0")
default Object instance() {
return this;
}
}
68 changes: 0 additions & 68 deletions src/main/java/org/spongepowered/plugin/PluginLanguageService.java

This file was deleted.

18 changes: 9 additions & 9 deletions src/main/java/org/spongepowered/plugin/PluginLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@
package org.spongepowered.plugin;

import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.spongepowered.plugin.discovery.PluginResource;
import org.spongepowered.plugin.metadata.PluginMetadata;

/**
* A loader used to create and load {@link PluginContainer plugins}.
* A service used to create and load {@link PluginContainer plugins}.
* <p>
* Implementors of this class are required to have a no-args constructor
* @param <P> The container type
*/
public interface PluginLoader<P extends PluginContainer> {
public interface PluginLoader extends PluginService {

/**
* @return The {@link ArtifactVersion version}, as a maven artifact
*/
ArtifactVersion version();

/**
* Instructs the loader to load the {@link PluginCandidate candidate} as a {@link PluginContainer container} into the
* target {@link ClassLoader classloader}.
* Loads the plugin candidate as a {@link PluginContainer container}.
*
* @param environment The environment
* @param candidate The candidate
* @param targetClassLoader The classloader
* @throws InvalidPluginException If the candidate is invalid
* @param resource The candidate resource
* @param metadata The candidate metadata
* @return The {@link PluginContainer container}
*/
P loadPlugin(Environment environment, PluginCandidate candidate, ClassLoader targetClassLoader) throws InvalidPluginException;
PluginContainer loadPlugin(Environment environment, PluginResource resource, PluginMetadata metadata) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.plugin.builtin.jvm.locator;
package org.spongepowered.plugin;

import org.spongepowered.plugin.PluginResourceLocatorService;
import org.spongepowered.plugin.builtin.jvm.JVMPluginResource;

public interface JVMPluginResourceLocatorService extends PluginResourceLocatorService<JVMPluginResource> {
public interface PluginService {

/**
* @return The {@link String name} of this service.
*/
String name();
}
11 changes: 1 addition & 10 deletions src/main/java/org/spongepowered/plugin/blackboard/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,13 @@

public final class Keys {

/**
* Indicates whether the target environment is a development environment.
* <p>
* The implementation may choose to interpret this flag in any number of ways.
* For example, it may disable certain behaviour in a development environment; or
* even change the way it handles some behaviour entirely.
*/
public static final Key<Boolean> DEVELOPMENT = Key.of("development", Boolean.class);

public static final Key<String> VERSION = Key.of("version", String.class);

public static final Key<Path> BASE_DIRECTORY = Key.of("base_directory", Path.class);

public static final Key<List<Path>> PLUGIN_DIRECTORIES = Key.of("plugin_directories", List.class);

public static final Key<String> METADATA_FILE_PATH = Key.of("metadata_file_path", String.class);
public static final Key<List<String>> METADATA_FILE_PATHS = Key.of("metadata_file_paths", List.class);

private Keys() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package org.spongepowered.plugin.builtin;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.plugin.Environment;
import org.spongepowered.plugin.blackboard.Blackboard;
Expand All @@ -36,10 +35,6 @@ public final class StandardEnvironment implements Environment {
private final Logger logger;
private final Blackboard blackboard;

public StandardEnvironment() {
this(LogManager.getLogger("plugin"));
}

public StandardEnvironment(final Logger logger) {
this.logger = Objects.requireNonNull(logger, "logger");
this.blackboard = new StandardBlackboard();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.plugin.PluginCandidate;
import org.spongepowered.plugin.PluginContainer;
import org.spongepowered.plugin.discovery.PluginResource;
import org.spongepowered.plugin.metadata.PluginMetadata;

import java.net.URI;
Expand All @@ -37,50 +37,38 @@

public class StandardPluginContainer implements PluginContainer {

private final PluginCandidate candidate;
private final PluginResource resource;
private final PluginMetadata metadata;
private final Logger logger;
private Object instance;

public StandardPluginContainer(final PluginCandidate candidate) {
this(Objects.requireNonNull(candidate, "candidate"), LogManager.getLogger(candidate.metadata().id()));
public StandardPluginContainer(final PluginResource resource, final PluginMetadata metadata) {
this(resource, metadata, LogManager.getLogger(metadata.id()));
}

public StandardPluginContainer(final PluginCandidate candidate, final Logger logger) {
this.candidate = Objects.requireNonNull(candidate, "candidate");
public StandardPluginContainer(final PluginResource resource, final PluginMetadata metadata, final Logger logger) {
this.resource = Objects.requireNonNull(resource, "resource");
this.metadata = Objects.requireNonNull(metadata, "metadata");
this.logger = Objects.requireNonNull(logger, "logger");
}

@Override
public final PluginMetadata metadata() {
return this.candidate.metadata();
return this.metadata;
}

@Override
public final Logger logger() {
return this.logger;
}

@Override
public final Object instance() {
return this.instance;
}

protected void initializeInstance(final Object instance) {
if (this.instance != null) {
throw new RuntimeException(String.format("Attempt made to set the plugin within container '%s' twice!",
this.candidate.metadata().id()));
}
this.instance = Objects.requireNonNull(instance, "instance");
}

@Override
public Optional<URI> locateResource(final String path) {
return this.candidate.resource().locateResource(path);
return this.resource.locateResource(path);
}

@Override
public int hashCode() {
return Objects.hashCode(this.candidate.metadata().id());
return Objects.hashCode(this.metadata.id());
}

@Override
Expand All @@ -93,12 +81,12 @@ public boolean equals(final Object that) {
return false;
}

return this.candidate.metadata().id().equals(((PluginContainer) that).metadata().id());
return this.metadata.id().equals(((PluginContainer) that).metadata().id());
}

protected StringJoiner toStringJoiner() {
return new StringJoiner(", ", this.getClass().getSimpleName() + "[", "]")
.add("metadata=" + this.candidate.metadata());
.add("metadata=" + this.metadata);
}

@Override
Expand Down
Loading
Loading