2929import java .util .zip .ZipInputStream ;
3030import java .util .zip .ZipOutputStream ;
3131
32+ import net .minecraftforge .gradle .tasks .CreateStartTask ;
3233import net .minecraftforge .gradle .util .caching .Cached ;
3334import net .minecraftforge .gradle .util .caching .CachedTask ;
3435
3536import org .gradle .api .AntBuilder ;
36- import org .gradle .api .AntBuilder .AntMessagePriority ;
3737import org .gradle .api .file .FileVisitDetails ;
3838import org .gradle .api .file .FileVisitor ;
39- import org .gradle .api .logging .LogLevel ;
4039import org .gradle .api .tasks .Input ;
4140import org .gradle .api .tasks .InputFile ;
4241import org .gradle .api .tasks .Optional ;
4847import com .google .common .collect .Sets ;
4948import com .google .common .io .Files ;
5049
51- import groovy .lang .Closure ;
52- import groovy .util .BuilderSupport ;
53-
5450public 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