project: Make it possible to skip injectors
This commit is contained in:
@@ -47,8 +47,9 @@ public class Injection extends InjectData implements InjectTaskHandler
|
|||||||
{
|
{
|
||||||
private static final Logger log = Logging.getLogger(Injection.class);
|
private static final Logger log = Logging.getLogger(Injection.class);
|
||||||
public static boolean development = true;
|
public static boolean development = true;
|
||||||
|
public static String skips = "";
|
||||||
|
|
||||||
public Injection(File vanilla, File rsclient, File mixins, FileTree rsapi, boolean development)
|
public Injection(File vanilla, File rsclient, File mixins, FileTree rsapi, boolean development, String skip)
|
||||||
{
|
{
|
||||||
super(
|
super(
|
||||||
load(vanilla),
|
load(vanilla),
|
||||||
@@ -58,6 +59,7 @@ public class Injection extends InjectData implements InjectTaskHandler
|
|||||||
);
|
);
|
||||||
|
|
||||||
Injection.development = development;
|
Injection.development = development;
|
||||||
|
Injection.skips = skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void inject()
|
public void inject()
|
||||||
@@ -142,15 +144,18 @@ public class Injection extends InjectData implements InjectTaskHandler
|
|||||||
{
|
{
|
||||||
final String name = injector.getName();
|
final String name = injector.getName();
|
||||||
|
|
||||||
injector.start();
|
if (injector.shouldRun())
|
||||||
|
|
||||||
injector.inject();
|
|
||||||
|
|
||||||
String completionMsg = injector.getCompletionMsg();
|
|
||||||
|
|
||||||
if (completionMsg != null)
|
|
||||||
{
|
{
|
||||||
log.lifecycle("{} {}", name, completionMsg);
|
injector.start();
|
||||||
|
|
||||||
|
injector.inject();
|
||||||
|
|
||||||
|
String completionMsg = injector.getCompletionMsg();
|
||||||
|
|
||||||
|
if (completionMsg != null)
|
||||||
|
{
|
||||||
|
log.lifecycle("{} {}", name, completionMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (injector instanceof Validator)
|
if (injector instanceof Validator)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
package com.openosrs.injector.injectors;
|
package com.openosrs.injector.injectors;
|
||||||
|
|
||||||
import com.google.common.base.Stopwatch;
|
import com.google.common.base.Stopwatch;
|
||||||
|
import com.openosrs.injector.Injection;
|
||||||
import com.openosrs.injector.injection.InjectData;
|
import com.openosrs.injector.injection.InjectData;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.gradle.api.logging.Logger;
|
import org.gradle.api.logging.Logger;
|
||||||
@@ -29,4 +30,9 @@ public abstract class AbstractInjector implements Injector
|
|||||||
{
|
{
|
||||||
return "finished in " + stopwatch.toString();
|
return "finished in " + stopwatch.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean shouldRun()
|
||||||
|
{
|
||||||
|
return !Injection.skips.contains(this.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,4 +33,9 @@ public interface Injector extends Named
|
|||||||
* Gets a message logged at quiet level when the injector ends
|
* Gets a message logged at quiet level when the injector ends
|
||||||
*/
|
*/
|
||||||
String getCompletionMsg();
|
String getCompletionMsg();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this injector is in the skip list
|
||||||
|
*/
|
||||||
|
boolean shouldRun();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,14 @@ abstract class Inject : DefaultTask() {
|
|||||||
val mixins = extension.mixins.get().asFile
|
val mixins = extension.mixins.get().asFile
|
||||||
val rsapi = project.zipTree(extension.rsapi)
|
val rsapi = project.zipTree(extension.rsapi)
|
||||||
|
|
||||||
val injector: InjectTaskHandler = Injection(vanilla, rsclient, mixins, rsapi, if (extension.development.isPresent) extension.development.get() else true)
|
val injector: InjectTaskHandler = Injection(
|
||||||
|
vanilla,
|
||||||
|
rsclient,
|
||||||
|
mixins,
|
||||||
|
rsapi,
|
||||||
|
if (extension.development.isPresent) extension.development.get() else true,
|
||||||
|
if (extension.skip.isPresent) extension.skip.get() else ""
|
||||||
|
)
|
||||||
|
|
||||||
injector.inject()
|
injector.inject()
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ interface InjectExtension {
|
|||||||
@get:Optional
|
@get:Optional
|
||||||
val development: Property<Boolean>
|
val development: Property<Boolean>
|
||||||
|
|
||||||
|
@get:Input
|
||||||
|
@get:Optional
|
||||||
|
val skip: Property<String>
|
||||||
|
|
||||||
@get:[InputFile PathSensitive(PathSensitivity.NONE)]
|
@get:[InputFile PathSensitive(PathSensitivity.NONE)]
|
||||||
val vanilla: RegularFileProperty
|
val vanilla: RegularFileProperty
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user