EasyJava VSCode Extension
A VSCode extension for simplifying Java development with Maven and Spring Boot.
Story
Many older computers struggle to start larger Spring Boot projects using Eclipse or the official VSCode plugins, often taking hours. Even IntelliJ IDEA can be slow due to hardware limitations. That's why I created the EasyJava extension—to enable fast hot-reloading and editing of Java files, making development much more efficient. Hope you enjoy it!
许多老旧电脑在使用 Eclipse 或 VSCode 官方插件启动稍大的 Spring Boot 项目时,速度极慢,甚至需要数小时。即使是 IDEA 也难以避免卡顿,根本原因还是硬件性能有限。因此,我开发了 EasyJava 插件,目标是让你能够快速热启动和编辑 Java 文件,大幅提升开发效率。希望你会喜欢!
多くの古いパソコンでは、Eclipse や VSCode 公式プラグインで少し大きめの Spring Boot プロジェクトを起動すると非常に時間がかかり、場合によっては数時間かかることもあります。IntelliJ IDEA でも同様に遅くなることがあり、根本的な原因はハードウェア性能の限界です。そこで私は、編集したファイルを素早くホットスタートできる EasyJava プラグインを開発しました。開発効率を大幅に向上させますので、ぜひお試しください!
Features
This extension provides several features to streamline Java development:
- Automatic activation when a Maven (pom.xml) project is detected
- Automatic configuration with main class detection
- Multiple project configuration support via YAML
- Automatic compilation of Java files with classpath
- Automatic copying of resource files to target directory
- Dynamic project commands in command palette
- Environment variables configuration
- Custom command support
- Automatic classpath regeneration when pom.xml changes
- Output to integrated terminal or output channel
- Status bar integration for quick access to commands
- Git staged files compilation
- Spring Boot application detection
- Maven wrapper support
Requirements
- Java Development Kit (JDK)
- Maven or Maven Wrapper
- VSCode
Extension Settings
This extension contributes the following setting:
easyjava.configPath
: Path to configuration file (default: ".easy/java.yml")
Commands
This extension provides the following commands:
easyjava.init
: Initialize EasyJava configuration
easyjava.runJava
: Show project picker to run a Java project
easyjava.generateClasspath
: Generate classpath for all configured projects
easyjava.compile
: Compile a Java project using Maven
easyjava.package
: Package a Java project using Maven
easyjava.compileGit
: Compile Git staged Java files
easyjava.showMenu
: Show EasyJava command menu
- Dynamic project commands: A command is created for each configured project
Configuration
The extension uses a YAML configuration file (default: .easy/java.yml
) to define all settings and one or more Java projects in your workspace. You can create this file automatically using the "EasyJava: Initialize Configuration" command.
Global Configuration
# Global configuration
autoCompile: true # Automatically compile Java files on save
# Global environment variables
env:
JAVA_HOME: "/path/to/jdk" # Path to Java home directory
MVNW_PATH: "./mvnw" # Path to Maven wrapper
Project Configuration
# Multiple projects can be defined in a single workspace
projects:
# Main application
- name: DemoApplication
main: com.example.demo.DemoApplication
src: src/main/java
res: src/main/resources
target: target/classes
classpath: .easy/com.example.demo.DemoApplication.classpath
args: '--server.port=8080' # Arguments for running the application
useTerminal: true # Run in integrated terminal instead of output channel
env: # Project-specific environment variables
DB_URL: "jdbc:mysql://localhost:3306/mydb"
Each project requires:
name
: A unique identifier for the project
src
: Path to Java source directory
res
: Path to resources directory
target
: Path to compiled classes directory
classpath
: Path to classpath file
Optional project settings:
main
: Main class name to run
args
: Command line arguments for the application
command
: Custom command to run (overrides Java command)
env
: Project-specific environment variables (override global variables)
useTerminal
: Whether to run in integrated terminal (true) or output channel (false)
pom
: Path to project's pom.xml file (automatically detected)
Usage
Status Bar Integration
The extension adds a status bar item that provides quick access to all EasyJava commands:
- Click the "EasyJava" button in the status bar to show the command menu
- Select any command from the menu to execute it
Initializing Configuration
- Open a Java/Maven project in VSCode
- Open the command palette (Ctrl+Shift+P or Cmd+Shift+P)
- Type "EasyJava: Initialize Configuration" and press Enter
- The extension will scan for main classes and create a configuration file
- Each discovered main class will have its classpath generated
Generating Classpath
The classpath will be generated automatically in the following scenarios:
- When initializing the configuration
- When saving a pom.xml file
- When any changes are detected in pom.xml
You can also manually generate classpaths:
- Open the command palette
- Type "EasyJava: Generate Classpath" and press Enter
- The extension will generate classpath files for all configured projects
Automatic Compilation
When you save a Java file, the extension will automatically compile it using javac
with the appropriate classpath if the autoCompile
setting is enabled.
Running Projects
There are two ways to run a configured project:
Using the project picker:
- Open the command palette
- Type "EasyJava: Run Java Project" and press Enter
- Select the project to run from the list
Using project-specific commands:
- Open the command palette
- Type the project name (e.g., "EasyJava: Run DemoApplication")
- Press Enter to run the selected project
Compiling Projects
You can compile projects in several ways:
Using Maven:
- Open the command palette
- Type "EasyJava: Compile Project" and press Enter
- Select the project to compile
- The extension will run
mvn compile -DskipTests
Compiling Git staged files:
- Stage your Java files using Git
- Open the command palette
- Type "EasyJava: Compile Git Staged Files" and press Enter
- The extension will compile only the staged Java files
Packaging Projects
To package a project:
- Open the command palette
- Type "EasyJava: Package Project" and press Enter
- Select the project to package
- The extension will run
mvn package -DskipTests -Dmaven.clean.skip=true
Output Options
You can choose where each project's output will be displayed:
Integrated Terminal: Set useTerminal: true
to run the project in VSCode's integrated terminal. This is useful when you need to interact with the application through the console.
Output Channel: Set useTerminal: false
(or omit the property) to run the project in the EasyJava output channel. This is useful for non-interactive applications.
Custom Commands
If a project has a command
property, that command will be executed instead of the default Java command. This allows you to configure arbitrary commands for each project:
projects:
- name: SpringBootApp
src: src/main/java
res: src/main/resources
target: target/classes
classpath: .easy/classpath.txt
command: './mvnw spring-boot:run -Dspring-boot.run.arguments="--server.port=8082"'
useTerminal: true # Run in integrated terminal
Environment Variables
Environment variables can be configured globally and per-project in the configuration file. Project-specific variables override global variables with the same name.
Spring Boot Support
The extension automatically detects Spring Boot applications by looking for:
@SpringBootApplication
annotation
SpringApplication.run
method calls
- Spring Boot imports
When a Spring Boot application is detected, the extension will:
- Set appropriate default arguments
- Configure the project for Spring Boot development
Release Notes
0.0.1
- Initial release
- Support for automatic compilation and resource copying
- Configuration via YAML file
- Multi-project support
- Environment variable configuration
- Automatic project detection and classpath generation
- Dynamic command registration for projects
- Automatic classpath regeneration when pom.xml changes
- Support for running commands in integrated terminal or output channel
- Status bar integration
- Git staged files compilation
- Spring Boot application detection
- Maven wrapper support
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Links