|
16 | 16 | <name>template-placeholder</name> |
17 | 17 | <description>template-placeholder</description> |
18 | 18 |
|
| 19 | + <properties> |
| 20 | + <generatedDirRelative>src/generated/java</generatedDirRelative> |
| 21 | + <generatedDir>${project.basedir}/${generatedDirRelative}</generatedDir> |
| 22 | + </properties> |
| 23 | + |
| 24 | + <dependencies> |
| 25 | + <!-- HTTP client: apache client --> |
| 26 | + <dependency> |
| 27 | + <groupId>org.apache.httpcomponents.client5</groupId> |
| 28 | + <artifactId>httpclient5</artifactId> |
| 29 | + <version>5.6.5</version> |
| 30 | + </dependency> |
| 31 | + |
| 32 | + <!-- JSON processing: jackson --> |
| 33 | + <dependency> |
| 34 | + <groupId>tools.jackson.core</groupId> |
| 35 | + <artifactId>jackson-databind</artifactId> |
| 36 | + <version>3.2.4</version> |
| 37 | + </dependency> |
| 38 | + <dependency> |
| 39 | + <groupId>org.openapitools</groupId> |
| 40 | + <artifactId>jackson-databind-nullable</artifactId> |
| 41 | + <version>0.2.12</version> |
| 42 | + </dependency> |
| 43 | + |
| 44 | + <dependency> |
| 45 | + <groupId>jakarta.annotation</groupId> |
| 46 | + <artifactId>jakarta.annotation-api</artifactId> |
| 47 | + <version>3.0.0</version> |
| 48 | + </dependency> |
| 49 | + </dependencies> |
| 50 | + |
| 51 | + <build> |
| 52 | + <plugins> |
| 53 | + <plugin> |
| 54 | + <groupId>org.codehaus.mojo</groupId> |
| 55 | + <artifactId>build-helper-maven-plugin</artifactId> |
| 56 | + <version>3.6.2</version> |
| 57 | + <executions> |
| 58 | + <execution> |
| 59 | + <phase>generate-sources</phase> |
| 60 | + <goals> |
| 61 | + <goal>add-source</goal> |
| 62 | + </goals> |
| 63 | + <configuration> |
| 64 | + <sources> |
| 65 | + <source>${generatedDirRelative}</source> |
| 66 | + </sources> |
| 67 | + </configuration> |
| 68 | + </execution> |
| 69 | + </executions> |
| 70 | + </plugin> |
| 71 | + </plugins> |
| 72 | + </build> |
| 73 | + <profiles> |
| 74 | + <profile> |
| 75 | + <id>openapi-generator</id> |
| 76 | + <properties> |
| 77 | + <componentName>INSERT_NAME_HERE</componentName> |
| 78 | + |
| 79 | + <openApiRelativeGeneratorDir>src/gen</openApiRelativeGeneratorDir> |
| 80 | + <openApiGeneratorDir> |
| 81 | + ${project.basedir}/target/generated-sources/openapi/${openApiRelativeGeneratorDir} |
| 82 | + </openApiGeneratorDir> |
| 83 | + </properties> |
| 84 | + <build> |
| 85 | + <plugins> |
| 86 | + <plugin> |
| 87 | + <groupId>org.apache.maven.plugins</groupId> |
| 88 | + <artifactId>maven-clean-plugin</artifactId> |
| 89 | + <version>3.5.0</version> |
| 90 | + <executions> |
| 91 | + <execution> |
| 92 | + <id>pre-generation-clean</id> |
| 93 | + <phase>initialize</phase> |
| 94 | + <goals> |
| 95 | + <goal>clean</goal> |
| 96 | + </goals> |
| 97 | + <configuration> |
| 98 | + <excludeDefaultDirectories>true</excludeDefaultDirectories> |
| 99 | + <filesets> |
| 100 | + <fileset> |
| 101 | + <directory>${generatedDir}</directory> |
| 102 | + </fileset> |
| 103 | + </filesets> |
| 104 | + </configuration> |
| 105 | + </execution> |
| 106 | + <execution> |
| 107 | + <id>post-generation-clean</id> |
| 108 | + <phase>process-resources</phase> |
| 109 | + <goals> |
| 110 | + <goal>clean</goal> |
| 111 | + </goals> |
| 112 | + </execution> |
| 113 | + </executions> |
| 114 | + </plugin> |
| 115 | + <plugin> |
| 116 | + <groupId>org.openapitools</groupId> |
| 117 | + <artifactId>openapi-generator-maven-plugin</artifactId> |
| 118 | + <version>7.27.0</version> |
| 119 | + <executions> |
| 120 | + <execution> |
| 121 | + <goals> |
| 122 | + <goal>generate</goal> |
| 123 | + </goals> |
| 124 | + <configuration> |
| 125 | + <inputSpec>${project.basedir}/openapi/openapi.yml</inputSpec> |
| 126 | + <generatorName>java</generatorName> |
| 127 | + <configOptions> |
| 128 | + <sourceFolder>${openApiRelativeGeneratorDir}</sourceFolder> |
| 129 | + <library>apache-httpclient</library> |
| 130 | + <apiPackage>software.xdev.${componentName}.api</apiPackage> |
| 131 | + <modelPackage>software.xdev.${componentName}.model</modelPackage> |
| 132 | + <invokerPackage>software.xdev.${componentName}.client</invokerPackage> |
| 133 | + <!-- Otherwise throw and catch everywhere --> |
| 134 | + <useRuntimeException>true</useRuntimeException> |
| 135 | + <!-- Some fields of API have been ignored because they are unused --> |
| 136 | + <disallowAdditionalPropertiesIfNotPresent>false |
| 137 | + </disallowAdditionalPropertiesIfNotPresent> |
| 138 | + <!-- Use newer Jakarta EE instead of Javax --> |
| 139 | + <useJakartaEe>true</useJakartaEe> |
| 140 | + <hideGenerationTimestamp>true</hideGenerationTimestamp> |
| 141 | + <useJackson3>true</useJackson3> |
| 142 | + </configOptions> |
| 143 | + <!-- No tests and documentation because we don't use that --> |
| 144 | + <generateModelTests>false</generateModelTests> |
| 145 | + <generateApiTests>false</generateApiTests> |
| 146 | + <generateModelDocumentation>false</generateModelDocumentation> |
| 147 | + <generateApiDocumentation>false</generateApiDocumentation> |
| 148 | + </configuration> |
| 149 | + </execution> |
| 150 | + </executions> |
| 151 | + </plugin> |
| 152 | + <plugin> |
| 153 | + <groupId>org.apache.maven.plugins</groupId> |
| 154 | + <artifactId>maven-resources-plugin</artifactId> |
| 155 | + <version>3.5.0</version> |
| 156 | + <executions> |
| 157 | + <execution> |
| 158 | + <id>copy-generated-resources</id> |
| 159 | + <phase>process-sources</phase> |
| 160 | + <goals> |
| 161 | + <goal>copy-resources</goal> |
| 162 | + </goals> |
| 163 | + <configuration> |
| 164 | + <outputDirectory>${generatedDir}</outputDirectory> |
| 165 | + <resources> |
| 166 | + <resource> |
| 167 | + <directory>${openApiGeneratorDir}</directory> |
| 168 | + </resource> |
| 169 | + </resources> |
| 170 | + </configuration> |
| 171 | + </execution> |
| 172 | + </executions> |
| 173 | + </plugin> |
| 174 | + <plugin> |
| 175 | + <groupId>software.xdev</groupId> |
| 176 | + <artifactId>find-and-replace-maven-plugin</artifactId> |
| 177 | + <version>1.0.5</version> |
| 178 | + <executions> |
| 179 | + <execution> |
| 180 | + <!-- Remove so that we don't need additional dependency --> |
| 181 | + <id>remove-unused-import-com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider</id> |
| 182 | + <phase>process-sources</phase> |
| 183 | + <goals> |
| 184 | + <goal>file-contents</goal> |
| 185 | + </goals> |
| 186 | + <configuration> |
| 187 | + <baseDir>${generatedDirRelative}/software/xdev/${componentName}/client/</baseDir> |
| 188 | + <fileMask>ApiClient.java</fileMask> |
| 189 | + <!-- @formatter:off DO NOT INTRODUCE LINE BREAK --> |
| 190 | + <findRegex>^import com\.fasterxml\.jackson\.jaxrs\.json\.JacksonJsonProvider;(\r?\n)</findRegex> |
| 191 | + <!-- @formatter:on --> |
| 192 | + <replaceLineBased>false</replaceLineBased> |
| 193 | + </configuration> |
| 194 | + </execution> |
| 195 | + <execution> |
| 196 | + <!-- Changes with each generator version --> |
| 197 | + <id>remove-generated-annotation</id> |
| 198 | + <phase>process-sources</phase> |
| 199 | + <goals> |
| 200 | + <goal>file-contents</goal> |
| 201 | + </goals> |
| 202 | + <configuration> |
| 203 | + <baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir> |
| 204 | + <recursive>true</recursive> |
| 205 | + <fileMask>.java</fileMask> |
| 206 | + <findRegex>^@jakarta\.annotation\.Generated.*(\r?\n)</findRegex> |
| 207 | + <replaceAll>false</replaceAll> |
| 208 | + <replaceLineBased>false</replaceLineBased> |
| 209 | + </configuration> |
| 210 | + </execution> |
| 211 | + <execution> |
| 212 | + <!-- Requiring Java serialization indicates a serious misuse of the API --> |
| 213 | + <id>remove-serialVersionUID</id> |
| 214 | + <phase>process-sources</phase> |
| 215 | + <goals> |
| 216 | + <goal>file-contents</goal> |
| 217 | + </goals> |
| 218 | + <configuration> |
| 219 | + <baseDir>${generatedDirRelative}/software/xdev/${componentName}/</baseDir> |
| 220 | + <recursive>true</recursive> |
| 221 | + <fileMask>.java</fileMask> |
| 222 | + <findRegex>^.*serialVersionUID.*(\r?\n)(\s*\r?\n)?</findRegex> |
| 223 | + <replaceAll>false</replaceAll> |
| 224 | + <replaceLineBased>false</replaceLineBased> |
| 225 | + </configuration> |
| 226 | + </execution> |
| 227 | + </executions> |
| 228 | + </plugin> |
| 229 | + </plugins> |
| 230 | + </build> |
| 231 | + </profile> |
| 232 | + <profile> |
| 233 | + <id>pmd</id> |
| 234 | + <build> |
| 235 | + <plugins> |
| 236 | + <plugin> |
| 237 | + <groupId>org.apache.maven.plugins</groupId> |
| 238 | + <artifactId>maven-pmd-plugin</artifactId> |
| 239 | + <version>3.28.0</version> |
| 240 | + <configuration> |
| 241 | + <rulesets> |
| 242 | + <ruleset>../../.config/pmd/java/ruleset.xml</ruleset> |
| 243 | + </rulesets> |
| 244 | + <excludeRoots> |
| 245 | + <excludeRoot>${generatedDir}</excludeRoot> |
| 246 | + </excludeRoots> |
| 247 | + </configuration> |
| 248 | + </plugin> |
| 249 | + </plugins> |
| 250 | + </build> |
| 251 | + </profile> |
| 252 | + </profiles> |
19 | 253 | </project> |
0 commit comments