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
.TargetClassifier
;
14 import java
.time
.Instant
;
15 import java
.util
.HashSet
;
17 import org
.gradle
.api
.Task
;
18 import org
.gradle
.api
.specs
.Spec
;
21 * This is a check to determine if a task is up-to-date or not for the library
26 public class VMLibraryTaskUpToDate
29 /** The classifier used. */
30 protected final TargetClassifier classifier
;
33 * Initializes the task dependencies.
35 * @param __classifier The classifier used.
36 * @throws NullPointerException On null arguments.
39 public VMLibraryTaskUpToDate(TargetClassifier __classifier
)
40 throws NullPointerException
42 if (__classifier
== null)
43 throw new NullPointerException("NARG");
45 this.classifier
= __classifier
;
53 public boolean isSatisfiedBy(Task __task
)
55 // Get the times the output was last changed
56 Set
<Instant
> taskOuts
= new HashSet
<>();
57 for (File f
: __task
.getOutputs().getFiles().getFiles())
58 taskOuts
.add(Instant
.ofEpochMilli(f
.lastModified()));
60 // Determine if any part of the compiler was not considered up-to-date
61 for (Task dep
: this.classifier
.getVmType().processLibraryDependencies(
62 (VMExecutableTask
)__task
, this.classifier
.getBangletVariant()))
64 for (File f
: dep
.getOutputs().getFiles().getFiles())
66 Instant fileTime
= Instant
.ofEpochMilli(f
.lastModified());
68 // One of the JARs the compiler uses is newer than the JAR we
69 // made, so this is not up-to-date!
70 for (Instant taskOut
: taskOuts
)
71 if (fileTime
.compareTo(taskOut
) > 0)
76 // Considered up to date