Permalink
Browse files

Allow specifying/overriding the parent in the pom file for Java and S… (

#1132)

* Allow specifying/overriding the parent in the pom file for Java and Spring generators.

* Don't add extra whitespace to the pom file when the parent isn't overridden.

* Remove accidentally added white space.
  • Loading branch information...
mwoodland authored and wing328 committed Oct 9, 2018
1 parent 5ac33a4 commit 8c0e1304813de2e0450d9b478011172f027b6e3a
Showing with 174 additions and 0 deletions.
  1. +9 −0 docs/generators/java.md
  2. +9 −0 docs/generators/spring.md
  3. +8 −0 modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java
  4. +39 −0 modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
  5. +7 −0 modules/openapi-generator/src/main/resources/Java/libraries/feign/pom.mustache
  6. +7 −0 modules/openapi-generator/src/main/resources/Java/libraries/google-api-client/pom.mustache
  7. +7 −0 modules/openapi-generator/src/main/resources/Java/libraries/jersey2/pom.mustache
  8. +7 −0 modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/pom.mustache
  9. +7 −0 modules/openapi-generator/src/main/resources/Java/libraries/rest-assured/pom.mustache
  10. +7 −0 modules/openapi-generator/src/main/resources/Java/libraries/resteasy/pom.mustache
  11. +7 −0 modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/pom.mustache
  12. +7 −0 modules/openapi-generator/src/main/resources/Java/libraries/retrofit/pom.mustache
  13. +7 −0 modules/openapi-generator/src/main/resources/Java/libraries/retrofit2/pom.mustache
  14. +7 −0 modules/openapi-generator/src/main/resources/Java/libraries/vertx/pom.mustache
  15. +7 −0 modules/openapi-generator/src/main/resources/Java/libraries/webclient/pom.mustache
  16. +7 −0 modules/openapi-generator/src/main/resources/Java/pom.mustache
  17. +9 −0 modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-boot/pom.mustache
  18. +9 −0 modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-cloud/pom.mustache
  19. +7 −0 modules/openapi-generator/src/main/resources/JavaSpring/libraries/spring-mvc/pom.mustache
View
@@ -104,6 +104,15 @@ CONFIG OPTIONS for java
booleanGetterPrefix
Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
useRxJava
Whether to use the RxJava adapter with the retrofit2 library. (Default: false)
@@ -104,6 +104,15 @@ CONFIG OPTIONS for spring
booleanGetterPrefix
Set booleanGetterPrefix (default value 'get')
parentGroupId
parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentArtifactId
parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
parentVersion
parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect
title
server title name or client service name
@@ -265,4 +265,12 @@
public static final String DATABASE_ADAPTER = "databaseAdapter";
public static final String DATABASE_ADAPTER_DESC = "The adapter for database (e.g. mysql, sqlite). Default: sqlite";
public static final String PARENT_GROUP_ID = "parentGroupId";
public static final String PARENT_GROUP_ID_DESC = "parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect";
public static final String PARENT_ARTIFACT_ID = "parentArtifactId";
public static final String PARENT_ARTIFACT_ID_DESC = "parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect";
public static final String PARENT_VERSION = "parentVersion";
public static final String PARENT_VERSION_DESC = "parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect";
}
@@ -105,6 +105,10 @@
protected boolean disableHtmlEscaping = false;
protected String booleanGetterPrefix = BOOLEAN_GETTER_PREFIX_DEFAULT;
protected boolean useNullForUnknownEnumValue = false;
protected String parentGroupId = "";
protected String parentArtifactId = "";
protected String parentVersion = "";
protected boolean parentOverridden = false;
public AbstractJavaCodegen() {
super();
@@ -198,6 +202,10 @@ public AbstractJavaCodegen() {
cliOptions.add(CliOption.newBoolean(DISABLE_HTML_ESCAPING, "Disable HTML escaping of JSON strings when using gson (needed to avoid problems with byte[] fields)"));
cliOptions.add(CliOption.newString(BOOLEAN_GETTER_PREFIX, "Set booleanGetterPrefix (default value '" + BOOLEAN_GETTER_PREFIX_DEFAULT + "')"));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_GROUP_ID, CodegenConstants.PARENT_GROUP_ID_DESC));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_ARTIFACT_ID, CodegenConstants.PARENT_ARTIFACT_ID_DESC));
cliOptions.add(CliOption.newString(CodegenConstants.PARENT_VERSION, CodegenConstants.PARENT_VERSION_DESC));
}
@Override
@@ -375,6 +383,22 @@ public void processOpts() {
this.setWithXml(Boolean.valueOf(additionalProperties.get(WITH_XML).toString()));
}
additionalProperties.put(WITH_XML, withXml);
if (additionalProperties.containsKey(CodegenConstants.PARENT_GROUP_ID)) {
this.setParentGroupId((String) additionalProperties.get(CodegenConstants.PARENT_GROUP_ID));
}
if (additionalProperties.containsKey(CodegenConstants.PARENT_ARTIFACT_ID)) {
this.setParentArtifactId((String) additionalProperties.get(CodegenConstants.PARENT_ARTIFACT_ID));
}
if (additionalProperties.containsKey(CodegenConstants.PARENT_VERSION)) {
this.setParentVersion((String) additionalProperties.get(CodegenConstants.PARENT_VERSION));
}
if (!StringUtils.isEmpty(parentGroupId) && !StringUtils.isEmpty(parentArtifactId) && !StringUtils.isEmpty(parentVersion)) {
additionalProperties.put("parentOverridden", true);
}
// make api and model doc path available in mustache template
additionalProperties.put("apiDocPath", apiDocPath);
@@ -1358,4 +1382,19 @@ public String sanitizeTag(String tag) {
return tag;
}
public void setParentGroupId(final String parentGroupId) {
this.parentGroupId = parentGroupId;
}
public void setParentArtifactId(final String parentArtifactId) {
this.parentArtifactId = parentArtifactId;
}
public void setParentVersion(final String parentVersion) {
this.parentVersion = parentVersion;
}
public void setParentOverridden(final boolean parentOverridden) {
this.parentOverridden = parentOverridden;
}
}
@@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url>
</scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses>
<license>
@@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url>
</scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses>
<license>
@@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url>
</scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses>
<license>
@@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url>
</scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses>
<license>
@@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url>
</scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses>
<license>
@@ -11,6 +11,13 @@
<developerConnection>scm:git:git@github.com:openapitools/openapi-generator.git</developerConnection>
<url>https://openapi-generator.tech</url>
</scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<build>
<plugins>
@@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url>
</scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses>
<license>
@@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url>
</scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses>
<license>
@@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url>
</scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses>
<license>
@@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url>
</scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses>
<license>
@@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url>
</scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses>
<license>
@@ -13,6 +13,13 @@
<developerConnection>{{scmDeveloperConnection}}</developerConnection>
<url>{{scmUrl}}</url>
</scm>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<licenses>
<license>
@@ -13,11 +13,20 @@
<springfox-version>2.8.0</springfox-version>
{{/useSpringfox}}
</properties>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
{{^parentOverridden}}
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>{{#java8}}2.0.1.RELEASE{{/java8}}{{^java8}}1.5.12.RELEASE{{/java8}}</version>
</parent>
{{/parentOverridden}}
<build>
<sourceDirectory>src/main/java</sourceDirectory>
{{^interfaceOnly}}
@@ -11,11 +11,20 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
<swagger-core-version>1.5.18</swagger-core-version>
</properties>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
{{^parentOverridden}}
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
</parent>
{{/parentOverridden}}
<build>
<sourceDirectory>src/main/java</sourceDirectory>
</build>
@@ -5,6 +5,13 @@
<packaging>jar</packaging>
<name>{{artifactId}}</name>
<version>{{artifactVersion}}</version>
{{#parentOverridden}}
<parent>
<groupId>{{{parentGroupId}}}</groupId>
<artifactId>{{{parentArtifactId}}}</artifactId>
<version>{{{parentVersion}}}</version>
</parent>
{{/parentOverridden}}
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>

0 comments on commit 8c0e130

Please sign in to comment.