Skip to content

Commit ca46e63

Browse files
committed
Standalone RetroMCP jar
1 parent 9e1e9ed commit ca46e63

21 files changed

Lines changed: 45 additions & 9333 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ build/
88

99
# Ignore everything in testing folder
1010
test/*
11-
!test/versions
1211

1312
# Ignore IDE-specific folders
1413
.idea

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
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;
2021
import org.mcphackers.mcp.tools.Util;
2122
import org.mcphackers.mcp.tools.VersionsParser;
2223

@@ -83,7 +84,9 @@ public void doTask() throws Exception {
8384
// Create Eclipse workspace
8485
MCP.logger.info(" Setting up workspace");
8586
FileUtil.deleteDirectoryIfExists(Paths.get("eclipse"));
86-
FileUtil.copyDirectory(Paths.get("versions", "workspace", "eclipse"), 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"));
8790

8891
// Create Intellij workspace
8992
String[] projects = { "Client", "Server" };
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.mcphackers.mcp.tools;
2+
3+
import java.io.File;
4+
import java.io.FileOutputStream;
5+
import java.io.InputStream;
6+
import java.io.OutputStream;
7+
8+
public class ResourceManager {
9+
10+
/**
11+
* Export a resource embedded into a Jar file to the local file path.
12+
*
13+
* @param resourceName ie.: "/SmartLibrary.dll"
14+
* @return The path to the exported resource
15+
* @throws Exception
16+
*/
17+
static public void copyResource(String resourceName, String destDir) throws Exception {
18+
InputStream stream = null;
19+
OutputStream resStreamOut = null;
20+
String jarFolder;
21+
try {
22+
stream = ResourceManager.class.getResourceAsStream(resourceName);
23+
if(stream == null) {
24+
throw new Exception("Cannot get resource \"" + resourceName + "\" from Jar file.");
25+
}
26+
27+
int readBytes;
28+
byte[] buffer = new byte[4096];
29+
jarFolder = new File(ResourceManager.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParentFile().getPath().replace('\\', '/');
30+
resStreamOut = new FileOutputStream(destDir);
31+
while ((readBytes = stream.read(buffer)) > 0) {
32+
resStreamOut.write(buffer, 0, readBytes);
33+
}
34+
} catch (Exception ex) {
35+
throw ex;
36+
} finally {
37+
stream.close();
38+
resStreamOut.close();
39+
}
40+
}
41+
}

src/main/resources/eclipse.zip

8.53 KB
Binary file not shown.

test/versions/a1.1.2_01/client.exc

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

0 commit comments

Comments
 (0)