Limit how often GC can be run.
[SquirrelJME.git] / buildSrc / src / main / java / cc / squirreljme / plugin / multivm / NanoCoatBuiltInTask.java
blob23846837632f3c0ef6fabd2152b2a26916eb9135
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // Multi-Phasic Applications: SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc.squirreljme.plugin.multivm;
12 import cc.squirreljme.plugin.multivm.ident.SourceTargetClassifier;
13 import java.nio.file.Files;
14 import java.nio.file.Path;
15 import javax.inject.Inject;
16 import lombok.Getter;
17 import org.gradle.api.DefaultTask;
18 import org.gradle.api.provider.Provider;
20 /**
21 * This task is used to generate a built-in RatufaCoat Rom.
23 * @since 2023/05/31
25 public class NanoCoatBuiltInTask
26 extends DefaultTask
27 implements VMBaseTask
29 /** The classifier used. */
30 @Getter
31 private final SourceTargetClassifier classifier;
33 /**
34 * Initializes the NanoCoat built-in setup.
36 * @param __classifier The classifier used.
37 * @param __romTask The task used to create the ROM.
38 * @throws NullPointerException On null arguments.
39 * @since 2023/05/31
41 @Inject
42 public NanoCoatBuiltInTask(SourceTargetClassifier __classifier,
43 VMRomTask __romTask)
44 throws NullPointerException
46 if (__classifier == null || __romTask == null)
47 throw new NullPointerException("NARG");
49 this.classifier = __classifier;
51 // Set details of this task
52 this.setGroup("squirreljmeGeneral");
53 this.setDescription("Copies the ROM to NanoCoat.");
55 // Depends on the ROM being built
56 this.dependsOn(__romTask);
58 // The inputs are the ROM task's output
59 this.getInputs().file(this.inputPath(__romTask));
61 // And the output is a primary single file for the ROM
62 this.getOutputs().dirs(this.specificPath(),
63 this.sharedPath());
65 // Actual running of everything
66 this.doFirst(new NanoCoatBuiltInCleanTaskAction(__classifier,
67 this.romBasePath(), this.specificPath(), this.sharedPath()));
68 this.doLast(new NanoCoatBuiltInTaskAction(__classifier));
71 /**
72 * Returns the input path to use for this task.
74 * @param __romTask The ROM task.
75 * @return The output of the task, used for input.
76 * @since 2023/05/31
78 private Provider<Path> inputPath(VMRomTask __romTask)
80 return this.getProject().provider(() -> __romTask.getOutputs()
81 .getFiles().getSingleFile().toPath());
84 /**
85 * Returns the base ROM path.
87 * @return The base ROM path.
88 * @since 2023/09/03
90 public final Provider<Path> romBasePath()
92 return this.getProject().provider(() -> this.getProject().getRootDir()
93 .toPath().resolve("nanocoat").resolve("rom"));
96 /**
97 * Returns the shared output path.
99 * @return The shared output path.
100 * @since 2023/09/03
102 public final Provider<Path> sharedPath()
104 return this.getProject().provider(() ->
105 this.romBasePath().get().resolve("shared"));
109 * Returns the shared specific path.
111 * @return The shared specific path.
112 * @since 2023/09/03
114 public final Provider<Path> specificPath()
116 return this.getProject().provider(() ->
117 this.romBasePath().get().resolve("specific").
118 resolve(String.format("%s_%s", this.classifier.getSourceSet(),
119 this.classifier.getTargetClassifier().getClutterLevel())));