【发布时间】:2017-10-16 16:16:14
【问题描述】:
我正在开发一个 spring-boot maven 项目(Maven 3.5、Java 8)。因为在我的项目中使用 Swagger Codegen 生成类,所以 pom.xml 的“plugins”标签越来越大:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.3</version>
<executions>
<execution>
<id>file1</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/swagger/../file1.json</inputSpec>
<generateApis>false</generateApis>
<generateSupportingFiles>false</generateSupportingFiles>
<generateApiDocumentation>false</generateApiDocumentation>
<modelPackage>com.bla.bla.model</modelPackage>
<templateDirectory>src/main/resources/swagger/templates</templateDirectory>
<language>spring</language>
<modelNamePrefix>ABC</modelNamePrefix>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<java8>true</java8>
</configOptions>
</configuration>
</execution>
<execution>
<id>file2</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/swagger/.../file2.json</inputSpec>
<generateApis>false</generateApis>
<generateSupportingFiles>false</generateSupportingFiles>
<generateApiDocumentation>false</generateApiDocumentation>
<modelPackage>com.bla.bla.model</modelPackage>
<templateDirectory>src/main/resources/swagger/templates</templateDirectory>
<language>spring</language>
<modelNamePrefix>ABC</modelNamePrefix>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<java8>true</java8>
</configOptions>
</configuration>
</execution>
...
如果我将一些插件移动到另一个 xml 文件中,是否可以将此 xml 文件包含到 pom.xml 中?如果不可能,那我该如何最小化这个文件?
编辑:这个问题不是Is it possible to split maven pom files? 的重复问题。我的项目还没有很大。只有 pom.xml 文件越来越大,因此没有必要将我的代码分成模块并以具有父子 pom.xml 文件的方式组织它。我需要一些不同的东西。
【问题讨论】:
-
见OldProgrammer 注释了解通常的maven 方式。您可以尝试 polyglot maven (github.com/takari/polyglot-maven) 以使用除 XML 以外的其他格式的 pom 文件,并在支持的方言中选择您想要的任何方言。如果你的项目足够小,你也可以考虑切换到 gradle
标签: xml maven swagger swagger-codegen