You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actions can be added to the app.yml file. Each action is simply a command that will get executed when the given action is activated with `jpm do <action>`. Commands can contain special "variables" that will get replaced just before execution. The most important is `{{deps}}` which will result in the full classpath to all dependencies defined in the app.yml being inserted in the command. The remaining one all have to do with making it easier to create os-specific paths (so commands will work both on WIndows and Linux/Mac).
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,7 @@ Always manually validate jpm functionality after making changes:
84
84
85
85
### Important Files
86
86
-`pom.xml` - Maven configuration with Spotless formatting, Shade plugin, Appassembler
87
-
-`app.yml` - Example dependency configuration (also created by jpm install)
87
+
-`app.yml` - jpm's actual runtime dependencies and actions (NOT an example file). Dependencies should be kept up-to-date with the (non-test) dependencies in pom.xml
88
88
-`RELEASE.md` - Release process documentation
89
89
-`.gitignore` - Excludes target/, deps/, IDE files
Copy file name to clipboardExpand all lines: README.md
+84-2Lines changed: 84 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,76 @@ to get the required dependencies to run the code.
89
89
_NB: We could have used `jpm copy` instead of `jpm install` to copy the dependencies but that would not have created
90
90
the `app.yml` file._
91
91
92
+
## Actions
93
+
94
+
The `app.yml` file doesn't just track dependencies - it can also define custom actions that can be executed with the `jpm do` command or through convenient alias commands.
95
+
96
+
### Defining Actions
97
+
98
+
Actions are defined in the `actions` section of your `app.yml` file:
99
+
100
+
```yaml
101
+
dependencies:
102
+
com.github.lalyos:jfiglet:0.0.9
103
+
104
+
actions:
105
+
build: "javac -cp {{deps}} *.java"
106
+
run: "java -cp {{deps}} HelloWorld"
107
+
test: "java -cp {{deps}} TestRunner"
108
+
clean: "rm -f *.class"
109
+
```
110
+
111
+
### Executing Actions
112
+
113
+
You can execute actions using the `jpm do` command:
114
+
115
+
```shell
116
+
$ jpm do build
117
+
$ jpm do run
118
+
$ jpm do --list # Lists all available actions
119
+
```
120
+
121
+
Or use the convenient alias commands:
122
+
123
+
```shell
124
+
$ jpm build # Executes the 'build' action
125
+
$ jpm run # Executes the 'run' action
126
+
$ jpm test # Executes the 'test' action
127
+
$ jpm clean # Executes the 'clean' action
128
+
```
129
+
130
+
Alias commands can accept additional arguments that will be passed through to the underlying action:
131
+
132
+
```shell
133
+
$ jpm run --verbose debug # Passes '--verbose debug' to the run action
134
+
```
135
+
136
+
### Variable Substitution
137
+
138
+
Actions support several variable substitution features for cross-platform compatibility:
139
+
140
+
- **`{{deps}}`** - Replaced with the full classpath of all dependencies
141
+
- **`{/}`** - Replaced with the file separator (`\` on Windows, `/` on Linux/Mac)
142
+
- **`{:}`** - Replaced with the path separator (`;` on Windows, `:` on Linux/Mac)
143
+
- **`{~}`** - Replaced with the user's home directory (The actual path on Windows, `~` on Linux/Mac)
144
+
- **`{./path/to/file}`** - Converts relative paths to platform-specific format
145
+
- **`{./libs:./ext:~/usrlibs}`** - Converts entire class paths to platform-specific format
NB: The `{{deps}}` variable substitution is only performed when needed - if your action doesn't contain `{{deps}}`, jpm won't resolve the classpath, making execution faster for simple actions that don't require dependencies.
157
+
158
+
NB2: These actions are just a very simple convenience feature. For a much more full-featured cross-platform action runner I recommend taking a look at:
159
+
160
+
- [Just](https://github.com/casey/just) - Just a command runner
161
+
92
162
## Installation
93
163
94
164
For now the simplest way to install `jpm` is to use [JBang](https://www.jbang.dev/download/):
@@ -132,8 +202,8 @@ Commands:
132
202
dependencies to the target directory while at the same time
133
203
removing any artifacts that are no longer needed (ie the ones
134
204
that are not mentioned in the app.yml file). If no artifacts
135
-
are passed the app.yml file will be left untouched and only
136
-
the existing dependencies in the file will be copied.
205
+
are passed the app.yml file will be left untouched and only the
0 commit comments