Limit how often GC can be run.
[SquirrelJME.git] / buildSrc / src / main / java / cc / squirreljme / plugin / multivm / VMDumpLibraryTask.java
blobbe53f9a34acd3626c990e881136e6f5ebc13eddd
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 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.io.File;
14 import java.nio.file.Paths;
15 import javax.inject.Inject;
16 import lombok.Getter;
17 import org.gradle.api.DefaultTask;
18 import org.gradle.api.Project;
19 import org.gradle.api.provider.Provider;
20 import org.gradle.api.tasks.Internal;
21 import org.gradle.jvm.tasks.Jar;
23 /**
24 * This is used to dump the output compilation result of a library.
26 * @since 2021/05/16
28 public class VMDumpLibraryTask
29 extends DefaultTask
30 implements VMExecutableTask
32 /** The classifier used. */
33 @Internal
34 @Getter
35 public final SourceTargetClassifier classifier;
37 /**
38 * Initializes the library dumping task.
40 * @param __classifier The source set used.
41 * @param __libTask The library task.
42 * @throws NullPointerException On null arguments.
43 * @since 2021/05/16
45 @Inject
46 public VMDumpLibraryTask(SourceTargetClassifier __classifier,
47 VMLibraryTask __libTask)
48 throws NullPointerException
50 if (__classifier == null || __libTask == null)
51 throw new NullPointerException("NARG");
53 Project project = this.getProject();
54 Jar baseJar = VMHelpers.jarTask(project, __classifier.getSourceSet());
56 // These are used at the build stage
57 this.classifier = __classifier;
59 // Set details of this task
60 this.setGroup("squirreljme");
61 this.setDescription("Dumps the compiled library for debugging.");
63 // We need to build the library before we can dump it
64 this.dependsOn(baseJar,
65 __libTask);
67 // The input is the output of the library task, which is a glob
68 Provider<File> file = this.getProject().provider(
69 () -> __libTask.getOutputs().getFiles().getSingleFile());
70 this.getInputs().file(file);
72 // The output depends on the task and its source set
73 this.getOutputs().file(this.getProject().provider(
74 () -> Paths.get(file.get() + ".yml").toFile()));
75 this.getOutputs().upToDateWhen(new VMLibraryTaskUpToDate(
76 __classifier.getTargetClassifier()));
78 // Performs the action of the task
79 this.doLast(new VMDumpLibraryTaskAction(__classifier));