1717import net .minecraftforge .mcmaven .impl .util .Constants ;
1818import net .minecraftforge .mcmaven .impl .Mavenizer ;
1919import net .minecraftforge .mcmaven .impl .util .POMBuilder ;
20+ import net .minecraftforge .mcmaven .impl .util .POMBuilder .Dependencies ;
21+ import net .minecraftforge .mcmaven .impl .util .POMBuilder .Dependencies .Dependency ;
2022import net .minecraftforge .mcmaven .impl .util .Task ;
2123import net .minecraftforge .mcmaven .impl .util .Util ;
2224import net .minecraftforge .util .data .json .JsonData ;
@@ -228,6 +230,7 @@ private static Task pom(File build, Patcher patcher, String version, Artifact cl
228230 .addKnown ("data" , patcher .getDataHash ())
229231 .addKnown ("extra" , Util .replace (clientExtra , Object ::toString ))
230232 .addKnown ("mappings" , Util .replace (mappings , Object ::toString ))
233+ .addKnown ("code-version" , "1" )
231234 ;
232235
233236 if (output .exists () && cache .isSame ())
@@ -243,6 +246,8 @@ private static Task pom(File build, Patcher patcher, String version, Artifact cl
243246 dependencies .add (mappings );
244247
245248 patcher .forAllLibraries (dependencies ::add , Artifact ::hasNoOs );
249+
250+ addExtraRuntimeToPom (patcher , dependencies );
246251 });
247252
248253 FileUtils .ensureParent (output );
@@ -257,6 +262,27 @@ private static Task pom(File build, Patcher patcher, String version, Artifact cl
257262 });
258263 }
259264
265+ @ SuppressWarnings ("deprecation" )
266+ private static void addExtraRuntimeToPom (Patcher patcher , Dependencies deps ) {
267+ if (patcher .config .extraDependencies == null )
268+ return ;
269+
270+ // Following https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#dependency-scope
271+ // PROVIDED == 'compileOnly'
272+ if (patcher .config .extraDependencies .compileOnly != null ) {
273+ for (var descriptor : patcher .config .extraDependencies .compileOnly ) {
274+ deps .add (Artifact .from (descriptor ), Dependency .Scope .PROVIDED );
275+ }
276+ }
277+
278+ // RUNTIME = 'runtimeOnly'
279+ if (patcher .config .extraDependencies .runtimeOnly != null ) {
280+ for (var descriptor : patcher .config .extraDependencies .runtimeOnly ) {
281+ deps .add (Artifact .from (descriptor ), Dependency .Scope .RUNTIME );
282+ }
283+ }
284+ }
285+
260286 @ SuppressWarnings ("deprecation" )
261287 protected GradleModule .Variant [] classVariants (Mappings mappings , Patcher patcher , Artifact ... extraDeps ) {
262288 var extra = new ArrayList <>(Arrays .asList (extraDeps ));
0 commit comments