@@ -98,22 +98,35 @@ public void applyToProject(
9898 final TaskProvider <JavaExec > runServer = this .createRunTask (spongeRuntime , sponge );
9999
100100 project .afterEvaluate (a -> {
101- if (sponge .apiVersion ().isPresent ()) {
101+ if (sponge .minecraftVersion (). isPresent () && sponge . apiVersion ().isPresent ()) {
102102 // TODO: client run task
103103 /*project.getLogger().lifecycle("SpongeAPI '{}' has been set within the 'spongeApi' configuration. 'runClient' and 'runServer'"
104104 + " tasks will be available. You may use these to test your plugin.", sponge.version().get());*/
105105
106106 spongeRuntime .configure (config -> {
107+ final String minecraftVersion = sponge .minecraftVersion ().get ();
107108 final String apiVersion = sponge .apiVersion ().get ();
108109
110+ config .getAttributes ().attribute (
111+ SpongeVersioningMetadataRule .MINECRAFT_TARGET ,
112+ minecraftVersion
113+ );
114+
109115 config .getAttributes ().attribute (
110116 SpongeVersioningMetadataRule .API_TARGET ,
111117 generateApiReleasedVersion (apiVersion )
112118 );
113119 });
114120 } else {
115- project .getLogger ().info ("SpongeAPI version has not been set within the 'sponge' configuration via the 'version' task. No "
116- + "tasks will be available to run a client or server session for debugging." );
121+ if (!sponge .minecraftVersion ().isPresent ()) {
122+ project .getLogger ().info ("Minecraft version has not been set within the 'sponge' configuration via the 'minecraftVersion' task. No "
123+ + "tasks will be available to run a client or server session for debugging." );
124+ }
125+
126+ if (!sponge .apiVersion ().isPresent ()) {
127+ project .getLogger ().info ("SpongeAPI version has not been set within the 'sponge' configuration via the 'version' task. No "
128+ + "tasks will be available to run a client or server session for debugging." );
129+ }
117130 runServer .configure (t -> t .setEnabled (false ));
118131 }
119132 if (sponge .injectRepositories ().get ()) {
@@ -184,13 +197,14 @@ private void addApiDependency(final SpongePluginExtension sponge) {
184197
185198 private NamedDomainObjectProvider <Configuration > addRuntimeDependency (final SpongePluginExtension sponge ) {
186199 this .project .getDependencies ().getComponents ().withModule ("org.spongepowered:spongevanilla" , SpongeVersioningMetadataRule .class );
200+ this .project .getDependencies ().getAttributesSchema ().attribute (SpongeVersioningMetadataRule .MINECRAFT_TARGET ).getCompatibilityRules ().add (ApiVersionCompatibilityRule .class );
187201 this .project .getDependencies ().getAttributesSchema ().attribute (SpongeVersioningMetadataRule .API_TARGET ).getCompatibilityRules ().add (ApiVersionCompatibilityRule .class );
188202 return this .project .getConfigurations ().register ("spongeRuntime" , conf -> {
189203 conf .defaultDependencies (a -> {
190204 final Dependency dep = this .project .getDependencies ().create (
191205 Constants .Dependencies .SPONGE_GROUP
192206 + ":" + sponge .platform ().get ().artifactId ()
193- + ":+:universal" );
207+ + ":" + sponge . minecraftVersion (). getOrElse ( "" ) + " +:universal" );
194208
195209 a .add (dep );
196210 });
0 commit comments