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 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
;
14 import java
.nio
.file
.Paths
;
15 import javax
.inject
.Inject
;
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
;
24 * This is used to dump the output compilation result of a library.
28 public class VMDumpLibraryTask
30 implements VMExecutableTask
32 /** The classifier used. */
35 public final SourceTargetClassifier classifier
;
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.
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
,
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
));