import BaseApplicationGenerator from '../../../base-application/index.js';
export default class JibGenerator extends BaseApplicationGenerator {
    async beforeQueue() {
        if (!this.fromBlueprint) {
            await this.composeWithBlueprints();
        }
        if (!this.delegateToBlueprint) {
            await this.dependsOnBootstrapApplication();
            await this.dependsOnJHipster('begcode:java:build-tool');
        }
    }
    get composing() {
        return this.asComposingTaskGroup({
            async compose() {
                const { buildTool } = this.jhipsterConfigWithDefaults;
                if (buildTool === 'maven') {
                    await this.composeWithJHipster('begcode:maven:jib');
                }
                else if (buildTool === 'gradle') {
                    await this.composeWithJHipster('begcode:gradle:jib');
                }
            },
        });
    }
    get [BaseApplicationGenerator.COMPOSING]() {
        return this.delegateTasksToBlueprint(() => this.composing);
    }
    get writing() {
        return this.asWritingTaskGroup({
            async write({ application }) {
                const { dockerServicesDir } = application;
                await this.writeFiles({
                    blocks: [
                        {
                            path: `${dockerServicesDir}jib/`,
                            templates: ['entrypoint.sh'],
                        },
                    ],
                    context: application,
                });
            },
        });
    }
    get [BaseApplicationGenerator.WRITING]() {
        return this.delegateTasksToBlueprint(() => this.writing);
    }
}
