代码之家  ›  专栏  ›  技术社区  ›  Stéphane GRILLON

如何执行两个maven版本的插件?

  •  0
  • Stéphane GRILLON  · 技术社区  · 8 年前

    如何执行两个maven版本的插件?我尝试了这个,但是在3.0.0-snapshot中全部执行

    我遇到了一个问题,因为v2.x.x使用v2 swagger文件,而v3.0.0使用v3 swagger文件。

    <plugin>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-codegen-maven-plugin</artifactId>
        <version>2.3.1</version>
        <executions>
            <execution>
                <id>first in v2</id>
                ...
            </execution>
        </executions>
    </plugin>
    <plugin>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-codegen-maven-plugin</artifactId>
        <version>3.0.0-SNAPSHOT</version>
        <executions>
            <execution>
                <id>second in v3</id>
                ...
            </execution>
        </executions>
    </plugin>
    
    2 回复  |  直到 8 年前
        1
  •  1
  •   J Fabian Meier    8 年前

    跟随

    Can Maven 2 use two different versions of a build plugin in the same project?

    做你想做的事是不可能的。我看到的唯一机会是获取源代码并用不同的名称编译插件。在你这样做之前,我真的会寻找另一种方法来实现你想要实现的目标。

        2
  •  0
  •   Stéphane GRILLON    8 年前

    我使用父/模块maven特性。

    我的项目父级

    <modules>
        <module>foodle-importer-core</module>
        <module>foodle-api</module>
        <module>diffusion-api</module>
    </modules>  
    

    架构:

    MyProject-parent
           ---------ModuleA-SourceGeneratorV2 (contain swagger-codegen-maven-plugin v2.3.1)
           ---------ModuleB-SourceGeneratorV3 (contain swagger-codegen-maven-plugin v3.0.0-SNAPSHOT)
           ---------ModuleC-MyProject (contain `ModuleA-SourceGeneratorV2` and `ModuleB-SourceGeneratorV3` dependencies)