import BaseApplicationGenerator from '../../../base-application/index.js';
import { GRADLE_BUILD_SRC_MAIN_DIR } from '../../../generator-constants.js';
import { GENERATOR_GRADLE } from '../../../generator-list.js';
export default class CodeQualityGenerator extends BaseApplicationGenerator {
    async beforeQueue() {
        if (!this.fromBlueprint) {
            await this.composeWithBlueprints();
        }
        if (!this.delegateToBlueprint) {
            await this.dependsOnBootstrapApplication();
            await this.dependsOnJHipster(GENERATOR_GRADLE);
        }
    }
    get writing() {
        return this.asWritingTaskGroup({
            async writing({ application }) {
                await this.writeFiles({
                    blocks: [{ templates: [`${GRADLE_BUILD_SRC_MAIN_DIR}/jhipster.docker-conventions.gradle`] }],
                    context: application,
                });
            },
        });
    }
    get [BaseApplicationGenerator.WRITING]() {
        return this.delegateTasksToBlueprint(() => this.writing);
    }
    get postWriting() {
        return this.asPostWritingTaskGroup({
            customize({ application, source }) {
                const { javaDependencies } = application;
                source.addGradleBuildSrcDependencyCatalogLibraries?.([
                    {
                        libraryName: 'jib-plugin',
                        module: 'com.google.cloud.tools:jib-gradle-plugin',
                        version: javaDependencies['jib-maven-plugin'],
                        scope: 'implementation',
                    },
                ]);
                source.addGradlePlugin?.({ id: 'jhipster.docker-conventions' });
            },
        });
    }
    get [BaseApplicationGenerator.POST_WRITING]() {
        return this.delegateTasksToBlueprint(() => this.postWriting);
    }
}
