Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

388
Views
JHipster Blueprint - How to get default Java package name path?

I am developing a blueprint with JHipster that overrides the entity-server sub-generator. The desired behaviour is to replace all files in /src/main/java/defaultpackageName/domain/ from the project generated by the blueprint with my generated files. This is my code (files.js):

const entityServerFiles = {
    noHibernate: [
        //domain files
        {
            path: 'src/main/java/XXX/domain/',
            templates: [
                {
                    file: 'Entity.java',
                    renameTo: generator => `${generator.persistClass}.java`
                }
            ]
        }
    ]
};

function writeFiles() {
    return {
        write() {
            this.writeFilesToDisk(entityServerFiles, this, false);
        }
    }
}

module.exports = {
    writeFiles
};

For now it just creates a folder XXX in /src/main/java/ with my generated files in it.

What would I need to write in the XXX in path: 'src/main/java/XXX/domain/' in order to generate the files at the right place?

I did some digging on github on the generator-jhipster project and the prompt asking the user for the default java package name is in /generator-jhipster/generators/java/index.cjs/. This is the whole code https://github.com/jhipster/generator-jhipster/blob/main/generators/java/index.cjs But I just took the important part:

const {
  PACKAGE_NAME,
  PACKAGE_NAME_DEFAULT_VALUE,
  PRETTIER_JAVA_INDENT,
  PRETTIER_JAVA_INDENT_DEFAULT_VALUE,
  BUILD_TOOL,
  BUILD_TOOL_DEFAULT_VALUE,
  BUILD_TOOL_PROMPT_CHOICES,
} = require('./constants.cjs');

get prompting() {
    return {
      async showPrompts() {
        if (this.shouldSkipPrompts()) return;
        await this.prompt(
          [
            {
              name: PACKAGE_NAME,
              type: 'input',
              validate: input => this.validatePackageName(input),
              message: 'What is your default Java package name?',
              default: () => this.sharedData.getConfigDefaultValue(PACKAGE_NAME, PACKAGE_NAME_DEFAULT_VALUE),
            },
          ],
          this.config
        );
      },
    };
  }

From what I understand, I just need to access the PACKAGE_NAME constant from my blueprint and it should work. Any ideas?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!