java generator, fix generator-test when running from main (#4334)

- Part of https://github.com/microsoft/typespec/pull/4315, though before
TypeSpec ARM fix, we'll probably will not merge that PR
This commit is contained in:
Xiaofei Cao 2024-09-05 09:57:34 +08:00 коммит произвёл GitHub
Родитель 244dbc08c0
Коммит 93377fd7dd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -43,14 +43,14 @@ import java.util.stream.Stream;
public class Main {
private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
private static final String DEFAULT_OUTPUT_DIR = "http-client-generator-test/tsp-output/";
private static Yaml yaml = null;
// java -jar target/azure-typespec-extension-jar-with-dependencies.jar
public static void main(String[] args) throws IOException {
// parameters
String inputYamlFileName = "typespec-tests/tsp-output/code-model.yaml";
String inputYamlFileName = DEFAULT_OUTPUT_DIR + "code-model.yaml";
if (args.length >= 1) {
inputYamlFileName = args[0];
}
@ -201,7 +201,7 @@ public class Main {
// output path
if (CoreUtils.isNullOrEmpty(options.getOutputDir())) {
options.setOutputDir("typespec-tests/tsp-output/");
options.setOutputDir(DEFAULT_OUTPUT_DIR);
} else if (!options.getOutputDir().endsWith("/")) {
options.setOutputDir(options.getOutputDir() + "/");
}
@ -213,7 +213,7 @@ public class Main {
if (options == null) {
// default if emitterOptions fails
options = new EmitterOptions();
options.setOutputDir("typespec-tests/tsp-output/");
options.setOutputDir(DEFAULT_OUTPUT_DIR);
if (codeModel.getLanguage().getJava() != null && !CoreUtils.isNullOrEmpty(
codeModel.getLanguage().getJava().getNamespace())) {
options.setNamespace(codeModel.getLanguage().getJava().getNamespace());