Skip to content

Commit

Permalink
Merge pull request #92 from SpongePowered/feature/guice-module
Browse files Browse the repository at this point in the history
plugin-development: Support specifying guice module
  • Loading branch information
aromaa authored Oct 3, 2024
2 parents fe70460 + 2471838 commit 9db0926
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
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;
}
}

0 comments on commit 9db0926

Please sign in to comment.