
Question:
I am working on a spring-boot maven project (Maven 3.5, Java 8). Because of using Swagger Codegen in my project to generate classes, "plugins" tag of the pom.xml is getting bigger:
<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>
...
If I move some plugins in another xml file, is it possible to include this xml file into pom.xml? If it isn't possible, then how can I minimize this file?
EDIT: This question is not a duplicate of <a href="https://stackoverflow.com/questions/2271082/is-it-possible-to-split-maven-pom-files" rel="nofollow">Is it possible to split maven pom files?</a>. My project hasn't been big yet. Only pom.xml file is getting bigger, so there is no necessity to seperate my codes into modules and organize it in a way of having parent-child pom.xml files. I need something different.
Answer1:You can define common plugin properties in <pluginManagement>
element once and then for each execution define only specific configurations. i.e. <inputSpec>src/main/resources/swagger/../file1.json</inputSpec>
Or you can do the same (<pluginManagment>
) in another parent project and in all children put only specific configurations.
UPD:
example:
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.3</version>
<configuration>
<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>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<executions>
<execution>
<id>file1</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/swagger/../file1.json</inputSpec>
</configuration>
</execution>
<execution>
<id>file2</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/swagger/.../file2.json</inputSpec>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...