Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin-development: Support specifying guice module #92

Merged
merged 1 commit into from
Oct 3, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ sponge {
displayName("Example")
version("0.1")
entrypoint("org.spongepowered.example.Example")
guiceModule("org.spongepowered.example.ExampleModule")
description("Just testing things...")
property("boolean-property", true)
property("int-property", 3)
property("string-property", "test")
links {
homepage("https://spongepowered.org")
source("https://spongepowered.org/source")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@
"load-order": "after",
"optional": false
}
]
],
"properties": {
"guice-module": "org.spongepowered.example.ExampleModule",
"boolean-property": "true",
"int-property": "3",
"string-property": "test"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,8 @@ public void description(final String description) {
this.description.set(description);
}

public void guiceModule(final String guiceModule) {
this.property("guice-module", guiceModule);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.gradle.api.Action;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Nested;
Expand All @@ -46,6 +47,8 @@ public abstract class PluginInheritableConfiguration {

private final NamedDomainObjectContainer<PluginDependencyConfiguration> dependencies;

private final MapProperty<String, Object> properties;


@Inject
public PluginInheritableConfiguration(final ObjectFactory objects) {
Expand All @@ -55,6 +58,7 @@ public PluginInheritableConfiguration(final ObjectFactory objects) {

this.contributors = objects.domainObjectContainer(PluginContributorConfiguration.class);
this.dependencies = objects.domainObjectContainer(PluginDependencyConfiguration.class);
this.properties = objects.mapProperty(String.class, Object.class);
}

@Input
Expand Down Expand Up @@ -110,4 +114,14 @@ public void dependencies(final Action<? super NamedDomainObjectContainer<PluginD
public void dependency(final String name, final Action<? super PluginDependencyConfiguration> action) {
this.dependencies.register(name, action);
}

@Input
@Optional
public MapProperty<String, Object> getProperties() {
return this.properties;
}

public void property(final String key, final Object value) {
this.properties.put(key, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ private <T extends StandardInheritable.AbstractBuilder<?, T>> T populateBuilder(

builder.addDependency(dependencyBuilder.build());
}

builder.properties(src.getProperties().get());
return builder;
}
}