Skip to content

Add subproject compile and test commands#1983

Open
bbatsov wants to merge 1 commit intomasterfrom
feature/1653-compile-subproject
Open

Add subproject compile and test commands#1983
bbatsov wants to merge 1 commit intomasterfrom
feature/1653-compile-subproject

Conversation

@bbatsov
Copy link
Owner

@bbatsov bbatsov commented Feb 16, 2026

Summary

Closes #1653.

  • Add projectile-subproject-root helper that walks up from the current directory to find the nearest build file (:project-file marker), stopping at the project root
  • Add projectile-compile-subproject — runs the project's compile command in the nearest subproject directory
  • Add projectile-test-subproject — runs the project's test command in the nearest subproject directory
  • Keybindings: c m c (compile subproject), c m t (test subproject)

This works for any project type that defines :project-file — Maven (pom.xml), Gradle (build.gradle), Leiningen (project.clj), etc. The implementation let-binds projectile-project-compilation-dir so the existing projectile--run-project-cmd infrastructure handles everything else (command caching, buffer naming, prompting, etc.).

Example: Maven multi-module project

myproject/
  pom.xml          <- project root
  module-foo/
    pom.xml        <- subproject root (found when editing Foo.java)
    src/main/java/
      Foo.java
  module-bar/
    pom.xml
    src/main/java/
      Bar.java

With cursor in Foo.java, C-c p c m c runs mvn -B clean install in module-foo/ instead of the project root.

Test plan

  • Byte-compiles cleanly
  • All 210 existing tests pass
  • Manual testing with a multi-module Maven or Gradle project

Add `projectile-compile-subproject` and `projectile-test-subproject`
for building/testing individual modules in multi-module projects
(e.g. Maven, Gradle).  These commands find the nearest build file
(project-file marker) between the current directory and the project
root, then run the compile/test command in that directory.

Keybindings: `c m c` (compile subproject), `c m t` (test subproject).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Support build of single maven module in multi-module maven projects

1 participant

Comments