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
;
17 import org
.gradle
.api
.DefaultTask
;
18 import org
.gradle
.api
.provider
.Provider
;
21 * This task is used to generate a built-in RatufaCoat Rom.
25 public class NanoCoatBuiltInTask
29 /** The classifier used. */
31 private final SourceTargetClassifier classifier
;
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.
42 public NanoCoatBuiltInTask(SourceTargetClassifier __classifier
,
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(),
65 // Actual running of everything
66 this.doFirst(new NanoCoatBuiltInCleanTaskAction(__classifier
,
67 this.romBasePath(), this.specificPath(), this.sharedPath()));
68 this.doLast(new NanoCoatBuiltInTaskAction(__classifier
));
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.
78 private Provider
<Path
> inputPath(VMRomTask __romTask
)
80 return this.getProject().provider(() -> __romTask
.getOutputs()
81 .getFiles().getSingleFile().toPath());
85 * Returns the base ROM path.
87 * @return The base ROM path.
90 public final Provider
<Path
> romBasePath()
92 return this.getProject().provider(() -> this.getProject().getRootDir()
93 .toPath().resolve("nanocoat").resolve("rom"));
97 * Returns the shared output path.
99 * @return The shared output path.
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.
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())));