Maven Linter Implementation is Incomplete
Labels: bug, enhancement, pkg/templates
Description
The maven_linter template currently generates a standalone configuration file and a plugin snippet file, but it fails to integrate the Checkstyle plugin into the project's pom.xml. As a result, the linter is not active even after being applied via scbake apply --with maven_linter.
Reproduction
- Create a Spring project:
scbake new my-app --lang spring.
- Apply the Maven linter:
scbake apply --with maven_linter.
- Check
pom.xml: The <plugin> configuration for maven-checkstyle-plugin is missing from the build section.
- Run
mvn checkstyle:check: The command fails or ignores the configuration because it isn't registered in the Project Object Model.
Expected behavior
The linter should automatically register itself within the <build><plugins> section of the existing pom.xml.
Actual behavior
The handler creates checkstyle.xml and maven-checkstyle-plugin.xml. The latter is an orphaned snippet that the user must manually copy-paste into their pom.xml to make the linter work.
Environment
- Go version: 1.22+
- OS/Arch: Linux/amd64 (Mint)
Additional context
The logic in pkg/templates/maven_linter/maven_linter.go uses tasks.CreateTemplateTask which can only create new files. To fix this properly, we will likely need:
- A new
task type capable of performing "search and replace" or XML-aware insertions within existing files.
- Logic to detect where the
<plugins> block is located in pom.xml.
Maven Linter Implementation is Incomplete
Labels:
bug,enhancement,pkg/templatesDescription
The
maven_lintertemplate currently generates a standalone configuration file and a plugin snippet file, but it fails to integrate the Checkstyle plugin into the project'spom.xml. As a result, the linter is not active even after being applied viascbake apply --with maven_linter.Reproduction
scbake new my-app --lang spring.scbake apply --with maven_linter.pom.xml: The<plugin>configuration formaven-checkstyle-pluginis missing from the build section.mvn checkstyle:check: The command fails or ignores the configuration because it isn't registered in the Project Object Model.Expected behavior
The linter should automatically register itself within the
<build><plugins>section of the existingpom.xml.Actual behavior
The handler creates
checkstyle.xmlandmaven-checkstyle-plugin.xml. The latter is an orphaned snippet that the user must manually copy-paste into theirpom.xmlto make the linter work.Environment
Additional context
The logic in
pkg/templates/maven_linter/maven_linter.gousestasks.CreateTemplateTaskwhich can only create new files. To fix this properly, we will likely need:tasktype capable of performing "search and replace" or XML-aware insertions within existing files.<plugins>block is located inpom.xml.