Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Maven Codegen Helper

A VS Code extension that detects Maven projects using swagger-codegen-maven-plugin and offers to add build-helper-maven-plugin so that IDEs correctly include generated sources on the classpath.

Problem

When using swagger-codegen-maven-plugin, the generated Java sources end up in target/generated-sources/swagger/src/main/java. Without build-helper-maven-plugin, IDEs like VS Code and IntelliJ may not automatically add this path to the project's source folders, leading to unresolved imports and red squiggles.

What it does

  1. On workspace open, scans all pom.xml files for the presence of swagger-codegen-maven-plugin.
  2. For each match, checks whether build-helper-maven-plugin is already configured.
  3. If the plugin is missing, shows a notification toast offering to add it automatically.
  4. When accepted, inserts the following plugin at the end of the <plugins> section in the <build> block:
<plugin>
    <!-- a hint for IDEs to add the java sources to the classpath -->
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>3.4.0</version>
    <executions>
        <execution>
            <?m2e execute onConfiguration,onIncremental?>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>add-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>target/generated-sources/swagger/src/main/java</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

Usage

  • Automatic: The extension activates whenever a workspace contains a pom.xml. It checks all Maven projects on startup.
  • Manual: Run the command Maven Codegen Helper: Check Projects from the Command Palette (Cmd+Shift+P).
  • On save: When you save a pom.xml, the extension re-checks that file.

Installation (development)

cd maven-codegen-helper
npm install
npm run compile

Then press F5 in VS Code to launch the Extension Development Host.

Packaging

npm install -g @vscode/vsce
vsce package

This produces a .vsix file you can install via Extensions: Install from VSIX... in VS Code.

Requirements

  • VS Code 1.80+
  • A Maven project with pom.xml in the workspace

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages