Skip to content

Execute run configurations automatically when closing a project or IDE - the mirror feature of IntelliJ's built-in "Startup Tasks".

License

Notifications You must be signed in to change notification settings

gdw96/Shutdown-Tasks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Centered Image

Shutdown Tasks Plugin for JetBrains IDE family

Build Version Platform

This plugin executes run configurations automatically when closing a project or IDE - the mirror feature of IntelliJ's built-in "Startup Tasks".

Table of Contents

Features

πŸš€ Automated Task Execution

  • Run any configured run/debug configuration when closing your project
  • Tasks are executed in the order you define
  • IDE waits for each task to complete
  • Configurable timeout per task (1-300 seconds)
  • Visual progress dialog with real-time status
  • Task output may be visible in Run tool window
  • Cancel anytime during execution

🎨 User-Friendly Interface

  • Intuitive configuration panel in Settings β†’ Tools β†’ Shutdown Tasks
  • Visual task list with configuration icons
  • Add/Edit/Remove and Reorder tasks easily

Installation

From JetBrains Marketplace (Recommended)

  1. Open Settings/Preferences β†’ Plugins
  2. Search for "Shutdown Tasks"
  3. Click Install
  4. Restart IDE

Manual Installation

  1. Download the latest release from Releases
  2. Open Settings/Preferences β†’ Plugins
  3. Click βš™οΈ β†’ Install Plugin from Disk...
  4. Select the downloaded .zip file
  5. Restart IDE

Build from Source

git clone https://github.com/gdw96/shutdown-tasks.git
cd shutdown-tasks
./gradlew buildPlugin

Usage

Basic Setup

  1. Open Settings

    • File β†’ Settings (Windows/Linux)
    • IntelliJ IDEA β†’ Preferences (macOS)
    • Or press Ctrl+Alt+S / ⌘+,
  2. Navigate to Shutdown Tasks

    • Tools β†’ Shutdown Tasks
  3. Add Tasks

    • Click the + button
    • Select a run configuration
    • Click OK
  4. Remove Tasks

    • Select a run configuration
    • Click the - button
  5. Edit Tasks

    • Select a run configuration
    • Click the πŸ–Š button
  6. Reorder Tasks (Optional)

    • Select a run configuration
    • Use β–² / β–Ό buttons to change execution order
  7. Set Timeout

    • Default: 5 seconds per task
    • Range: 1-300 seconds
    • ⚠️ Important: The IDE will wait for the total duration of the timeout for each task where it is impossible to monitor execution.
  8. Apply Changes

    • Click Apply or OK

Example Configurations

Stop Development Server (Shell)

#!/bin/bash
echo "Stopping development server..."
# Your server stop command here
echo "Server stopped"
exit

Configuration:

  • Type: Shell Script
  • Script: stop-server.sh
  • Interpreter path: /bin/bash
  • Execute in the terminal: Unchecked ⚠️ Important ⚠️

Use Cases

Development Workflow

  • Cleanup temporary files after each session
  • Stop background services (databases, servers, containers)
  • Archive logs or debug information
  • Commit/Stash/Push changes automatically

Deployment & CI/CD

  • Trigger builds on project close
  • Update documentation automatically

Resource Management

  • Close connections to remote servers
  • Release file locks or temporary resources
  • Stop Docker containers or VMs
  • Cleanup memory-intensive processes

Screenshots

PluginPage PluginEmptyConfig PluginSelectConfiguration PluginConfigFilled PluginClosedModal

Configuration Files

Shutdown Tasks configuration is stored in .idea/workspace.xml.

Important Notes

When and How Tasks Execute

Project Closing (File β†’ Close Project):

  • βœ… Tasks executed with the progress dialog visible
  • βœ… You can see and cancel execution
  • βœ… The IDE waits for tasks until the timeout expires.

IDE Closing (File β†’ Exit or close window):

  • βœ… Tasks executed automatically (projects close triggers them)
  • ⚠️ No progress dialog shown (IDE closes immediately)
  • ⚠️ Tasks run in background during shutdown
  • πŸ’‘ Tip: Use "Close Project" first if you want to monitor tasks

Recommendation:

  • Use File β†’ Close Project to see progress

Why Full Timeout sometimes?

Due to IntelliJ Platform limitations, the plugin cannot reliably detect when a task completes. Or your task may take longer than the timeout.

Therefore:

  • Tasks are launched and may be visible in the Run tool window
  • The progress dialog waits for the configured timeout
  • After timeout, the IDE continues closing

Task Execution During Shutdown

  • Tasks execute in sequential order (one after another)
  • Failed tasks don't prevent subsequent tasks from running
  • Task output may be visible in the Run tool window
  • Errors are logged to idea.log

Best Practices

  1. βœ… Keep tasks short - Users expect quick shutdown
  2. βœ… Test your tasks before adding to shutdown
  3. βœ… Set realistic timeouts - slightly longer than task duration
  4. βœ… Handle errors gracefully in your scripts
  5. ⚠️ Avoid interactive tasks - No user input during shutdown

Troubleshooting

Tasks Don't Execute

Problem: Tasks configured but nothing happens on project close.

Solutions:

  • Check if tasks are enabled in Settings
  • Verify run configurations still exist
  • ⚠️ Please verify that the β€œShell Script” (or other) tasks do not have the β€œRun in the terminal” option selected.
  • Check idea.log for errors (Help β†’ Show Log in Explorer/Finder)

Task Fails Silently

Problem: Task configured but appears to do nothing.

Solutions:

  • Test the run configuration manually first
  • Check task output in Run tool window
  • Make sure that the actions are carried out; the task may not display anything but still works.
  • Verify script paths and permissions
  • Add error handling to your scripts

Cannot See Task Progress

Problem: Want to see what tasks are doing.

Solutions:

  • ⚠️ Please verify that the β€œShell Script” (or other) tasks do not have the β€œRun in the terminal” option selected.
  • Check Run tool window tabs for each task's output
  • ¯⁠\⁠_⁠(⁠ツ⁠)⁠_⁠/⁠¯

Development

Requirements

  • IntelliJ IDEA 2025.2+ or compatible IDE
  • JDK 21+
  • Gradle 8.14+

Building

# Build plugin
./gradlew buildPlugin

# Run in development IDE
./gradlew runIde

# Run tests
./gradlew test

Project Structure

shutdown-tasks/
β”œβ”€β”€ src/main/kotlin/dev/gdw/shutdowntasks/
β”‚   β”œβ”€β”€ listeners/
β”‚   β”‚   └── ShutdownTasksProjectCloseListener.kt                 # Project close listener
β”‚   β”œβ”€β”€ settings/
β”‚   β”‚   └── ShutdownTasksState.kt                                # State persistence
β”‚   β”œβ”€β”€ ui/
β”‚   β”‚   β”œβ”€β”€ RunnerAndConfigurationSettingsListCellRenderer.kt    # UI renderer
β”‚   β”‚   β”œβ”€β”€ RunnerAndConfigurationSettingsSelectionDialog.kt     # Task selection dialog
β”‚   β”‚   └── ShutdownTasksConfigurable.kt                         # Settings UI
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ RunnerAndConfigurationSettingsUtils.kt               # RunnerAndConfigurationSettings Utility
β”‚   β”‚   └── ShutdownTasksRunner.kt                               # Tasks executor
β”‚   └── ShutdownTasksBundle.kt                                   # Intl
β”œβ”€β”€ src/main/resources/
β”‚   β”œβ”€β”€ META-INF/
β”‚   β”‚    β”œβ”€β”€ plugin.xml                                          # Plugin descriptor
β”‚   β”‚    └── pluginIcon.svg                                      # Plugin icon
β”‚   └── messages/                                                # Translation files
β”‚        β”œβ”€β”€ ShutdownTasksBundle.properties
β”‚        └── ShutdownTasksBundle_fr.properties
β”œβ”€β”€ build.gradle.kts                                             # Build configuration
└── README.md

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Acknowledgments

Made with ❀️ by GDW

About

Execute run configurations automatically when closing a project or IDE - the mirror feature of IntelliJ's built-in "Startup Tasks".

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages