Repository: jhipster/generator-jhipster
Pull request #9706 (2019-05-08 17:58:53)

Handle all blueprint name variants when searching for blueprint custo…
…m commands

A blueprint can be referenced with cli option --blueprint as both generator-jhipster-foo or just foo.
Moved utility function normalizeBlueprintName() from generator-base-private to utils, and added unit tests.

-   Please make sure the below checklist is followed for Pull Requests.

-   [ ] [Travis tests](https://travis-ci.org/jhipster/generator-jhipster/pull_requests) are green
-   [ ] Tests are added where necessary
-   [ ] Documentation is added/updated where necessary
-   [ ] Coding Rules & Commit Guidelines as per our [CONTRIBUTING.md document](https://github.com/jhipster/generator-jhipster/blob/master/CONTRIBUTING.md) are followed

<!--
Please also reference the issue number in a commit message to [automatically close the related Github issue](https://help.github.com/articles/closing-issues-via-commit-messages/)

Note: It is also possible to add `[skip ci]` to your commit message to skip Travis tests
-->



Patch:
diff --git a/cli/commands.js b/cli/commands.js
index eb6b632cfe..711096f45a 100644
--- a/cli/commands.js
+++ b/cli/commands.js
@@ -17,6 +17,7 @@
  * limitations under the License.
  */
 const chalk = require('chalk');
+const jhipsterUtils = require('../generators/utils');
 
 let customCommands = {};
 const indexOfBlueprintArgv = process.argv.indexOf('--blueprint');
@@ -24,11 +25,11 @@ if (indexOfBlueprintArgv > -1) {
     /* eslint-disable import/no-dynamic-require */
     /* eslint-disable global-require */
 
-    const blueprint = process.argv[indexOfBlueprintArgv + 1];
+    const blueprint = jhipsterUtils.normalizeBlueprintName(process.argv[indexOfBlueprintArgv + 1]);
     try {
-        customCommands = require(`generator-jhipster-${blueprint}/cli/commands`);
+        customCommands = require(`${blueprint}/cli/commands`);
     } catch (e) {
-        const msg = `No custom command found within blueprint: generator-jhipster-${blueprint}`;
+        const msg = `No custom command found within blueprint: ${blueprint}`;
         /* eslint-disable no-console */
         console.info(`${chalk.green.bold('INFO!')} ${msg}`);
     }
diff --git a/generators/app/index.js b/generators/app/index.js
index ad0923bf32..aba33677ef 100644
--- a/generators/app/index.js
+++ b/generators/app/index.js
@@ -23,6 +23,7 @@ const cleanup = require('../cleanup');
 const prompts = require('./prompts');
 const packagejs = require('../../package.json');
 const statistics = require('../statistics');
+const jhipsterUtils = require('../utils');
 
 module.exports = class extends BaseGenerator {
     constructor(args, opts) {
@@ -157,7 +158,7 @@ module.exports = class extends BaseGenerator {
 
         // This adds support for a `--blueprint` flag which can be used to specify a blueprint to use for generation
         this.option('blueprint', {
-            desc: 'Specify a generator blueprint to use for the sub generators',
+            desc: '[BETA] Specify a generator blueprint to use for the sub generators',
             type: String
         });
 
@@ -188,7 +189,7 @@ module.exports = class extends BaseGenerator {
 
         this.withEntities = this.options['with-entities'];
         this.skipChecks = this.options['skip-checks'];
-        const blueprint = this.normalizeBlueprintName(this.options.blueprint || this.config.get('blueprint'));
+        const blueprint = jhipsterUtils.normalizeBlueprintName(this.options.blueprint || this.config.get('blueprint'));
         this.blueprint = this.configOptions.blueprint = blueprint;
         this.useNpm = this.configOptions.useNpm = !this.options.yarn;
         this.useYarn = !this.useNpm;
diff --git a/generators/client/templates/angular/webpack/webpack.prod.js.ejs b/generators/client/templates/angular/webpack/webpack.prod.js.ejs
index 295129dc41..15615dfe34 100644
--- a/generators/client/templates/angular/webpack/webpack.prod.js.ejs
+++ b/generators/client/templates/angular/webpack/webpack.prod.js.ejs
@@ -35,7 +35,7 @@ const sass = require('sass');
 
 module.exports = webpackMerge(commonConfig({ env: ENV }), {
     // Enable source maps. Please note that this will slow down the build.
-    // You have to enable it in Terser config below and in tsconfig-aot.json as well
+    // You have to enable it in UglifyJSPlugin config below and in tsconfig-aot.json as well
     // devtool: 'source-map',
     entry: {
         polyfills: './<%= MAIN_SRC_DIR %>app/polyfills',
@@ -111,12 +111,12 @@ module.exports = webpackMerge(commonConfig({ env: ENV }), {
             new TerserPlugin({
                 parallel: true,
                 cache: true,
-                // sourceMap: true, // Enable source maps. Please note that this will slow down the build
                 terserOptions: {
                     ecma: 6,
                     ie8: false,
                     toplevel: true,
                     module: true,
+                    // sourceMap: true, // Enable source maps. Please note that this will slow down the build
                     compress: {
                         dead_code: true,
                         warnings: false,
diff --git a/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs b/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs
index 84d00a21a4..c3c5098bf8 100644
--- a/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs
+++ b/generators/entity-server/templates/src/main/java/package/domain/Entity.java.ejs
@@ -23,7 +23,6 @@ let importJsonIgnoreProperties = false;
 let importSet = false;
 let hasDto = dto === 'mapstruct';
 let isUsingMapsId = false;
-let hasRelationship = relationships.length !== 0;
 const uniqueEnums = {}; %><%- include imports -%>
 
 <%_ for (idx in relationships) {
@@ -55,19 +54,13 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
 import org.springframework.data.annotation.Id;
 import org.springframework.data.mongodb.core.mapping.Field;
 import org.springframework.data.mongodb.core.mapping.Document;
-    <%_ if (hasRelationship) { _%>
 import org.springframework.data.mongodb.core.mapping.DBRef;
-    <%_ } _%>
 <%_ } else if (databaseType === 'couchbase') { _%>
 import org.springframework.data.annotation.Id;
 import com.couchbase.client.java.repository.annotation.Field;
 import org.springframework.data.couchbase.core.mapping.Document;
 import org.springframework.data.couchbase.core.mapping.id.GeneratedValue;
 import org.springframework.data.couchbase.core.mapping.id.IdPrefix;
-    <%_ if (hasRelationship) { _%>
-import org.springframework.data.couchbase.core.query.FetchType;
-import org.springframework.data.couchbase.core.query.N1qlJoin;
-    <%_ } _%>
 <%_ } if (databaseType === 'sql') { _%>
 
 import javax.persistence.*;
@@ -96,9 +89,6 @@ import java.util.HashSet;
 import java.util.Set;
 <%_ } _%>
 import java.util.Objects;
-<%_ if (databaseType === 'couchbase' && hasRelationship) { _%>
-import java.util.stream.Collectors;
-<%_ } _%>
 <%_ if (databaseType === 'cassandra') { _%>
 import java.util.UUID;
 <%_ }
@@ -267,16 +257,9 @@ public class <%= asEntity(entityClass) %> implements Serializable {
     @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
                 <%_ }
             }
-        } else if (databaseType === 'mongodb' || databaseType === 'couchbase') {
-            if (databaseType === 'mongodb') { _%>
+        } else if (databaseType === 'mongodb') { _%>
     @DBRef
-        <%_ } _%>
     @Field("<%= relationshipFieldName %>")
-        <%_ if (databaseType === 'couchbase') { _%>
-    private Set<String> <%= relationshipFieldName %>Ids = new HashSet<>();
-
-    @N1qlJoin(on = "lks.<%= relationshipFieldName %>=meta(rks).id", fetchType = FetchType.IMMEDIATE)
-        <%_ } _%>
     <%_ } _%>
     private Set<<%= asEntity(otherEntityNameCapitalized) %>> <%= relationshipFieldNamePlural %> = new HashSet<>();
 
@@ -287,18 +270,10 @@ public class <%= asEntity(entityClass) %> implements Serializable {
         <%_ if (relationshipValidate) { _%>
     <%- include relationship_validators -%>
         <%_ }
-    } else if (databaseType === 'mongodb' || databaseType === 'couchbase') {
-        if (databaseType === 'mongodb') { _%>
+    } else if (databaseType === 'mongodb') { _%>
     @DBRef
-    <%_ } _%>
     @Field("<%= relationshipFieldName %>")
-    <%_ if (databaseType === 'couchbase') { _%>
-    private String <%= relationshipFieldName %>Id;
-
-    @N1qlJoin(on = "lks.<%= relationshipFieldName %>=meta(rks).id", fetchType = FetchType.IMMEDIATE)
-    <%_ }
-    }
-    _%>
+    <%_ } _%>
     <%_ if (otherEntityRelationshipNamePlural !== undefined && otherEntityRelationshipNamePlural !== '') { _%>
     @JsonIgnoreProperties("<%= otherEntityRelationshipNamePlural %>")
     <%_ } _%>
@@ -321,17 +296,10 @@ public class <%= asEntity(entityClass) %> implements Serializable {
                joinColumns = @JoinColumn(name = "<%= getColumnName(name) %>_id", referencedColumnName = "id"),
                inverseJoinColumns = @JoinColumn(name = "<%= getColumnName(relationships[idx].relationshipName) %>_id", referencedColumnName = "id"))
         <%_ }
-        } else if (databaseType === 'mongodb' || databaseType === 'couchbase') {
-            if (databaseType === 'mongodb') { _%>
+        } else if (databaseType === 'mongodb') { _%>
     @DBRef
-        <%_ } _%>
     @Field("<%= relationshipFieldNamePlural %>")
-        <%_ if (databaseType === 'couchbase') { _%>
-    private Set<String> <%= relationshipFieldName %>Ids = new HashSet<>();
-
-    @N1qlJoin(on = "lks.<%= relationshipFieldNamePlural %>=meta(rks).id", fetchType = FetchType.IMMEDIATE)
-        <%_ }
-         } if (ownerSide === false) { _%>
+    <%_ } if (ownerSide === false) { _%>
     @JsonIgnore
     <%_ } _%>
     private Set<<%= asEntity(otherEntityNameCapitalized) %>> <%= relationshipFieldNamePlural %> = new HashSet<>();
@@ -353,17 +321,10 @@ public class <%= asEntity(entityClass) %> implements Serializable {
     @OneToOne(mappedBy = "<%= otherEntityRelationshipName %>")
     @JsonIgnore
         <%_ }
-        } else if (databaseType === 'mongodb' || databaseType === 'couchbase') {
-            if (databaseType === 'mongodb') { _%>
+        } else if (databaseType === 'mongodb') { _%>
     @DBRef
-        <%_ } _%>
     @Field("<%= relationshipFieldName %>")
-        <%_ if (databaseType === 'couchbase') { _%>
-    private String <%= relationshipFieldName %>Id;
-
-    @N1qlJoin(on = "lks.<%= relationshipFieldName %>=meta(rks).id", fetchType = FetchType.IMMEDIATE)
-        <%_ }
-            if (ownerSide === false) { _%>
+    <%_     if (ownerSide === false) { _%>
     @com.fasterxml.jackson.annotation.JsonBackReference
     <%_     }
         } _%>
@@ -451,19 +412,11 @@ public class <%= asEntity(entityClass) %> implements Serializable {
 
     public <%= asEntity(entityClass) %> <%= relationshipFieldNamePlural %>(Set<<%= asEntity(otherEntityNameCapitalized) %>> <%= otherEntityNamePlural %>) {
         this.<%= relationshipFieldNamePlural %> = <%= otherEntityNamePlural %>;
-            <%_ if (databaseType === 'couchbase') { _%>
-        this.<%= relationshipFieldName %>Ids = <%= otherEntityNamePlural %>.stream()
-            .map(<%= asEntity(otherEntityNameCapitalized) %>::getId)
-            .collect(Collectors.toSet());
-            <%_ } _%>
         return this;
     }
 
     public <%= asEntity(entityClass) %> add<%= relationshipNameCapitalized %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) {
         this.<%= relationshipFieldNamePlural %>.add(<%= otherEntityName %>);
-            <%_ if (databaseType === 'couchbase') { _%>
-        this.<%= relationshipFieldName %>Ids.add(<%= otherEntityName %>.getId());
-            <%_ } _%>
             <%_ if (relationshipType === 'one-to-many') { _%>
         <%= otherEntityName %>.set<%= otherEntityRelationshipNameCapitalized %>(this);
             <%_ } else if (otherEntityRelationshipNameCapitalizedPlural !== '' && asEntity(otherEntityNameCapitalized)!=='User' && relationshipType === 'many-to-many') {
@@ -475,9 +428,6 @@ public class <%= asEntity(entityClass) %> implements Serializable {
 
     public <%= asEntity(entityClass) %> remove<%= relationshipNameCapitalized %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) {
         this.<%= relationshipFieldNamePlural %>.remove(<%= otherEntityName %>);
-            <%_ if (databaseType === 'couchbase') { _%>
-        this.<%= relationshipFieldName %>Ids.remove(<%= otherEntityName %>.getId());
-            <%_ } _%>
             <%_ if (relationshipType === 'one-to-many') { _%>
         <%= otherEntityName %>.set<%= otherEntityRelationshipNameCapitalized %>(null);
             <%_ } else if (otherEntityRelationshipNameCapitalizedPlural !== '' && asEntity(otherEntityNameCapitalized)!=='User' && relationshipType === 'many-to-many') {
@@ -490,11 +440,6 @@ public class <%= asEntity(entityClass) %> implements Serializable {
 
     public void set<%= relationshipNameCapitalizedPlural %>(Set<<%= asEntity(otherEntityNameCapitalized) %>> <%= otherEntityNamePlural %>) {
         this.<%= relationshipFieldNamePlural %> = <%= otherEntityNamePlural %>;
-        <%_ if (databaseType === 'couchbase') { _%>
-        this.<%= relationshipFieldName %>Ids = <%= otherEntityNamePlural %>.stream()
-            .map(<%= asEntity(otherEntityNameCapitalized) %>::getId)
-            .collect(Collectors.toSet());
-        <%_ } _%>
     }
     <%_ } else { _%>
 
@@ -505,18 +450,12 @@ public class <%= asEntity(entityClass) %> implements Serializable {
 
     public <%= asEntity(entityClass) %> <%= relationshipFieldName %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) {
         this.<%= relationshipFieldName %> = <%= otherEntityName %>;
-            <%_ if (databaseType === 'couchbase') { _%>
-        this.<%= relationshipFieldName %>Id = <%= otherEntityName %>.getId();
-            <%_ } _%>
         return this;
     }
         <%_ } _%>
 
     public void set<%= relationshipNameCapitalized %>(<%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>) {
         this.<%= relationshipFieldName %> = <%= otherEntityName %>;
-        <%_ if (databaseType === 'couchbase') { _%>
-        this.<%= relationshipFieldName %>Id = <%= otherEntityName %>.getId();
-        <%_ } _%>
     }
     <%_ } _%>
 <%_ } _%>
diff --git a/generators/entity-server/templates/src/main/java/package/repository/EntityRepository.java.ejs b/generators/entity-server/templates/src/main/java/package/repository/EntityRepository.java.ejs
index 25dd27e7f2..b275019382 100644
--- a/generators/entity-server/templates/src/main/java/package/repository/EntityRepository.java.ejs
+++ b/generators/entity-server/templates/src/main/java/package/repository/EntityRepository.java.ejs
@@ -33,14 +33,11 @@ import org.springframework.data.repository.query.Param;
 import org.springframework.data.mongodb.repository.Query;
 import org.springframework.data.mongodb.repository.MongoRepository;
 <%_ } _%>
-<%_ if (databaseType === 'couchbase') { _%>
-import org.springframework.data.couchbase.core.query.Query;
-<%_ } _%>
 <%_ if (databaseType === 'cassandra') { _%>
 import org.springframework.data.cassandra.repository.CassandraRepository;
 <%_ } _%>
 import org.springframework.stereotype.Repository;
-<%_ if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { _%>
+<%_ if (databaseType === 'sql' || databaseType === 'mongodb') { _%>
 
     <%_ let importList = fieldsContainOwnerManyToMany;
     for (r of relationships) {
@@ -90,15 +87,14 @@ public interface <%=entityClass%>Repository extends <% if (databaseType === 'sql
     if (relationships[idx].relationshipType === 'many-to-many' && relationships[idx].ownerSide === true) { %> left join fetch <%=entityInstance%>.<%=relationships[idx].relationshipFieldNamePlural%><%} }%> where <%=entityInstance%>.id =:id")
     Optional<<%=asEntity(entityClass)%>> findOneWithEagerRelationships(@Param("id") <%= pkType %> id);
     <%_
-        } else if (databaseType === 'mongodb' || databaseType === 'couchbase')  { _%>
-
-    @Query("<%=(databaseType === 'mongodb')?'{}':'#{#n1ql.selectEntity} WHERE #{#n1ql.filter}'%>")
+        } else if (databaseType === 'mongodb')  { _%>
+    @Query("{}")
     Page<<%=asEntity(entityClass)%>> findAllWithEagerRelationships(Pageable pageable);
 
-    @Query("<%=(databaseType === 'mongodb')?'{}':'#{#n1ql.selectEntity} WHERE #{#n1ql.filter}'%>")
+    @Query("{}")
     List<<%=asEntity(entityClass)%>> findAllWithEagerRelationships();
 
-    @Query("<%-(databaseType === 'mongodb')?"{'id': ?0}":"#{#n1ql.selectEntity} USE KEYS $1 WHERE #{#n1ql.filter}"%>")
+    @Query("{'id': ?0}")
     Optional<<%=asEntity(entityClass)%>> findOneWithEagerRelationships(<%= pkType %> id);
     <%_ }
     } _%>
diff --git a/generators/entity-server/templates/src/main/java/package/service/mapper/EntityMapper.java.ejs b/generators/entity-server/templates/src/main/java/package/service/mapper/EntityMapper.java.ejs
index e6c5c3fec6..3e25aee117 100644
--- a/generators/entity-server/templates/src/main/java/package/service/mapper/EntityMapper.java.ejs
+++ b/generators/entity-server/templates/src/main/java/package/service/mapper/EntityMapper.java.ejs
@@ -80,7 +80,7 @@ _%>
     <%_ if (renMapAnotDto === true) { _%>
     <%= asEntity(entityClass) %> toEntity(<%= asDto(entityClass)%> <%= asDto(entityInstance) %>);
     <%_ } _%>
-    <%_ if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'couchbase') { _%>
+    <%_ if (databaseType === 'sql' || databaseType === 'mongodb') { _%>
 
     default <%= asEntity(entityClass) %> fromId(<%= pkType %> id) {
         if (id == null) {
diff --git a/generators/entity/prompts.js b/generators/entity/prompts.js
index 4ceb3a8b50..e88e44842b 100644
--- a/generators/entity/prompts.js
+++ b/generators/entity/prompts.js
@@ -196,7 +196,7 @@ function askForRelationships() {
     if (context.useConfigurationFile && context.updateEntity !== 'add') {
         return;
     }
-    if (context.databaseType === 'cassandra') {
+    if (['cassandra', 'couchbase'].includes(context.databaseType)) {
         return;
     }
 
@@ -211,7 +211,7 @@ function askForRelationsToRemove() {
     if (!context.useConfigurationFile || context.updateEntity !== 'remove' || context.relNameChoices.length === 0) {
         return;
     }
-    if (context.databaseType === 'cassandra') {
+    if (['cassandra', 'couchbase'].includes(context.databaseType)) {
         return;
     }
 
diff --git a/generators/generator-base-private.js b/generators/generator-base-private.js
index fdaa6e68ed..fd4e0237db 100644
--- a/generators/generator-base-private.js
+++ b/generators/generator-base-private.js
@@ -714,20 +714,6 @@ module.exports = class extends Generator {
         }
     }
 
-    /**
-     * Normalize blueprint name: prepend 'generator-jhipster-' if needed
-     * @param {string} blueprint - name of the blueprint
-     */
-    normalizeBlueprintName(blueprint) {
-        if (blueprint && blueprint.startsWith('@')) {
-            return blueprint;
-        }
-        if (blueprint && !blueprint.startsWith('generator-jhipster')) {
-            return `generator-jhipster-${blueprint}`;
-        }
-        return blueprint;
-    }
-
     /**
      * Compose external blueprint module
      * @param {string} blueprint - name of the blueprint
@@ -736,7 +722,7 @@ module.exports = class extends Generator {
      */
     composeBlueprint(blueprint, subGen, options = {}) {
         if (blueprint) {
-            blueprint = this.normalizeBlueprintName(blueprint);
+            blueprint = jhipsterUtils.normalizeBlueprintName(blueprint);
             if (options.skipChecks === undefined || !options.skipChecks) {
                 this.checkBlueprint(blueprint, subGen);
             }
diff --git a/generators/server/templates/build.gradle.ejs b/generators/server/templates/build.gradle.ejs
index 384fc91a9f..84baa91376 100644
--- a/generators/server/templates/build.gradle.ejs
+++ b/generators/server/templates/build.gradle.ejs
@@ -195,7 +195,7 @@ project.ext.diffChangelogFile = "<%= SERVER_MAIN_RES_DIR %>config/liquibase/chan
 liquibase {
     activities {
         main {
-            driver "<% if (devDatabaseType === 'mysql') { %>com.mysql.cj.jdbc.Driver<% } else if (devDatabaseType === 'mariadb') { %>org.mariadb.jdbc.Driver<% } else if (devDatabaseType === 'postgresql') { %>org.postgresql.Driver<% } else if (devDatabaseType === 'h2Disk') { %>org.h2.Driver<% } else if (devDatabaseType === 'oracle') { %>oracle.jdbc.OracleDriver<% } %>"
+            driver "<% if (devDatabaseType === 'mysql') { %>com.mysql.jdbc.Driver<% } else if (devDatabaseType === 'mariadb') { %>org.mariadb.jdbc.Driver<% } else if (devDatabaseType === 'postgresql') { %>org.postgresql.Driver<% } else if (devDatabaseType === 'h2Disk') { %>org.h2.Driver<% } else if (devDatabaseType === 'oracle') { %>oracle.jdbc.OracleDriver<% } %>"
             url "<% if (devDatabaseType === 'mysql') { %>jdbc:mysql://localhost:3306/<%= baseName %><% } else if (devDatabaseType === 'mariadb') { %>jdbc:mariadb://localhost:3306/<%= baseName %><% } else if (devDatabaseType === 'postgresql') { %>jdbc:postgresql://localhost:5432/<%= baseName %><% } else if (devDatabaseType === 'h2Disk') { %>jdbc:h2:file:./target/h2db/db/<%= lowercaseBaseName %><% } else if (devDatabaseType === 'oracle') { %>jdbc:oracle:thin:@localhost:1521:<%= baseName %><% } else if (devDatabaseType === 'mssql') { %>jdbc:sqlserver://localhost:1433;database=<%= baseName %><% } %>"
             username "<% if (devDatabaseType === 'mysql') { %>root<% } else if (devDatabaseType === 'postgresql' || devDatabaseType === 'h2Disk' || devDatabaseType === 'h2Memory') { %><%= baseName %><% } else if (devDatabaseType === 'mssql') { %>SA<% } %>"
             password "<% if (devDatabaseType === 'mssql') { %>yourStrong(!)Password<% } %>"
@@ -205,7 +205,7 @@ liquibase {
             classpath "<%= SERVER_MAIN_RES_DIR %>"
         }
         diffLog {
-            driver "<% if (devDatabaseType === 'mysql') { %>com.mysql.cj.jdbc.Driver<% } else if (devDatabaseType === 'mariadb') { %>org.mariadb.jdbc.Driver<% } else if (devDatabaseType === 'postgresql') { %>org.postgresql.Driver<% } else if (devDatabaseType === 'h2Disk') { %>org.h2.Driver<% } else if (devDatabaseType === 'oracle') { %>oracle.jdbc.OracleDriver<% } %>"
+            driver "<% if (devDatabaseType === 'mysql') { %>com.mysql.jdbc.Driver<% } else if (devDatabaseType === 'mariadb') { %>org.mariadb.jdbc.Driver<% } else if (devDatabaseType === 'postgresql') { %>org.postgresql.Driver<% } else if (devDatabaseType === 'h2Disk') { %>org.h2.Driver<% } else if (devDatabaseType === 'oracle') { %>oracle.jdbc.OracleDriver<% } %>"
             url "<% if (devDatabaseType === 'mysql') { %>jdbc:mysql://localhost:3306/<%= baseName %><% } else if (devDatabaseType === 'mariadb') { %>jdbc:mariadb://localhost:3306/<%= baseName %><% } else if (devDatabaseType === 'postgresql') { %>jdbc:postgresql://localhost:5432/<%= baseName %><% } else if (devDatabaseType === 'h2Disk') { %>jdbc:h2:file:./target/h2db/db/<%= lowercaseBaseName %><% } else if (devDatabaseType === 'oracle') { %>jdbc:oracle:thin:@localhost:1521:<%= baseName %><% } else if (devDatabaseType === 'mssql') { %>jdbc:sqlserver://localhost:1433;database=<%= baseName %><% } %>"
             username "<% if (devDatabaseType === 'mysql') { %>root<% } else if (devDatabaseType === 'postgresql' || devDatabaseType === 'h2Disk' || devDatabaseType === 'h2Memory') { %><%= baseName %><% } else if (devDatabaseType === 'mssql') { %>SA<% } %>"
             password "<% if (devDatabaseType === 'mssql') { %>yourStrong(!)Password<% } %>"
diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs
index ca83f4e9b8..ffeb809b8e 100644
--- a/generators/server/templates/pom.xml.ejs
+++ b/generators/server/templates/pom.xml.ejs
@@ -1017,7 +1017,7 @@
                     <configuration>
                         <changeLogFile>${project.basedir}/<%= SERVER_MAIN_RES_DIR %>config/liquibase/master.xml</changeLogFile>
                         <diffChangeLogFile>${project.basedir}/<%= SERVER_MAIN_RES_DIR %>config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
-                        <driver><% if (devDatabaseType === 'mysql') { %>com.mysql.cj.jdbc.Driver<% } else if (devDatabaseType === 'mariadb') { %>org.mariadb.jdbc.Driver<% } else if (devDatabaseType === 'postgresql') { %>org.postgresql.Driver<% } else if (devDatabaseType === 'h2Disk') { %>org.h2.Driver<% } else if (devDatabaseType === 'oracle') { %>oracle.jdbc.OracleDriver<% } %></driver>
+                        <driver><% if (devDatabaseType === 'mysql') { %>com.mysql.jdbc.Driver<% } else if (devDatabaseType === 'mariadb') { %>org.mariadb.jdbc.Driver<% } else if (devDatabaseType === 'postgresql') { %>org.postgresql.Driver<% } else if (devDatabaseType === 'h2Disk') { %>org.h2.Driver<% } else if (devDatabaseType === 'oracle') { %>oracle.jdbc.OracleDriver<% } %></driver>
                         <url><% if (devDatabaseType === 'mysql') { %>jdbc:mysql://localhost:3306/<%= baseName %><% } else if (devDatabaseType === 'mariadb') { %>jdbc:mariadb://localhost:3306/<%= baseName %><% } else if (devDatabaseType === 'postgresql') { %>jdbc:postgresql://localhost:5432/<%= baseName %><% } else if (devDatabaseType === 'h2Disk') { %>jdbc:h2:file:${project.build.directory}/h2db/db/<%= lowercaseBaseName %><% } else if (devDatabaseType === 'oracle') { %>jdbc:oracle:thin:@localhost:1521:<%= baseName %><% } else if (devDatabaseType === 'mssql') { %>jdbc:sqlserver://localhost:1433;database=<%= baseName %><% } %></url>
                         <defaultSchemaName><% if (devDatabaseType === 'mysql') { %><%= baseName %><% } else if (devDatabaseType === 'postgresql') { %><% } %></defaultSchemaName>
                         <username><% if (devDatabaseType === 'mysql') { %>root<% } else if (devDatabaseType === 'postgresql' || devDatabaseType === 'h2Disk' || devDatabaseType === 'h2Memory') { %><%= baseName %><% } else if (devDatabaseType === 'mssql') { %>SA<% } %></username>
diff --git a/generators/utils.js b/generators/utils.js
index 4f521f39db..e28e05fd3a 100644
--- a/generators/utils.js
+++ b/generators/utils.js
@@ -46,7 +46,8 @@ module.exports = {
     getDBTypeFromDBValue,
     getBase64Secret,
     getRandomHex,
-    checkStringInFile
+    checkStringInFile,
+    normalizeBlueprintName
 };
 
 /**
@@ -468,3 +469,17 @@ function checkStringInFile(path, search, generator) {
     const fileContent = generator.fs.read(path);
     return fileContent.includes(search);
 }
+
+/**
+ * Normalize blueprint name: prepend 'generator-jhipster-' if needed
+ * @param {string} blueprint - name of the blueprint
+ */
+function normalizeBlueprintName(blueprint) {
+    if (blueprint && blueprint.startsWith('@')) {
+        return blueprint;
+    }
+    if (blueprint && !blueprint.startsWith('generator-jhipster')) {
+        return `generator-jhipster-${blueprint}`;
+    }
+    return blueprint;
+}


Test patch:
diff --git a/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs b/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs
index 46a142aa52..42550cecfe 100644
--- a/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs
+++ b/generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs
@@ -409,24 +409,23 @@ _%>
             .setValidator(validator).build();
     }
 
-<%_ ['DEFAULT_', 'UPDATED_'].forEach((fieldStatus) => { _%>
     /**
-     * Create an <% if (fieldStatus === 'UPDATED_') { %>updated <% } %>entity for this test.
+     * Create an entity for this test.
      *
      * This is a static method, as tests for other entities might also need it,
      * if they test an entity which requires the current entity.
      */
-    public static <%= asEntity(entityClass) %> create<% if (fieldStatus === 'UPDATED_') { _%>Updated<%_ } %>Entity(<% if (databaseType === 'sql') { %>EntityManager em<% } %>) {
+    public static <%= asEntity(entityClass) %> createEntity(<% if (databaseType === 'sql') { %>EntityManager em<% } %>) {
         <%_ if (fluentMethods) { _%>
         <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %> = new <%= asEntity(entityClass) %>()<% for (idx in fields) { %>
-            .<%= fields[idx].fieldName %>(<%=fieldStatus + fields[idx].fieldNameUnderscored.toUpperCase()%>)<% if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { %>
-            .<%= fields[idx].fieldName %>ContentType(<%=fieldStatus + fields[idx].fieldNameUnderscored.toUpperCase()%>_CONTENT_TYPE)<% } %><% } %>;
+            .<%= fields[idx].fieldName %>(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase()%>)<% if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { %>
+            .<%= fields[idx].fieldName %>ContentType(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase()%>_CONTENT_TYPE)<% } %><% } %>;
         <%_ } else { _%>
         <%= asEntity(entityClass) %> <%= asEntity(entityInstance) %> = new <%= asEntity(entityClass) %>();
             <%_ for (idx in fields) { _%>
-        <%= asEntity(entityInstance) %>.set<%= fields[idx].fieldInJavaBeanMethod %>(<%=fieldStatus + fields[idx].fieldNameUnderscored.toUpperCase() %>);
+        <%= asEntity(entityInstance) %>.set<%= fields[idx].fieldInJavaBeanMethod %>(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase() %>);
                 <%_ if ((fields[idx].fieldType === 'byte[]' || fields[idx].fieldType === 'ByteBuffer') && fields[idx].fieldTypeBlobContent !== 'text') { _%>
-        <%= asEntity(entityInstance) %>.set<%= fields[idx].fieldInJavaBeanMethod %>ContentType(<%=fieldStatus + fields[idx].fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE);
+        <%= asEntity(entityInstance) %>.set<%= fields[idx].fieldInJavaBeanMethod %>ContentType(<%='DEFAULT_' + fields[idx].fieldNameUnderscored.toUpperCase() %>_CONTENT_TYPE);
                 <%_ } _%>
             <%_ } _%>
         <%_ } _%>
@@ -443,7 +442,6 @@ _%>
             if ((relationshipValidate !== null && relationshipValidate === true) || mapsIdUse === true) { _%>
         // Add required entity
             <%_ if (alreadyGeneratedEntities.indexOf(otherEntityName) == -1) { _%>
-    <%_ if (otherEntityName === 'user') { // TODO or other entity has no unique fields _%>
         <%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %> = <%= otherEntityNameCapitalized %>ResourceIT.createEntity(<% if (databaseType === 'sql') { %>em<% } %>);
                 <%_ if (databaseType === 'sql') { _%>
         em.persist(<%= otherEntityName %>);
@@ -452,21 +450,6 @@ _%>
                 <%_ if (databaseType === 'mongodb') { _%>
         <%= otherEntityName %>.setId("fixed-id-for-tests");
                 <%_ } _%>
-    <%_ } else { _%>
-        <%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %>;
-        if (TestUtil.findAll(em, <%= otherEntityNameCapitalized %>.class).isEmpty()) {
-            <%= otherEntityName %> = <%= otherEntityNameCapitalized %>ResourceIT.create<% if (fieldStatus === 'UPDATED_') { %>Updated<% } %>Entity(<% if (databaseType === 'sql') { %>em<% } %>);
-                <%_ if (databaseType === 'sql') { _%>
-            em.persist(<%= otherEntityName %>);
-            em.flush();
-                <%_ } _%>
-                <%_ if (databaseType === 'mongodb') { _%>
-            <%= otherEntityName %>.setId("fixed-id-for-tests");
-                <%_ } _%>
-        } else {
-            <%= otherEntityName %> = TestUtil.findAll(em, <%= otherEntityNameCapitalized %>.class).get(0);
-        }
-    <%_ } _%>
             <%_ } _%>
             <%_ if (relationshipType === 'many-to-many' || relationshipType === 'one-to-many') { _%>
         <%= asEntity(entityInstance) %>.get<%= relationshipNameCapitalizedPlural %>().add(<%= otherEntityName %>);
@@ -477,7 +460,6 @@ _%>
         <%_ } } _%>
         return <%= asEntity(entityInstance) %>;
     }
-<%_ }); _%>
 
     @BeforeEach
     public void initTest() {
@@ -578,7 +560,7 @@ _%>
             if (mapsIdUse === true) { _%>
         // Add a new parent entity
                 <%_ if (alreadyGeneratedEntities.indexOf(otherEntityName) == -1) { _%>
-        <%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %> = <%= otherEntityNameCapitalized %>ResourceIT.create<% if (otherEntityName !== 'user') { _%>Updated<%_ } %>Entity(em);
+        <%= asEntity(otherEntityNameCapitalized) %> <%= otherEntityName %> = <%= otherEntityNameCapitalized %>ResourceIT.createEntity(em);
         em.persist(<%= otherEntityName %>);
         em.flush();
                 <%_ } _%>
@@ -831,10 +813,6 @@ _%>
     @Test<% if (databaseType === 'sql') { %>
     @Transactional<% } %>
     public void getAll<%= entityClassPlural %>By<%= relationship.relationshipNameCapitalized %>IsEqualToSomething() throws Exception {
-        <%_ if (relationship.relationshipValidate === true || relationship.useJPADerivedIdentifier === true) { _%>
-        // Get already existing entity
-        <%= asEntity(relationship.otherEntityNameCapitalized) %> <%= relationship.relationshipFieldName %> = <%= asEntity(entityInstance) %>.get<%= relationship.relationshipNameCapitalized %>();
-        <%_ } else { _%>
         // Initialize the database
         <%= asEntity(relationship.otherEntityNameCapitalized) %> <%= relationship.relationshipFieldName %> = <%= relationship.otherEntityNameCapitalized %>ResourceIT.createEntity(em);
         em.persist(<%= relationship.relationshipFieldName %>);
@@ -847,7 +825,6 @@ _%>
         <%= relationship.relationshipFieldName %>.set<%= relationship.otherEntityRelationshipNameCapitalized %>(<%= asEntity(entityInstance) %>);
 <%_     } _%>
 <%_ } _%>
-        <%_ } _%>
         <%= entityInstance %>Repository.saveAndFlush(<%= asEntity(entityInstance) %>);
         <% if (authenticationType === 'oauth2' && relationship.relationshipFieldName === 'user') { _%>String<%_ } else { _%>Long<% } %> <%= relationship.relationshipFieldName %>Id = <%= relationship.relationshipFieldName %>.getId();
 
diff --git a/generators/server/templates/src/test/java/package/web/rest/TestUtil.java.ejs b/generators/server/templates/src/test/java/package/web/rest/TestUtil.java.ejs
index 92af04a611..25bc7f98fa 100644
--- a/generators/server/templates/src/test/java/package/web/rest/TestUtil.java.ejs
+++ b/generators/server/templates/src/test/java/package/web/rest/TestUtil.java.ejs
@@ -35,15 +35,6 @@ import org.springframework.security.test.context.TestSecurityContextHolder;
 import java.io.IOException;
 import java.time.ZonedDateTime;
 import java.time.format.DateTimeParseException;
-<%_ if (databaseType === 'sql') { _%>
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.TypedQuery;
-import javax.persistence.criteria.CriteriaBuilder;
-import javax.persistence.criteria.CriteriaQuery;
-import javax.persistence.criteria.Root;
-<%_ } _%>
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -173,23 +164,5 @@ public final class TestUtil {
         return dfcs;
     }
 
-<%_ if (databaseType === 'sql') { _%>
-    /**
-     * Makes a an executes a query to the EntityManager finding all stored objects.
-     * @param <T> The type of objects to be searched
-     * @param em The instance of the EntityManager
-     * @param clss The class type to be searched
-     * @return A list of all found objects
-     */
-    public static <T> List<T> findAll(EntityManager em, Class<T> clss) {
-        CriteriaBuilder cb = em.getCriteriaBuilder();
-        CriteriaQuery<T> cq = cb.createQuery(clss);
-        Root<T> rootEntry = cq.from(clss);
-        CriteriaQuery<T> all = cq.select(rootEntry);
-        TypedQuery<T> allQuery = em.createQuery(all);
-        return allQuery.getResultList();
-    }
-<%_ } _%>
-
     private TestUtil() {}
 }
diff --git a/test-integration/samples/jdl-default/app.jdl b/test-integration/samples/jdl-default/app.jdl
index 5a437a71cf..7732c8c03d 100644
--- a/test-integration/samples/jdl-default/app.jdl
+++ b/test-integration/samples/jdl-default/app.jdl
@@ -105,18 +105,6 @@ entity Task {
   description String
 }
 
-entity GoldenBadge {
-  name String
-}
-
-entity SilverBadge {
-  name String
-}
-
-entity Identifier {
-  name String required unique
-}
-
 entity Country {
   name String
 }
@@ -126,8 +114,7 @@ entity Region {
 }
 
 relationship OneToOne {
-  Department{location} to Location,
-  Employee{user(login)} to User with jpaDerivedIdentifier
+  Department{location} to Location
 }
 
 relationship OneToMany {
@@ -151,28 +138,25 @@ relationship OneToMany {
   Employee{department},
   Employee{job} to Job{emp(lastName)},
   Location{country} to Country,
-  Country{area(name)} to Region
+  Country{area(region)} to Region
 }
 
 relationship ManyToOne {
-  Employee{manager(lastName)} to Employee,
-  Employee{sibag(name) required} to SilverBadge,
-  Employee{gobag(name) required} to GoldenBadge,
-  SilverBadge{iden(name) required} to Identifier,
-  GoldenBadge{iden(name) required} to Identifier
+  Employee{user(login)} to User{employee},
+  Employee{manager(lastName)} to Employee
 }
 
 relationship ManyToMany {
   JobHistory to Department,
   JobHistory to Job{history},
-  JobHistory{emp(firstName)} to Employee{history},
-  Job{chore(title)} to Task{linkedJob(title)}
+  JobHistory{emp(employee)} to Employee{history},
+  Job{chore(title)} to Task{linkedJob(JobTitle)}
 }
 
-dto BankAccount, Employee, Department, Location, Country, Region, SilverBadge, GoldenBadge, Identifier with mapstruct
+dto BankAccount, Employee, Department, Location, Country, Region with mapstruct
 
 angularSuffix BankAccount with mySuffix
-filter BankAccount, Employee
+filter BankAccount
 clientRootFolder BankAccount, TheLabel, Operation with test-root
 
 paginate TheLabel, Job with pagination
diff --git a/test/app.spec.js b/test/app.spec.js
index 835ce09079..5fe029a6ed 100644
--- a/test/app.spec.js
+++ b/test/app.spec.js
@@ -1466,6 +1466,7 @@ describe('JHipster generator', () => {
                         ['package.json']
                     )
                 );
+                assert.noFile(['gradle/yeoman.gradle']);
             });
             it('generates README with instructions for Gradle', () => {
                 assert.fileContent('README.md', './gradlew');
diff --git a/test/cli/import-jdl.spec.js b/test/cli/import-jdl.spec.js
index 3a0e7d5eab..ebfbc82026 100644
--- a/test/cli/import-jdl.spec.js
+++ b/test/cli/import-jdl.spec.js
@@ -35,39 +35,6 @@ const mockFork = (done, tries) => (runYeomanProcess, argv, opts) => {
     };
 };
 
-function testDocumentsRelationships() {
-    it('creates entity json files', () => {
-        assert.file([
-            '.jhipster/Customer.json',
-            '.jhipster/CustomerOrder.json',
-            '.jhipster/OrderedItem.json',
-            '.jhipster/PaymentDetails.json',
-            '.jhipster/ShippingDetails.json'
-        ]);
-    });
-    it('calls entity subgenerator', () => {
-        expect(subGenCallParams.count).to.equal(5);
-        expect(subGenCallParams.commands).to.eql([
-            'jhipster:entity Customer',
-            'jhipster:entity CustomerOrder',
-            'jhipster:entity OrderedItem',
-            'jhipster:entity PaymentDetails',
-            'jhipster:entity ShippingDetails'
-        ]);
-        expect(subGenCallParams.options[0]).to.eql({
-            regenerate: true,
-            force: true,
-            'from-cli': true,
-            'no-fluent-methods': undefined,
-            'skip-client': undefined,
-            'skip-install': true,
-            'skip-server': undefined,
-            'skip-ui-grouping': undefined,
-            'skip-user-management': undefined
-        });
-    });
-}
-
 describe('JHipster generator import jdl', () => {
     beforeEach(() => {
         subGenCallParams = {
@@ -111,26 +78,42 @@ describe('JHipster generator import jdl', () => {
     describe('imports a JDL entity model with relations for mongodb', () => {
         beforeEach(done => {
             testInTempDir(dir => {
-                fse.copySync(path.join(__dirname, '../templates/documents-with-relations'), dir);
                 fse.copySync(path.join(__dirname, '../templates/mongodb-with-relations'), dir);
                 importJdl(['orders-model.jdl'], {}, env);
                 done();
             });
         });
 
-        testDocumentsRelationships();
-    });
-    describe('imports a JDL entity model with relations for couchbase', () => {
-        beforeEach(done => {
-            testInTempDir(dir => {
-                fse.copySync(path.join(__dirname, '../templates/documents-with-relations'), dir);
-                fse.copySync(path.join(__dirname, '../templates/couchbase-with-relations'), dir);
-                importJdl(['orders-model.jdl'], {}, env);
-                done();
+        it('creates entity json files', () => {
+            assert.file([
+                '.jhipster/Customer.json',
+                '.jhipster/CustomerOrder.json',
+                '.jhipster/OrderedItem.json',
+                '.jhipster/PaymentDetails.json',
+                '.jhipster/ShippingDetails.json'
+            ]);
+        });
+        it('calls entity subgenerator', () => {
+            expect(subGenCallParams.count).to.equal(5);
+            expect(subGenCallParams.commands).to.eql([
+                'jhipster:entity Customer',
+                'jhipster:entity CustomerOrder',
+                'jhipster:entity OrderedItem',
+                'jhipster:entity PaymentDetails',
+                'jhipster:entity ShippingDetails'
+            ]);
+            expect(subGenCallParams.options[0]).to.eql({
+                regenerate: true,
+                force: true,
+                'from-cli': true,
+                'no-fluent-methods': undefined,
+                'skip-client': undefined,
+                'skip-install': true,
+                'skip-server': undefined,
+                'skip-ui-grouping': undefined,
+                'skip-user-management': undefined
             });
         });
-
-        testDocumentsRelationships();
     });
     describe('imports a JDL entity model from single file with --json-only flag', () => {
         beforeEach(done => {
diff --git a/test/templates/couchbase-with-relations/.yo-rc.json b/test/templates/couchbase-with-relations/.yo-rc.json
deleted file mode 100644
index 7a50dce9df..0000000000
--- a/test/templates/couchbase-with-relations/.yo-rc.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-    "generator-jhipster": {
-        "applicationType": "monolith",
-        "baseName": "sampleCouchbase",
-        "packageName": "com.mycompany.myapp",
-        "packageFolder": "com/mycompany/myapp",
-        "authenticationType": "session",
-        "cacheProvider": "ehcache",
-        "enableHibernateCache": true,
-        "websocket": "no",
-        "databaseType": "couchbase",
-        "devDatabaseType": "couchbase",
-        "prodDatabaseType": "couchbase",
-        "searchEngine": "elasticsearch",
-        "useSass": false,
-        "buildTool": "maven",
-        "enableTranslation": true,
-        "rememberMeKey": "2bb60a80889aa6e6767e9ccd8714982681152aa5",
-        "languages": ["en", "fr"],
-        "testFrameworks": [
-            "gatling"
-        ]
-    }
-}
diff --git a/test/templates/documents-with-relations/orders-model.jdl b/test/templates/mongodb-with-relations/orders-model.jdl
similarity index 100%
rename from test/templates/documents-with-relations/orders-model.jdl
rename to test/templates/mongodb-with-relations/orders-model.jdl
diff --git a/test/utils.spec.js b/test/utils.spec.js
index 2061d94a41..54a680736e 100644
--- a/test/utils.spec.js
+++ b/test/utils.spec.js
@@ -74,4 +74,18 @@ describe('JHipster Utils', () => {
             });
         });
     });
+    describe('::normalizeBlueprintName', () => {
+        it('adds generator-jhipster prefix if it is absent', () => {
+            const generatorName = utils.normalizeBlueprintName('foo');
+            assert.textEqual(generatorName, 'generator-jhipster-foo');
+        });
+        it('keeps generator-jhipster prefix if it is present', () => {
+            const generatorName = utils.normalizeBlueprintName('generator-jhipster-foo');
+            assert.textEqual(generatorName, 'generator-jhipster-foo');
+        });
+        it("doesn't  do anything for scoped package", () => {
+            const generatorName = utils.normalizeBlueprintName('@corp/foo');
+            assert.textEqual(generatorName, '@corp/foo');
+        });
+    });
 });