diff --git a/build.gradle.kts b/build.gradle.kts index e89c274b..281088cb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,11 +1,11 @@ import org.gradle.api.JavaVersion import xyz.jpenilla.resourcefactory.bukkit.BukkitPluginYaml +import java.io.IOException import java.nio.file.Files import java.nio.file.Paths import java.nio.file.StandardOpenOption import java.nio.file.NoSuchFileException -import java.nio.file.StandardCopyOption plugins { java @@ -181,9 +181,18 @@ tasks.register("renameProject") { replaceStringInFile(buildFilePath, "val mainProjectAuthor = \"$mainProjectAuthor\"", "val mainProjectAuthor = \"$newAuthorName\"") replaceStringInFile(buildFilePath, "val topLevelDomain = \"$topLevelDomain\"", "val topLevelDomain = \"$newTopLevelDomain\"") - Paths.get("$startPath/$currentGroupPath/$currentMainFileNameWithExtension").toFile().renameTo( - Paths.get("$startPath/$newGroupPath/$newMainFileNameWithExtension").toFile() - ) + val currentMainFilePath = javaSourcePath.resolve(currentGroupPath).resolve(currentMainFileNameWithExtension) + val newMainFilePath = javaSourcePath.resolve(newGroupPath).resolve(newMainFileNameWithExtension) + + try { + Files.move(currentMainFilePath.toPath(), newMainFilePath.toPath()) + println("Renamed file successfully") + } catch (exception: IOException) { + exception.printStackTrace() + error("Failed to rename file") + } + + // Ensure directories are renamed and other replacements are done similarly renamePackageDirectories("${javaSourcePathString}/${currentGroupPath}", "${javaSourcePathString}/${newGroupPath}")