1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
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
.Path
;
14 import javax
.inject
.Inject
;
16 import org
.gradle
.api
.DefaultTask
;
17 import org
.gradle
.api
.provider
.Provider
;
18 import org
.gradle
.api
.tasks
.Internal
;
21 * This task is responsible for compiling a combined ROM, if a VM uses one.
25 public class VMRomTask
27 implements VMBaseTask
, VMExecutableTask
29 /** The classifier used. */
32 public final SourceTargetClassifier classifier
;
35 * Initializes the library creation task.
37 * @param __classifier The classifier used.
38 * @throws NullPointerException On null arguments.
42 public VMRomTask(SourceTargetClassifier __classifier
)
43 throws NullPointerException
45 if (__classifier
== null)
46 throw new NullPointerException("NARG");
48 this.classifier
= __classifier
;
50 // Set details of this task
51 this.setGroup("squirreljmeGeneral");
52 this.setDescription("Builds the combined ROM.");
54 // The JAR we are compiling has to be built first
55 this.dependsOn(new VMRomDependencies(
58 // Only execute this task in certain cases
59 this.onlyIf(new CheckRomShouldBuild(
60 __classifier
.getTargetClassifier()));
62 // The inputs of this tasks are all the ROM files to merge
63 this.getInputs().files(new VMRomInputs(
66 // And the output is a primary single file for the ROM
67 this.getOutputs().file(this.outputPath());
69 // Action for performing the actual linkage of the ROM
70 this.doLast(new VMRomTaskAction(__classifier
));
74 * Returns the output path of the archive.
76 * @return The output path.
79 public final Provider
<Path
> outputPath()
81 return this.getProject().provider(() -> VMHelpers
.cacheDir(
82 this.getProject(), this.classifier
).get()
83 .resolve(this.classifier
.getVmType()
84 .outputRomName(this.classifier
.getSourceSet(),
85 this.classifier
.getBangletVariant())));