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
.SquirrelJMEPluginConfiguration
;
13 import cc
.squirreljme
.plugin
.multivm
.ident
.SourceTargetClassifier
;
14 import java
.util
.Arrays
;
15 import java
.util
.Collection
;
16 import java
.util
.Collections
;
17 import java
.util
.LinkedHashSet
;
18 import java
.util
.List
;
19 import java
.util
.concurrent
.Callable
;
20 import org
.gradle
.api
.Project
;
21 import org
.gradle
.api
.Task
;
22 import org
.gradle
.api
.tasks
.SourceSet
;
25 * Dependencies used for the full SquirrelJME suite.
29 public class VMFullSuiteDepends
30 implements Callable
<Iterable
<Task
>>
32 /** The task to execute for. */
33 protected final Task task
;
35 /** The classifier target used. */
36 protected final SourceTargetClassifier classifier
;
39 * Initializes the dependency grabber.
41 * @param __task The task to run off.
42 * @param __classifier The classifier used.
43 * @throws NullPointerException On null arguments.
46 public VMFullSuiteDepends(Task __task
, SourceTargetClassifier __classifier
)
47 throws NullPointerException
49 if (__task
== null || __classifier
== null)
50 throw new NullPointerException("NARG");
53 this.classifier
= __classifier
;
61 public Iterable
<Task
> call()
63 Project root
= this.task
.getProject().getRootProject();
64 Collection
<Task
> tasks
= new LinkedHashSet
<>();
66 // We need the emulator to be built and working before we can actually
67 // run our full suite accordingly
68 for (String emulatorProject
: this.classifier
.getVmType()
69 .emulatorProjects(this.classifier
.getBangletVariant()))
71 Task emulJar
= root
.project(emulatorProject
).getTasks()
77 // Which source sets should be used
78 List
<String
> sourceSets
;
79 if (!this.classifier
.isMainSourceSet())
80 sourceSets
= Arrays
.asList(SourceSet
.MAIN_SOURCE_SET_NAME
,
81 this.classifier
.getSourceSet());
83 sourceSets
= Collections
.singletonList(
84 this.classifier
.getSourceSet());
86 // Go through every single project, and try to use it as a dependency
87 for (Project project
: root
.getAllprojects())
89 // Ignore non-SquirrelJME projects
90 SquirrelJMEPluginConfiguration config
=
91 SquirrelJMEPluginConfiguration
.configurationOrNull(project
);
95 // Include whatever libraries are needed for the source set
96 for (String sourceSet
: sourceSets
)
98 // Find the associated library task
99 Task libTask
= project
.getTasks().findByName(TaskInitialization
101 this.classifier
.withSourceSet(sourceSet
)));
105 // Use all of their dependencies, if not yet added
106 for (VMLibraryTask subDep
: new VMRunDependencies(
107 libTask
.getProject(),
108 this.classifier
.withSourceSet(sourceSet
))
114 return Collections
.unmodifiableCollection(tasks
);