Skip to content

Commit 7fe75e3

Browse files
committed
Backport of #376 for fg2.1
1 parent 160af89 commit 7fe75e3

20 files changed

+74
-72
lines changed

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ dependencies {
9191
//Stuff used in the GradleStart classes
9292
compileOnly 'com.mojang:authlib:1.5.16'
9393
compileOnly "net.minecraft:launchwrapper:1.11"
94+
95+
testCompile 'junit:junit:4.12'
9496
}
9597

9698
sourceSets {

src/main/java/edu/sc/seis/launch4j/Launch4jPlugin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private Task addCopyToLibTask()
137137
task.setGroup(LAUNCH4J_GROUP);
138138
// more stuff with the java plugin
139139
//task.with(configureDistSpec(project));
140-
task.into(new Closure<File>(null)
140+
task.into(new Closure<File>(Launch4jPlugin.class)
141141
{
142142
@Override
143143
public File call(Object... obj)
@@ -180,7 +180,7 @@ private Task addLaunch4jTask()
180180
@SuppressWarnings({ "serial", "unused" })
181181
private static CopySpec configureDistSpec(Project project)
182182
{
183-
CopySpec distSpec = project.copySpec(new Closure<Object>(null) {});
183+
CopySpec distSpec = project.copySpec(new Closure<Object>(Launch4jPlugin.class) {});
184184
Jar jar = (Jar) project.getTasks().getByName(JavaPlugin.JAR_TASK_NAME);
185185

186186
distSpec.from(jar);

src/main/java/net/minecraftforge/gradle/common/BasePlugin.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ private void makeCommonTasks()
354354
{
355355
EtagDownloadTask getVersionJson = makeTask(TASK_DL_VERSION_JSON, EtagDownloadTask.class);
356356
{
357-
getVersionJson.setUrl(new Closure<String>(null, null) {
357+
getVersionJson.setUrl(new Closure<String>(BasePlugin.class) {
358358
@Override
359359
public String call()
360360
{
@@ -363,7 +363,7 @@ public String call()
363363
});
364364
getVersionJson.setFile(delayedFile(JSON_VERSION));
365365
getVersionJson.setDieWithError(false);
366-
getVersionJson.doLast(new Closure<Boolean>(project) // normalizes to linux endings
366+
getVersionJson.doLast(new Closure<Boolean>(BasePlugin.class) // normalizes to linux endings
367367
{
368368
@Override
369369
public Boolean call()
@@ -409,7 +409,7 @@ public Boolean call()
409409

410410
EtagDownloadTask getAssetsIndex = makeTask(TASK_DL_ASSET_INDEX, EtagDownloadTask.class);
411411
{
412-
getAssetsIndex.setUrl(new Closure<String>(null, null) {
412+
getAssetsIndex.setUrl(new Closure<String>(BasePlugin.class) {
413413
@Override
414414
public String call()
415415
{
@@ -431,7 +431,7 @@ public String call()
431431
Download dlClient = makeTask(TASK_DL_CLIENT, Download.class);
432432
{
433433
dlClient.setOutput(delayedFile(JAR_CLIENT_FRESH));
434-
dlClient.setUrl(new Closure<String>(null, null) {
434+
dlClient.setUrl(new Closure<String>(BasePlugin.class) {
435435
@Override
436436
public String call()
437437
{
@@ -445,7 +445,7 @@ public String call()
445445
Download dlServer = makeTask(TASK_DL_SERVER, Download.class);
446446
{
447447
dlServer.setOutput(delayedFile(JAR_SERVER_FRESH));
448-
dlServer.setUrl(new Closure<String>(null, null) {
448+
dlServer.setUrl(new Closure<String>(BasePlugin.class) {
449449
@Override
450450
public String call()
451451
{
@@ -805,7 +805,7 @@ public TokenReplacer load(String key)
805805
new CacheLoader<String, DelayedString>() {
806806
public DelayedString load(String key)
807807
{
808-
return new DelayedString(replacerCache.getUnchecked(key));
808+
return new DelayedString(CacheLoader.class, replacerCache.getUnchecked(key));
809809
}
810810
});
811811
private LoadingCache<String, DelayedFile> fileCache = CacheBuilder.newBuilder()
@@ -814,7 +814,7 @@ public DelayedString load(String key)
814814
new CacheLoader<String, DelayedFile>() {
815815
public DelayedFile load(String key)
816816
{
817-
return new DelayedFile(project, replacerCache.getUnchecked(key));
817+
return new DelayedFile(CacheLoader.class, project, replacerCache.getUnchecked(key));
818818
}
819819
});
820820

@@ -830,7 +830,7 @@ public DelayedFile delayedFile(String path)
830830

831831
public DelayedFileTree delayedTree(String path)
832832
{
833-
return new DelayedFileTree(project, replacerCache.getUnchecked(path));
833+
return new DelayedFileTree(BasePlugin.class, project, replacerCache.getUnchecked(path));
834834
}
835835

836836
protected File cacheFile(String path)

src/main/java/net/minecraftforge/gradle/common/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public String toString()
8787
public static final String GROUP_FG = "ForgeGradle";
8888

8989
@SuppressWarnings("serial")
90-
public static final Closure<Boolean> CALL_FALSE = new Closure<Boolean>(null) {
90+
public static final Closure<Boolean> CALL_FALSE = new Closure<Boolean>(Constants.class) {
9191
public Boolean call(Object o)
9292
{
9393
return false;

src/main/java/net/minecraftforge/gradle/patcher/PatcherExtension.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void setWorkspaceDir(Object workspaceDir)
124124
@SuppressWarnings("serial")
125125
protected Closure<File> getDelayedWorkspaceDir()
126126
{
127-
return new Closure<File>(null) {
127+
return new Closure<File>(PatcherExtension.class) {
128128
public File call()
129129
{
130130
return getWorkspaceDir();
@@ -135,7 +135,7 @@ public File call()
135135
@SuppressWarnings("serial")
136136
protected Closure<File> getDelayedSubWorkspaceDir(final String path)
137137
{
138-
return new Closure<File>(null) {
138+
return new Closure<File>(PatcherExtension.class) {
139139
public File call()
140140
{
141141
return new File(getWorkspaceDir(), path);
@@ -146,7 +146,7 @@ public File call()
146146
@SuppressWarnings("serial")
147147
protected Closure<File> getDelayedVersionJson()
148148
{
149-
return new Closure<File>(null) {
149+
return new Closure<File>(PatcherExtension.class) {
150150
public File call()
151151
{
152152
return getVersionJson();

src/main/java/net/minecraftforge/gradle/patcher/PatcherPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ protected void makePackagingTasks()
238238
Zip installer = makeTask(TASK_BUILD_INSTALLER, Zip.class);
239239
{
240240
installer.from(outputJar);
241-
installer.from(delayedTree(JAR_INSTALLER), new CopyInto("", "!*.json", "!*.png"));
241+
installer.from(delayedTree(JAR_INSTALLER), new CopyInto(PatcherPlugin.class, "", "!*.json", "!*.png"));
242242
installer.from(delayedTree(JSON_INSTALLER));
243243
installer.setBaseName(project.getName());
244244
installer.setClassifier("installer");

src/main/java/net/minecraftforge/gradle/patcher/PatcherProject.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ public void setApplyMcpPatches(boolean applyMcpPatches)
543543
@SuppressWarnings("serial")
544544
protected Closure<String> getDelayedMainClassClient()
545545
{
546-
return new Closure<String>(project, this) {
546+
return new Closure<String>(PatcherProject.class) {
547547
public String call()
548548
{
549549
return getMainClassClient();
@@ -554,7 +554,7 @@ public String call()
554554
@SuppressWarnings("serial")
555555
protected Closure<String> getDelayedTweakClassClient()
556556
{
557-
return new Closure<String>(project, this) {
557+
return new Closure<String>(PatcherProject.class) {
558558
public String call()
559559
{
560560
return getTweakClassClient();
@@ -565,7 +565,7 @@ public String call()
565565
@SuppressWarnings("serial")
566566
protected Closure<String> getDelayedRunArgsClient()
567567
{
568-
return new Closure<String>(project, this) {
568+
return new Closure<String>(PatcherProject.class) {
569569
public String call()
570570
{
571571
return getRunArgsClient();
@@ -576,7 +576,7 @@ public String call()
576576
@SuppressWarnings("serial")
577577
protected Closure<String> getDelayedMainClassServer()
578578
{
579-
return new Closure<String>(project, this) {
579+
return new Closure<String>(PatcherProject.class) {
580580
public String call()
581581
{
582582
return getMainClassServer();
@@ -587,7 +587,7 @@ public String call()
587587
@SuppressWarnings("serial")
588588
protected Closure<String> getDelayedTweakClassServer()
589589
{
590-
return new Closure<String>(project, this) {
590+
return new Closure<String>(PatcherProject.class) {
591591
public String call()
592592
{
593593
return getTweakClassServer();
@@ -598,7 +598,7 @@ public String call()
598598
@SuppressWarnings("serial")
599599
protected Closure<String> getDelayedRunArgsServer()
600600
{
601-
return new Closure<String>(project, this) {
601+
return new Closure<String>(PatcherProject.class) {
602602
public String call()
603603
{
604604
return getRunArgsServer();
@@ -609,7 +609,7 @@ public String call()
609609
@SuppressWarnings("serial")
610610
protected Closure<File> getDelayedSourcesDir()
611611
{
612-
return new Closure<File>(project, this) {
612+
return new Closure<File>(PatcherProject.class) {
613613
public File call()
614614
{
615615
return getSourcesDir();
@@ -620,7 +620,7 @@ public File call()
620620
@SuppressWarnings("serial")
621621
protected Closure<File> getDelayedResourcesDir()
622622
{
623-
return new Closure<File>(project, this) {
623+
return new Closure<File>(PatcherProject.class) {
624624
public File call()
625625
{
626626
return getResourcesDir();
@@ -631,7 +631,7 @@ public File call()
631631
@SuppressWarnings("serial")
632632
protected Closure<File> getDelayedTestSourcesDir()
633633
{
634-
return new Closure<File>(project, this) {
634+
return new Closure<File>(PatcherProject.class) {
635635
public File call()
636636
{
637637
return getTestSourcesDir();
@@ -642,7 +642,7 @@ public File call()
642642
@SuppressWarnings("serial")
643643
protected Closure<File> getDelayedTestResourcesDir()
644644
{
645-
return new Closure<File>(project, this) {
645+
return new Closure<File>(PatcherProject.class) {
646646
public File call()
647647
{
648648
return getTestResourcesDir();
@@ -653,7 +653,7 @@ public File call()
653653
@SuppressWarnings("serial")
654654
protected Closure<File> getDelayedPatchDir()
655655
{
656-
return new Closure<File>(project, this) {
656+
return new Closure<File>(PatcherProject.class) {
657657
public File call()
658658
{
659659
return getPatchDir();

src/main/java/net/minecraftforge/gradle/tasks/CreateStartTask.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
import net.minecraftforge.gradle.util.caching.Cached;
3434
import net.minecraftforge.gradle.util.caching.CachedTask;
3535

36+
import org.gradle.api.AntBuilder;
37+
import org.gradle.api.AntBuilder.AntMessagePriority;
3638
import org.gradle.api.file.FileCollection;
3739
import org.gradle.api.file.FileVisitDetails;
3840
import org.gradle.api.file.FileVisitor;
39-
import org.gradle.api.logging.LoggingManager;
4041
import org.gradle.api.logging.LogLevel;
4142
import org.gradle.api.tasks.Input;
4243
import org.gradle.api.tasks.OutputDirectory;
@@ -124,14 +125,14 @@ public void doStuff() throws IOException
124125
col = col.plus(config);
125126
}
126127

128+
AntBuilder ant = this.getAnt();
127129
// Remove errors on normal runs
128-
LoggingManager log = getLogging();
129130
LogLevel startLevel = getProject().getGradle().getStartParameter().getLogLevel();
130131
if (startLevel.compareTo(LogLevel.LIFECYCLE) >= 0) {
131-
log.setLevel(LogLevel.ERROR);
132+
ant.setLifecycleLogLevel(AntMessagePriority.ERROR);
132133
}
133134
// INVOKE!
134-
this.getAnt().invokeMethod("javac", ImmutableMap.builder()
135+
ant.invokeMethod("javac", ImmutableMap.builder()
135136
.put("srcDir", resourceDir.getCanonicalPath())
136137
.put("destDir", compiled.getCanonicalPath())
137138
.put("failonerror", true)

src/main/java/net/minecraftforge/gradle/tasks/DeobfuscateJar.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ public void setOutJar(Object outJar)
439439
@SuppressWarnings("serial")
440440
public Closure<File> getDelayedOutput()
441441
{
442-
return new Closure<File>(getProject(), this) {
442+
return new Closure<File>(DeobfuscateJar.class) {
443443
public File call()
444444
{
445445
return getOutJar();

src/main/java/net/minecraftforge/gradle/user/ReobfTaskFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public IReobfuscator create(final String jarName)
5555
task.dependsOn(Constants.TASK_GENERATE_SRGS, jarName);
5656
task.mustRunAfter("test");
5757

58-
task.setJar(new Closure<File>(null) {
58+
task.setJar(new Closure<File>(ReobfTaskFactory.class) {
5959
public File call()
6060
{
6161
return ((Jar) plugin.project.getTasks().getByName(jarName)).getArchivePath();

0 commit comments

Comments
 (0)