Workaround for getting tests to work.
[SquirrelJME.git] / buildSrc / src / main / java / cc / squirreljme / plugin / multivm / ident / SourceTargetClassifier.java
blob3370ed9960b130afbb70b20030df8bce1f933841
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // Multi-Phasic Applications: 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.ident;
12 import cc.squirreljme.plugin.multivm.BangletVariant;
13 import cc.squirreljme.plugin.multivm.ClutterLevel;
14 import cc.squirreljme.plugin.multivm.VMHelpers;
15 import cc.squirreljme.plugin.multivm.VMSpecifier;
16 import cc.squirreljme.plugin.multivm.VMType;
17 import lombok.AllArgsConstructor;
18 import lombok.Builder;
19 import lombok.NonNull;
20 import lombok.Value;
21 import org.gradle.api.tasks.SourceSet;
23 /**
24 * Represents a source set and a target classifier.
26 * @since 2022/10/01
28 @Value
29 @AllArgsConstructor
30 @Builder
31 public class SourceTargetClassifier
33 /** The source set used. */
34 @NonNull
35 String sourceSet;
37 /** The classifier for the target that is used. */
38 @NonNull
39 TargetClassifier targetClassifier;
41 /**
42 * Initializes the classifier.
44 * @param __sourceSet The source set.
45 * @param __vmType The virtual machine type.
46 * @param __variant The variant used.
47 * @param __clutterLevel The clutter level used.
48 * @since 2022/10/01
50 public SourceTargetClassifier(String __sourceSet, VMSpecifier __vmType,
51 BangletVariant __variant, ClutterLevel __clutterLevel)
53 this(__sourceSet, new TargetClassifier(__vmType, __variant,
54 __clutterLevel));
57 /**
58 * Returns the banglet variant used.
60 * @return The banglet variant used.
61 * @since 2022/10/01
63 public BangletVariant getBangletVariant()
65 return this.getTargetClassifier().getBangletVariant();
68 /**
69 * Returns the virtual machine type.
71 * @return The virtual machine type.
72 * @since 2022/10/01
74 public VMSpecifier getVmType()
76 return this.getTargetClassifier().getVmType();
79 /**
80 * Is this the main source set?
82 * @return If this is the main source set or not.
83 * @since 2022/10/01
85 public boolean isMainSourceSet()
87 return this.sourceSet.equals(SourceSet.MAIN_SOURCE_SET_NAME);
90 /**
91 * Is this the test fixtures source set?
93 * @return If this is the test fixtures source set or not.
94 * @since 2022/10/01
96 public boolean isTestFixturesSourceSet()
98 return this.sourceSet.equals(VMHelpers.TEST_FIXTURES_SOURCE_SET_NAME);
102 * Is this the test source set?
104 * @return If this is the test source set or not.
105 * @since 2022/10/01
107 public boolean isTestSourceSet()
109 return this.sourceSet.equals(SourceSet.TEST_SOURCE_SET_NAME);
113 * Modifies this classifier with the given source set.
115 * @param __sourceSet The source set to use instead.
116 * @return The classifier for the given source set.
117 * @throws NullPointerException On null arguments.
118 * @since 2022/10/01
120 public SourceTargetClassifier withSourceSet(String __sourceSet)
121 throws NullPointerException
123 if (__sourceSet == null)
124 throw new NullPointerException("NARG");
126 // No change?
127 if (this.sourceSet.equals(__sourceSet))
128 return this;
130 // Is changed
131 return new SourceTargetClassifier(__sourceSet, this.targetClassifier);
135 * Specifies an alternative virtual machine to use, but with the same
136 * source set.
138 * @param __vm The virtual machine to use instead.
139 * @return The modified source target classifier.
140 * @throws NullPointerException On null arguments.
141 * @since 2022/12/23
143 public SourceTargetClassifier withVm(VMSpecifier __vm)
144 throws NullPointerException
146 if (__vm == null)
147 throw new NullPointerException("NARG");
149 return new SourceTargetClassifier(this.sourceSet,
150 this.targetClassifier.withVm(__vm));
154 * Returns the classifier to be used by the emulated JIT.
156 * @return The classifier with the appropriate VM based on if it supports
157 * emulated JIT.
158 * @since 2022/12/23
160 public SourceTargetClassifier withVmByEmulatedJit()
162 if (this.targetClassifier.getVmType().hasEmulatorJit())
163 return new SourceTargetClassifier(this.sourceSet,
164 this.targetClassifier.withVmByEmulatedJit());
165 return this;