Workaround for getting tests to work.
[SquirrelJME.git] / buildSrc / src / main / java / cc / squirreljme / plugin / multivm / VMRomTask.java
blobb7339ee6b09468dc6bce12a64e4ba556fd696cde
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
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;
15 import lombok.Getter;
16 import org.gradle.api.DefaultTask;
17 import org.gradle.api.provider.Provider;
18 import org.gradle.api.tasks.Internal;
20 /**
21 * This task is responsible for compiling a combined ROM, if a VM uses one.
23 * @since 2020/08/23
25 public class VMRomTask
26 extends DefaultTask
27 implements VMBaseTask, VMExecutableTask
29 /** The classifier used. */
30 @Internal
31 @Getter
32 public final SourceTargetClassifier classifier;
34 /**
35 * Initializes the library creation task.
37 * @param __classifier The classifier used.
38 * @throws NullPointerException On null arguments.
39 * @since 2020/08/07
41 @Inject
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(
56 this, __classifier));
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(
64 this, __classifier));
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));
73 /**
74 * Returns the output path of the archive.
76 * @return The output path.
77 * @since 2020/08/07
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())));