mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-26 20:53:06 +00:00
Fix AP file writer issue with non-file outputs, fixed #622
This commit is contained in:
1 parent
2d14c78a10
commit
a362aad99b
1 file changed
+28
-4
@@ -27,9 +27,14 @@ package org.spongepowered.tools.obfuscation;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.processing.Filer;
|
||||
import javax.annotation.processing.FilerException;
|
||||
import javax.tools.FileObject;
|
||||
import javax.tools.JavaFileManager.Location;
|
||||
import javax.tools.StandardLocation;
|
||||
|
||||
import org.spongepowered.asm.mixin.injection.selectors.ITargetSelectorRemappable;
|
||||
@@ -129,7 +134,9 @@ public class ReferenceManager implements IReferenceManager {
|
||||
|
||||
try {
|
||||
writer = this.newWriter(this.outRefMapFileName, "refmap");
|
||||
this.refMapper.write(writer);
|
||||
if (writer != null) {
|
||||
this.refMapper.write(writer);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
@@ -154,9 +161,26 @@ public class ReferenceManager implements IReferenceManager {
|
||||
return new PrintWriter(outFile);
|
||||
}
|
||||
|
||||
FileObject outResource = this.ap.getProcessingEnvironment().getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", fileName);
|
||||
this.ap.printMessage(MessageType.INFO, "Writing " + description + " to " + new File(outResource.toUri()).getAbsolutePath());
|
||||
return new PrintWriter(outResource.openWriter());
|
||||
try {
|
||||
Filer filer = this.ap.getProcessingEnvironment().getFiler();
|
||||
FileObject outResource = null;
|
||||
try {
|
||||
outResource = filer.createResource(StandardLocation.CLASS_OUTPUT, "", fileName);
|
||||
} catch (Exception ex) {
|
||||
// fileName is not a valid relative path?
|
||||
outResource = filer.createResource(StandardLocation.CLASS_OUTPUT, "", new File(fileName).getName());
|
||||
}
|
||||
|
||||
URI resourceUri = outResource.toUri();
|
||||
String absolutePath = "file".equals(resourceUri.getScheme()) ? new File(resourceUri).getAbsolutePath() : resourceUri.toString();
|
||||
PrintWriter writer = new PrintWriter(outResource.openWriter());
|
||||
this.ap.printMessage(MessageType.INFO, "Writing " + description + " to (" + resourceUri.getScheme() + ") " + absolutePath);
|
||||
return writer;
|
||||
} catch (Exception ex) {
|
||||
this.ap.printMessage(MessageType.ERROR, "Cannot write " + description + " to (" + fileName + "): " + ex.getClass().getName()
|
||||
+ ": " + ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
Reference in new issue
Block a user