# jshell-maven-plugin **Repository Path**: acuner/jshell-maven-plugin ## Basic Information - **Project Name**: jshell-maven-plugin - **Description**: jshell mvn 包引用 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-07-31 - **Last Updated**: 2024-07-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README = jshell-maven-plugin Maven Plugin for the Java Shell Tool ( https://docs.oracle.com/javase/9/jshell/introduction-jshell.htm[JShell] ) == Run it [source,shell] ---- $mvn compile com.github.johnpoth:jshell-maven-plugin:1.4:run | Welcome to JShell -- Version 10 | For an introduction type: /help intro jshell> ---- Now you can start using your project's *runtime* classpath: [source,shell] ---- jshell> var foo = new org.apache.camel.component.beanclass.ClassComponent() foo ==> org.apache.camel.component.beanclass.ClassComponent@4d1b0d2a jshell> ---- To you use your project's test classpath, add *-DtestClasspath* to the command and make sure you have compiled your test classes: [source,shell] ---- $mvn test-compile com.github.johnpoth:jshell-maven-plugin:1.4:run ---- If you notice some resources missing, you may have to invoke the `install` phase instead: [source,shell] ---- $mvn install com.github.johnpoth:jshell-maven-plugin:1.4:run -DskipTests ---- Once you project has been built properly, and you haven't updated your source files, you can skip the building phase and invoke the plugin directly: [source,shell] ---- $mvn com.github.johnpoth:jshell-maven-plugin:1.4:run ---- == Options [cols="1v,1v,1v"] |=== |Name |Description |Default value| class-path|Explicitly set JShell's class path|| module-path|Set JShell's module path|| add-modules|Add modules from JShell's module path|| add-exports|Explicitly add exports|| scripts|Add startup scripts to JShell ',' delimited|| useProjectClasspath|Use project class path in JShell|True| properties| Configure Java properties|| runtimeClasspath| Add `./target/classes` in classpath|`false`| testClasspath| Add `./target/test-classes` in classpath|`true`| options| Add other options to JShell. See https://docs.oracle.com/javase/9/tools/jshell.htm#GUID-C337353B-074A-431C-993F-60C226163F00__OPTIONSFORJSHELL-AF4AC615[docs]|| |=== Reminder: plugin parameters when passed through the command line should be prefixed with 'jshell.' e.g: *mvn com.github.johnpoth:jshell-maven-plugin:1.4:run -Djshell.scripts="script0,script1"* == Adding to pom.xml To use the plugin's shortened prefix *jshell*, declare the plugin in your pom.xml [source,xml] ---- com.github.johnpoth jshell-maven-plugin 1.4 ---- And now you'll be able to run it by typing *mvn jshell:run* [source,shell] ---- $mvn jshell:run | Welcome to JShell -- Version 10 | For an introduction type: /help intro jshell> ---- Works on Java 9, 10 and 11+ Enjoy!