public async prompt()

in src/scaffolding/wizard/java/JavaGatherInformationStep.ts [28:70]


    public async prompt(wizardContext: JavaScaffoldingWizardContext): Promise<void> {
        if (wizardContext.artifact) {
            // If an artifact exists, it's a POM or Gradle file, we can find some info in there
            const contents = await fse.readFile(wizardContext.artifact, 'utf-8');

            if (/pom.xml$/i.test(wizardContext.artifact)) {
                // If it's a POM file, parse as XML
                this.javaProjectType = 'pom';
                const pomObject = <PomContents>await xml2js.parseStringPromise(contents, { trim: true, normalizeTags: true, normalize: true, mergeAttrs: true });

                wizardContext.version = pomObject?.project?.version || '0.0.1';

                if (pomObject?.project?.artifactid) {
                    wizardContext.relativeJavaOutputPath = `target/${pomObject.project.artifactid}-${wizardContext.version}.jar`;
                }
            } else {
                // Otherwise it's a gradle file, parse with that
                this.javaProjectType = 'gradle';
                const gradleObject = <GradleContents>await gradleParser.parseText(contents);

                wizardContext.version = gradleObject?.jar?.version || gradleObject?.version || '0.0.1';

                if (gradleObject?.jar?.archiveName) {
                    wizardContext.relativeJavaOutputPath = `build/libs/${gradleObject.jar.archiveName}`;
                } else if (gradleObject?.jar?.baseName) {
                    wizardContext.relativeJavaOutputPath = `build/libs/${gradleObject.jar.baseName}-${wizardContext.version}.jar`;
                } else if (gradleObject?.archivesBaseName) {
                    wizardContext.relativeJavaOutputPath = `build/libs/${gradleObject.archivesBaseName}-${wizardContext.version}.jar`;
                } else {
                    wizardContext.relativeJavaOutputPath = `build/libs/${wizardContext.workspaceFolder.name}-${wizardContext.version}.jar`;
                }
            }
        }

        await super.prompt(wizardContext);

        if (!wizardContext.relativeJavaOutputPath) {
            // If the artifact is not set (fell through the above if/else), it will just be the service name + .jar
            wizardContext.relativeJavaOutputPath = `${wizardContext.serviceName}.jar`;
        }

        wizardContext.debugPorts = [5005];
    }