diff --git a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/AdaptTemplatesTest.java b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/AdaptTemplatesTest.java index 854558bd81..9254a553cc 100644 --- a/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/AdaptTemplatesTest.java +++ b/cobigen-eclipse/cobigen-eclipse-test/src/main/java/com/devonfw/cobigen/eclipse/test/AdaptTemplatesTest.java @@ -182,7 +182,7 @@ public void testBasicOpenAPIGenerationWithAdaptMonolithicTemplates() throws Exce @Test public void testAdaptMonolithicTemplatesAndGenerate() throws Exception { - File tmpProject = this.tempFolder.newFolder("playground", "project"); + File tmpProject = this.tempFolder.newFolder("playground", "project", "templates"); withEnvironmentVariable("COBIGEN_HOME", tmpProject.toPath().toString()) .execute(() -> testBasicOpenAPIGenerationWithAdaptMonolithicTemplates()); } diff --git a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/CobiGenPaths.java b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/CobiGenPaths.java index c2178fb3b2..0ab76baaf8 100644 --- a/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/CobiGenPaths.java +++ b/cobigen/cobigen-core-api/src/main/java/com/devonfw/cobigen/api/util/CobiGenPaths.java @@ -74,8 +74,16 @@ public static Path getTemplatesFolderPath() { */ public static Path getTemplatesFolderPath(Path home) { - Path templatesPath = home.resolve(ConfigurationConstants.TEMPLATES_FOLDER); - return templatesPath; + File file = new File(home.toString()); + int lastSlash = file.getName().lastIndexOf("/"); + String lastWord = file.getName().substring(lastSlash + 1); + if (lastWord.equals(ConfigurationConstants.TEMPLATES_FOLDER)) { + return home; + } else { + home = home.resolve(ConfigurationConstants.TEMPLATES_FOLDER); + } + + return home; } /**