Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

389
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda