Cherry pick the banglets and such from wip-l1summercoat, this will be the basis for...
[SquirrelJME.git] / buildSrc / src / main / java / cc / squirreljme / plugin / multivm / VMRunTask.java
blob4e34c0ce6e367b05c1822d14d42b8ce343ae99f7
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 javax.inject.Inject;
14 import lombok.Getter;
15 import org.gradle.api.DefaultTask;
16 import org.gradle.api.tasks.Internal;
18 /**
19 * Used to run the virtual machine.
21 * @since 2020/08/07
23 public class VMRunTask
24 extends DefaultTask
25 implements VMBaseTask, VMExecutableTask
27 /** The classifier used. */
28 @Internal
29 @Getter
30 protected final SourceTargetClassifier classifier;
32 /**
33 * Initializes the task.
35 * @param __classifier The classifier used.
36 * @param __libTask The task used to create libraries, this may be directly
37 * depended upon.
38 * @since 2020/08/07
40 @Inject
41 public VMRunTask(SourceTargetClassifier __classifier,
42 VMLibraryTask __libTask)
43 throws NullPointerException
45 if (__classifier == null || __libTask == null)
46 throw new NullPointerException("NARG");
48 // These are used when running
49 this.classifier = __classifier;
51 // Set details of this task
52 this.setGroup("squirreljme");
53 this.setDescription("Executes the program to start running it.");
55 // This task depends on the various VM libraries of this class
56 // depending on the dependencies along with the emulator being
57 // available as well
58 this.dependsOn(this.getProject().provider(
59 new VMRunDependencies(this, __classifier)),
60 new VMEmulatorDependencies(this,
61 __classifier.getTargetClassifier()));
63 // Only run if entry points are valid
64 this.onlyIf(new CheckForEntryPoints());
66 // Performs the action of the task
67 this.doLast(new VMRunTaskAction(__classifier));