Skip to content

Commit 295ad13

Browse files
committed
install package + 0.4 version in pom
1 parent fc95c13 commit 295ad13

8 files changed

Lines changed: 104 additions & 58 deletions

File tree

dependency-reduced-pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.benjamin538</groupId>
55
<artifactId>geode</artifactId>
6-
<version>0.31</version>
6+
<version>0.4</version>
77
<build>
88
<plugins>
99
<plugin>
@@ -83,7 +83,7 @@
8383
</profile>
8484
</profiles>
8585
<properties>
86-
<maven.compiler.target>21</maven.compiler.target>
87-
<maven.compiler.source>21</maven.compiler.source>
86+
<maven.compiler.target>25</maven.compiler.target>
87+
<maven.compiler.source>25</maven.compiler.source>
8888
</properties>
8989
</project>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.benjamin538</groupId>
88
<artifactId>geode</artifactId>
9-
<version>0.31</version>
9+
<version>0.4</version>
1010
<profiles>
1111
<profile>
1212
<id>native</id>

src/main/java/com/benjamin538/Main.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.benjamin538.project.CreateMod;
1010
import com.benjamin538.config.Config;
1111
import com.benjamin538.project.Project;
12+
import com.benjamin538.modPackage.Package;
1213

1314
// picocli
1415
import picocli.CommandLine;
@@ -28,7 +29,8 @@
2829
Project.class,
2930
picocli.AutoComplete.GenerateCompletion.class,
3031
Index.class,
31-
Build.class
32+
Build.class,
33+
Package.class
3234
},
3335
version = "geode 3.2.0",
3436
mixinStandardHelpOptions = true

src/main/java/com/benjamin538/index/IndexLogin.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,6 @@ public void run() {
6666
if (response.statusCode() != 200) {
6767
logger.fatal("Unable to connect to Geode Index");
6868
}
69-
/*
70-
{
71-
"payload": {
72-
"code": "code",
73-
"interval": 5,
74-
"uuid": uuid,
75-
"uri": "https://github.com/login/device"
76-
}, "error": ""
77-
}
78-
*/
7969
JSONObject json = new JSONObject(response.body()).getJSONObject("payload");
8070
String code = json.getString("code");
8171
int interval = json.getInt("interval");
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.benjamin538.modPackage;
2+
3+
// path
4+
import java.nio.file.Paths;
5+
import java.nio.file.Path;
6+
import java.nio.file.Files;
7+
8+
// config path
9+
import com.benjamin538.config.ConfigPath;
10+
11+
// get profile
12+
import com.benjamin538.profile.CurrentDeveloper;
13+
14+
// check file
15+
import com.benjamin538.util.CheckProfileFile;
16+
17+
// logging
18+
import com.benjamin538.util.Logging;
19+
20+
// json
21+
import org.json.JSONObject;
22+
import org.json.JSONArray;
23+
24+
// picocli
25+
import picocli.CommandLine.Command;
26+
import picocli.CommandLine.Option;
27+
import picocli.CommandLine.Parameters;
28+
29+
@Command(
30+
name = "install",
31+
description = "Install a .geode package to the current profile"
32+
)
33+
public class InstallPackage implements Runnable {
34+
private Logging logger = new Logging();
35+
@Option(names = {"-h", "--help"}, description = "Print help", usageHelp = true)
36+
boolean help;
37+
@Parameters(description = "Location of the .geode package to install")
38+
Path path;
39+
@Override
40+
public void run() {
41+
CheckProfileFile.checkFile();
42+
String current = CurrentDeveloper.get();
43+
if(current.equals("")) {
44+
logger.fatal("Current profile is missing, use `geode profile switch`");
45+
}
46+
Path configPath = ConfigPath.path();
47+
if (!Files.exists(path)) {
48+
logger.fatal(".geode file not found.");
49+
}
50+
try {
51+
JSONObject profileJSON = new JSONObject(Files.readString(configPath));
52+
JSONArray profiles = profileJSON.getJSONArray("profiles");
53+
for(Object profile : profiles) {
54+
JSONObject _profile = (JSONObject) profile;
55+
String name = _profile.getString("name");
56+
if(name.equals(current)) {
57+
String gdPath = Paths.get(_profile.getString("gd-path"), "..").normalize().toString();
58+
Path modDir = Paths.get(gdPath, "geode", "mods");
59+
if (!Files.exists(modDir)) {
60+
logger.warn("Path " + modDir.toAbsolutePath().toString() + "does not exists, creating one");
61+
logger.warn("(Did you installed Geode?");
62+
Files.createDirectories(modDir);
63+
}
64+
Files.copy(path, Paths.get(gdPath, "geode", "mods", path.getFileName().toString()));
65+
logger.done("Installed " + path.getFileName().toString());
66+
}
67+
}
68+
} catch(Exception ex) {
69+
logger.fatal("Failed to install package: " + ex.getMessage());
70+
}
71+
}
72+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.benjamin538.modPackage;
2+
3+
// picocli
4+
import picocli.CommandLine;
5+
import picocli.CommandLine.Command;
6+
import picocli.CommandLine.Option;
7+
8+
@Command(
9+
name = "package",
10+
description = "Options for working with .geode packages",
11+
subcommands = {
12+
InstallPackage.class
13+
}
14+
)
15+
public class Package implements Runnable {
16+
@Option(names = {"-h", "--help"}, description = "Print help", usageHelp = true)
17+
boolean help;
18+
@Override
19+
public void run() {
20+
CommandLine.usage(this, System.err);
21+
}
22+
}

src/main/java/com/benjamin538/profile/InstallToProfile.java

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

src/main/java/com/benjamin538/project/Build.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ void setPlatform(String s) {
4444
Set<String> extraConfArgs = new HashSet<>();
4545
@Override
4646
public void run() {
47+
if (platform == null) {
48+
platform = DetectOS.detectOS();
49+
}
4750
Path CMakePath = Paths.get("CMakeLists.txt");
4851
if(!Files.exists(CMakePath)) {
4952
logger.fatal("Could not find CMakeLists.txt. Please run this within a Geode project!");

0 commit comments

Comments
 (0)