Skip to content

Commit dba694d

Browse files
committed
Changes to workspace copying
1 parent ca46e63 commit dba694d

7 files changed

Lines changed: 10 additions & 49 deletions

File tree

src/main/java/org/mcphackers/mcp/tasks/TaskCleanup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void doTask() throws Exception {
2929
Paths.get(MCPConfig.BIN),
3030
Paths.get(MCPConfig.REOBF),
3131
Paths.get(MCPConfig.BUILD),
32-
Paths.get("eclipse")
32+
Paths.get("workspace")
3333
};
3434
if (MCP.config.srcCleanup) pathsToDelete = new Path[] {
3535
Paths.get(MCPConfig.SRC),

src/main/java/org/mcphackers/mcp/tasks/TaskSetup.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.mcphackers.mcp.MCPConfig;
1818
import org.mcphackers.mcp.tasks.info.TaskInfo;
1919
import org.mcphackers.mcp.tools.FileUtil;
20-
import org.mcphackers.mcp.tools.ResourceManager;
2120
import org.mcphackers.mcp.tools.Util;
2221
import org.mcphackers.mcp.tools.VersionsParser;
2322

@@ -83,10 +82,9 @@ public void doTask() throws Exception {
8382

8483
// Create Eclipse workspace
8584
MCP.logger.info(" Setting up workspace");
86-
FileUtil.deleteDirectoryIfExists(Paths.get("eclipse"));
87-
ResourceManager.copyResource("/eclipse.zip", "eclipse.zip");
88-
FileUtil.unzip(Paths.get("eclipse.zip"), Paths.get("eclipse"));
89-
Files.delete(Paths.get("eclipse.zip"));
85+
FileUtil.deleteDirectoryIfExists(Paths.get("workspace"));
86+
FileUtil.copyResource(MCP.class.getClassLoader().getResourceAsStream("workspace.zip"), Paths.get("workspace.zip"));
87+
FileUtil.unzip(Paths.get("workspace.zip"), Paths.get("workspace"), true);
9088

9189
// Create Intellij workspace
9290
String[] projects = { "Client", "Server" };

src/main/java/org/mcphackers/mcp/tools/FileUtil.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,9 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) thro
188188
});
189189
outputStream.close();
190190
}
191-
191+
192+
public static void copyResource(InputStream is, Path out) throws IOException {
193+
byte[] data = Util.readAllBytes(is);
194+
Files.write(out, data);
195+
}
192196
}

src/main/java/org/mcphackers/mcp/tools/ResourceManager.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/main/java/org/mcphackers/mcp/tools/Util.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static JSONArray parseJSONArray(InputStream stream) throws JSONException,
120120
return new JSONArray(content);
121121
}
122122

123-
private static byte[] readAllBytes(InputStream inputStream) throws IOException {
123+
public static byte[] readAllBytes(InputStream inputStream) throws IOException {
124124
final int bufLen = 4 * 0x400; // 4KB
125125
byte[] buf = new byte[bufLen];
126126
int readLen;

src/main/resources/eclipse.zip

-8.53 KB
Binary file not shown.

src/main/resources/workspace.zip

17.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)