Skip to content

Commit 64c8920

Browse files
committed
refactor: renamed deps.json to app.json
Using a more generically useful name might make it possible to use the file for other app/project related purposes in the future.
1 parent 495f50d commit 64c8920

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

app.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"dependencies": {
3+
"eu.maveniverse.maven.mima:context": "2.4.15",
4+
"eu.maveniverse.maven.mima.runtime:standalone-static": "2.4.15",
5+
"info.picocli:picocli": "4.7.6",
6+
"com.google.code.gson:gson": "2.11.0",
7+
"org.slf4j:slf4j-api": "2.0.13",
8+
"org.slf4j:slf4j-simple": "2.0.13"
9+
}
10+
}

src/main/java/org/codejive/jpm/Jpm.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import java.io.IOException;
44
import java.nio.file.Path;
55
import java.util.*;
6-
import org.codejive.jpm.json.JpmProject;
6+
import org.codejive.jpm.json.AppInfo;
77
import org.codejive.jpm.util.FileUtils;
88
import org.codejive.jpm.util.ResolverUtils;
99
import org.codejive.jpm.util.SyncStats;
@@ -57,7 +57,7 @@ public SyncStats sync(String[] artifactNames)
5757

5858
public SyncStats install(String[] artifactNames)
5959
throws IOException, DependencyResolutionException {
60-
JpmProject prj = JpmProject.read();
60+
AppInfo prj = AppInfo.read();
6161
String[] artifacts = getArtifacts(artifactNames, prj);
6262
if (artifacts.length > 0) {
6363
List<Path> files = ResolverUtils.resolveArtifactPaths(artifacts);
@@ -69,7 +69,7 @@ public SyncStats install(String[] artifactNames)
6969
String version = dep.substring(p + 1);
7070
prj.dependencies.put(name, version);
7171
}
72-
JpmProject.write(prj);
72+
AppInfo.write(prj);
7373
}
7474
return stats;
7575
} else {
@@ -79,7 +79,7 @@ public SyncStats install(String[] artifactNames)
7979

8080
public List<Path> path(String[] artifactNames)
8181
throws DependencyResolutionException, IOException {
82-
JpmProject prj = JpmProject.read();
82+
AppInfo prj = AppInfo.read();
8383
String[] deps = getArtifacts(artifactNames, prj);
8484
if (deps.length > 0) {
8585
return ResolverUtils.resolveArtifactPaths(deps);
@@ -88,7 +88,7 @@ public List<Path> path(String[] artifactNames)
8888
}
8989
}
9090

91-
private static String[] getArtifacts(String[] artifactNames, JpmProject prj) {
91+
private static String[] getArtifacts(String[] artifactNames, AppInfo prj) {
9292
String[] deps;
9393
if (artifactNames.length > 0) {
9494
deps = artifactNames;

src/main/java/org/codejive/jpm/Main.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ public Integer call() throws Exception {
8484
name = "install",
8585
aliases = {"i"},
8686
description =
87-
"This adds the given artifacts to the list of dependencies available in the deps.json file. "
88-
+ "It then behaves just like 'sync' and copies all artifacts in that list and all their dependencies to the target directory while at the same time removing any artifacts that are no longer needed (ie the ones that are not mentioned in the deps.json file)."
89-
+ "If no artifacts are passed the deps.json file will be left untouched and only the existing dependencies in the file will be copied.\n\n"
87+
"This adds the given artifacts to the list of dependencies available in the app.json file. "
88+
+ "It then behaves just like 'sync' and copies all artifacts in that list and all their dependencies to the target directory while at the same time removing any artifacts that are no longer needed (ie the ones that are not mentioned in the app.json file)."
89+
+ "If no artifacts are passed the app.json file will be left untouched and only the existing dependencies in the file will be copied.\n\n"
9090
+ "Example:\n jpm install org.apache.httpcomponents:httpclient:4.5.14\n")
9191
static class Install implements Callable<Integer> {
9292
@Mixin QuietMixin quietMixin;
@@ -112,7 +112,7 @@ public Integer call() throws Exception {
112112
aliases = {"p"},
113113
description =
114114
"Resolves one or more artifacts and prints the full classpath to standard output. "
115-
+ "If no artifacts are passed the classpath for the dependencies defined in the deps.json file will be printed instead.\n\n"
115+
+ "If no artifacts are passed the classpath for the dependencies defined in the app.json file will be printed instead.\n\n"
116116
+ "Example:\n jpm path org.apache.httpcomponents:httpclient:4.5.14\n")
117117
static class PrintPath implements Callable<Integer> {
118118
@Mixin OptionalArtifactsMixin optionalArtifactsMixin;

src/main/java/org/codejive/jpm/json/JpmProject.java renamed to src/main/java/org/codejive/jpm/json/AppInfo.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,21 @@
1010
import java.util.Map;
1111
import java.util.TreeMap;
1212

13-
public class JpmProject {
13+
public class AppInfo {
1414
public Map<String, String> dependencies;
1515

16-
public static JpmProject read() throws IOException {
17-
Path prjJson = Path.of("deps.json");
18-
JpmProject prj;
16+
public static final String APP_INFO_FILE = "app.json";
17+
18+
public static AppInfo read() throws IOException {
19+
Path prjJson = Path.of(APP_INFO_FILE);
20+
AppInfo prj;
1921
if (Files.isRegularFile(prjJson)) {
2022
try (Reader in = Files.newBufferedReader(prjJson)) {
2123
Gson parser = new GsonBuilder().create();
22-
prj = parser.fromJson(in, JpmProject.class);
24+
prj = parser.fromJson(in, AppInfo.class);
2325
}
2426
} else {
25-
prj = new JpmProject();
27+
prj = new AppInfo();
2628
}
2729
if (prj.dependencies == null) {
2830
prj.dependencies = new TreeMap<>();
@@ -32,8 +34,8 @@ public static JpmProject read() throws IOException {
3234
return prj;
3335
}
3436

35-
public static void write(JpmProject prj) throws IOException {
36-
Path prjJson = Path.of("deps.json");
37+
public static void write(AppInfo prj) throws IOException {
38+
Path prjJson = Path.of(APP_INFO_FILE);
3739
try (Writer out = Files.newBufferedWriter(prjJson)) {
3840
Gson parser = new GsonBuilder().setPrettyPrinting().create();
3941
parser.toJson(prj, out);

0 commit comments

Comments
 (0)