Skip to content

Commit 7be8481

Browse files
committed
Apply backwards compatiblity to RecompileMC task as well.
Also cleanup the OSX ext path 'fix' to actually.. set the path to something.
1 parent d1f219e commit 7be8481

File tree

2 files changed

+33
-45
lines changed

2 files changed

+33
-45
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import net.minecraftforge.gradle.util.caching.CachedTask;
3535

3636
import org.gradle.api.AntBuilder;
37+
import org.gradle.api.Task;
3738
import org.gradle.api.AntBuilder.AntMessagePriority;
3839
import org.gradle.api.file.FileCollection;
3940
import org.gradle.api.file.FileVisitDetails;
@@ -127,7 +128,7 @@ public void doStuff() throws IOException
127128
col = col.plus(config);
128129
}
129130

130-
AntBuilder ant = this.setupAnt();
131+
AntBuilder ant = CreateStartTask.setupAnt(this);
131132
// INVOKE!
132133
ant.invokeMethod("javac", ImmutableMap.builder()
133134
.put("srcDir", resourceDir.getCanonicalPath())
@@ -161,10 +162,10 @@ public void visitFile(FileVisitDetails arg0)
161162

162163
}
163164

164-
private AntBuilder setupAnt()
165+
public static AntBuilder setupAnt(Task task)
165166
{
166-
AntBuilder ant = this.getAnt();
167-
LogLevel startLevel = getProject().getGradle().getStartParameter().getLogLevel();
167+
AntBuilder ant = task.getAnt();
168+
LogLevel startLevel = task.getProject().getGradle().getStartParameter().getLogLevel();
168169
if (startLevel.compareTo(LogLevel.LIFECYCLE) >= 0)
169170
{
170171
GradleVersion v2_14 = GradleVersion.version("2.14");
@@ -175,10 +176,10 @@ private AntBuilder setupAnt()
175176
else
176177
{
177178
try {
178-
LoggingManager.class.getMethod("setLevel", LogLevel.class).invoke(getLogging(), LogLevel.ERROR);
179+
LoggingManager.class.getMethod("setLevel", LogLevel.class).invoke(task.getLogging(), LogLevel.ERROR);
179180
} catch (Exception e) {
180181
//Couldn't find it? We are on some weird version oh well.
181-
this.getLogger().info("Could not set log level:", e);
182+
task.getLogger().info("Could not set log level:", e);
182183
}
183184
}
184185
}

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

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@
2929
import java.util.zip.ZipInputStream;
3030
import java.util.zip.ZipOutputStream;
3131

32+
import net.minecraftforge.gradle.tasks.CreateStartTask;
3233
import net.minecraftforge.gradle.util.caching.Cached;
3334
import net.minecraftforge.gradle.util.caching.CachedTask;
3435

3536
import org.gradle.api.AntBuilder;
36-
import org.gradle.api.AntBuilder.AntMessagePriority;
3737
import org.gradle.api.file.FileVisitDetails;
3838
import org.gradle.api.file.FileVisitor;
39-
import org.gradle.api.logging.LogLevel;
4039
import org.gradle.api.tasks.Input;
4140
import org.gradle.api.tasks.InputFile;
4241
import org.gradle.api.tasks.Optional;
@@ -48,9 +47,6 @@
4847
import com.google.common.collect.Sets;
4948
import com.google.common.io.Files;
5049

51-
import groovy.lang.Closure;
52-
import groovy.util.BuilderSupport;
53-
5450
public class TaskRecompileMc extends CachedTask
5551
{
5652
@InputFile
@@ -83,15 +79,9 @@ public void doStuff() throws IOException
8379
// extract sources
8480
extractSources(tempSrc, inJar);
8581

86-
AntBuilder ant = this.getAnt();
87-
// Remove errors on normal runs
88-
LogLevel startLevel = getProject().getGradle().getStartParameter().getLogLevel();
89-
if (startLevel.compareTo(LogLevel.LIFECYCLE) >= 0) {
90-
ant.setLifecycleLogLevel(AntMessagePriority.ERROR);
91-
}
92-
82+
AntBuilder ant = CreateStartTask.setupAnt(this);
9383
// recompile
94-
ant.invokeMethod("javac", new Object[] {
84+
ant.invokeMethod("javac",
9585
ImmutableMap.builder()
9686
.put("srcDir", tempSrc.getCanonicalPath())
9787
.put("destDir", tempCls.getCanonicalPath())
@@ -102,36 +92,33 @@ public void doStuff() throws IOException
10292
.put("source", "1.6")
10393
.put("target", "1.6")
10494
.put("debug", "true")
105-
.build(),
106-
new Closure<Object>(TaskRecompileMc.class) {
107-
protected Object doCall(Object arguments) {
108-
String currentExtDirs = System.getProperty("java.ext.dirs");
109-
String newExtDirs = "";
110-
String[] parts = currentExtDirs.split(File.pathSeparator);
111-
if (parts.length > 0) {
112-
String lastPart = parts[parts.length - 1];
113-
for (String part : parts) {
114-
if (!part.equals("/System/Library/Java/Extensions")) {
115-
newExtDirs += part;
116-
if (!part.equals(lastPart)) {
117-
newExtDirs += File.pathSeparator;
118-
}
119-
}
120-
}
121-
}
122-
((BuilderSupport) getDelegate()).invokeMethod("compilerarg",
123-
// Remove old vecmath
124-
ImmutableMap.of("line", "-Djava.ext.dirs=${newExtDirs}")
125-
);
126-
return null;
127-
}
128-
}
129-
});
95+
.put("java.ext.dirs", getExtPath())
96+
.build()
97+
);
13098

13199
outJar.getParentFile().mkdirs();
132100
createOutput(outJar, inJar, tempCls, getInResources());
133101
}
134102

103+
private static String getExtPath()
104+
{
105+
String currentExtDirs = System.getProperty("java.ext.dirs");
106+
String newExtDirs = "";
107+
String[] parts = currentExtDirs.split(File.pathSeparator);
108+
if (parts.length > 0) {
109+
String lastPart = parts[parts.length - 1];
110+
for (String part : parts) {
111+
if (!part.equals("/System/Library/Java/Extensions")) {
112+
newExtDirs += part;
113+
if (!part.equals(lastPart)) {
114+
newExtDirs += File.pathSeparator;
115+
}
116+
}
117+
}
118+
}
119+
return newExtDirs;
120+
}
121+
135122
private static void extractSources(File tempDir, File inJar) throws IOException
136123
{
137124
ZipInputStream zin = new ZipInputStream(new FileInputStream(inJar));
@@ -160,7 +147,7 @@ private void createOutput(File outJar, File sourceJar, File classDir, File resou
160147
JarOutputStream zout = new JarOutputStream(new FileOutputStream(outJar));
161148

162149
Visitor visitor = new Visitor(zout, elementsAdded);
163-
150+
164151
// custom resources should override existing ones, so resources first.
165152
if (resourceJar != null)
166153
{

0 commit comments

Comments
 (0)