diff --git a/ljprojectbuilder/generator/src/main/java/de/starwit/generator/services/ProjectCheckout.java b/ljprojectbuilder/generator/src/main/java/de/starwit/generator/services/ProjectCheckout.java index 04a3b2b5..74c37d5c 100644 --- a/ljprojectbuilder/generator/src/main/java/de/starwit/generator/services/ProjectCheckout.java +++ b/ljprojectbuilder/generator/src/main/java/de/starwit/generator/services/ProjectCheckout.java @@ -29,7 +29,7 @@ public String createTempProjectDirectory(final ProjectEntity project) throws Not try { Path destDir = null; destDir = Files.createTempDirectory(Constants.LJ_PREFIX + project.getTitle()); - return destDir.toString(); + return destDir.getFileName().toString(); } catch (final IOException e) { LOG.error("Error creating temporary folder for project", e); final ResponseMetadata data = new ResponseMetadata(ResponseCode.ERROR, @@ -76,7 +76,7 @@ public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) */ public void checkoutProjectTemplate(final GeneratorDto dto) throws NotificationException { final ProjectEntity entity = dto.getProject(); - final String destDirString = entity.getTargetPath(); + String destDirString = Constants.TMP_DIR + Constants.FILE_SEP + entity.getTargetPath(); final File destDir = new File(destDirString); String srcDir = entity.getTemplate().getLocation(); String branch = Constants.DEFAULT_BRANCH; diff --git a/ljprojectbuilder/generator/src/main/java/de/starwit/generator/services/ProjectRenamer.java b/ljprojectbuilder/generator/src/main/java/de/starwit/generator/services/ProjectRenamer.java index b530e0ae..208e519b 100644 --- a/ljprojectbuilder/generator/src/main/java/de/starwit/generator/services/ProjectRenamer.java +++ b/ljprojectbuilder/generator/src/main/java/de/starwit/generator/services/ProjectRenamer.java @@ -36,7 +36,7 @@ public void renameProjectTitle(ProjectEntity entity) throws NotificationExceptio LOG.info("Try to rename project " + entity.getTemplate().getPackagePrefix() + "."); File parentdirectory; - parentdirectory = new File(entity.getTargetPath()); + parentdirectory = new File(Constants.TMP_DIR + Constants.FILE_SEP + entity.getTargetPath()); String currentProjectName = entity.getTemplate().getTitle(); renameDirectories(currentProjectName, entity.getTitle(), parentdirectory, false); renameFiles(currentProjectName, entity.getTitle(), parentdirectory); @@ -50,7 +50,7 @@ public void renamePackage(ProjectEntity entity) throws NotificationException { LOG.info("Try to rename package " + entity.getTitle() + "."); File parentdirectory; - parentdirectory = new File(entity.getTargetPath()); + parentdirectory = new File(Constants.TMP_DIR + Constants.FILE_SEP + entity.getTargetPath()); renameDirectories(entity.getTemplate().getPackagePrefix(), entity.getPackagePrefix(), parentdirectory, true); renameFiles(entity.getTemplate().getPackagePrefix(), entity.getPackagePrefix(), parentdirectory); } diff --git a/ljprojectbuilder/generator/src/test/java/de/starwit/ljprojectbuilder/ejb/ProjectCheckoutTest.java b/ljprojectbuilder/generator/src/test/java/de/starwit/ljprojectbuilder/ejb/ProjectCheckoutTest.java index 961cf04e..3bd4f8de 100644 --- a/ljprojectbuilder/generator/src/test/java/de/starwit/ljprojectbuilder/ejb/ProjectCheckoutTest.java +++ b/ljprojectbuilder/generator/src/test/java/de/starwit/ljprojectbuilder/ejb/ProjectCheckoutTest.java @@ -7,6 +7,7 @@ import org.apache.log4j.Logger; import org.junit.Test; +import de.starwit.generator.config.Constants; import de.starwit.generator.services.Git; import de.starwit.generator.services.ProjectCheckout; import de.starwit.generator.services.StartupShutdownService; @@ -22,20 +23,20 @@ public class ProjectCheckoutTest { @Test public void cloneGitRepoWithoutAuthTest() throws NotificationException, IOException, InterruptedException { - final Path destDir = this.createDirectory("tmplirejarp").toPath(); - String dir = destDir.toAbsolutePath().toString(); + final Path destDir = this.createDirectory(Constants.TMP_DIR + Constants.FILE_SEP + "tmplirejarp").toPath(); + String dir = destDir.toString(); LOG.info("Path is " + dir); Git.gitClone(destDir, "https://github.com/witchpou/lirejarp.git", "master"); String[] dirContent = destDir.toFile().list(); assertTrue("Cloning repository results in an empty directory.", (dirContent != null && dirContent.length > 0)); - checkout.deleteTempProject("tmplirejarp"); + checkout.deleteTempProject(dir); } private File createDirectory(final String location) { final File file = new File(location); if (file.exists()) { - checkout.deleteTempProject("tmplirejarp"); + checkout.deleteTempProject(location); fail("Directory " + location + "should not exist."); } final boolean iscreated = file.mkdir();