Code review comment: This is already done in BuildCommandTest. `testResources` here is a temporary directory with test resources copied from the original location.

Code under review:
public void testBuildProjectPrecompiledWithOlderDistWithoutStickyFlag() throws IOException {
        Path projectPath = testResources.resolve("dep-dist-version-projects").resolve("preCompiledPackage");
        replaceDependenciesTomlContent(projectPath, "**INSERT_DISTRIBUTION_VERSION_HERE**", "2201.5.0");
        System.setProperty("user.dir", projectPath.toString());
        BuildCommand buildCommand = new BuildCommand(projectPath, printStream, printStream, false);

        new CommandLine(buildCommand).parseArgs();
        buildCommand.execute();
        String buildLog = readOutput(true);
        Assert.assertEquals(
                buildLog.replaceAll("\r", ""),
                getOutput("build-old-dist-precomp-proj-with-dep.txt")
                        .replaceAll("INSERT_NEW_DIST_VERSION_HERE", getNewVersionForOldDistWarning())
                        .replaceAll("INSERT_OLD_DIST_VERSION_HERE", getOldVersionForOldDistWarning("2201.5.0")));

        
        
        
        Path actualDependenciesToml = projectPath.resolve("Dependencies.toml");
        Path expectedDependenciesToml = testResources.resolve("dep-dist-version-projects").resolve("expected-dep-tomls")
                .resolve("old-dist-precomp-pkg-with-no-sticky.toml");
        Assert.assertTrue(actualDependenciesToml.toFile().exists());
        assertTomlFilesEquals(actualDependenciesToml, expectedDependenciesToml);

        
        replaceDependenciesTomlContent(projectPath, RepoUtils.getBallerinaShortVersion(),
                "**INSERT_DISTRIBUTION_VERSION_HERE**");
        replaceDependenciesTomlContent(projectPath, "1.1.0", "1.0.0");
        deleteDirectory(projectPath.resolve("target"));
    }

Line commented on: replaceDependenciesTomlContent(projectPath, RepoUtils.getBallerinaShortVersion(),

Revised code:
public void testBuildProjectPrecompiledWithOlderDistWithoutStickyFlag() throws IOException {
        Path projectPath = testResources.resolve("dep-dist-version-projects").resolve("preCompiledPackage");
        replaceDependenciesTomlContent(projectPath, "**INSERT_DISTRIBUTION_VERSION_HERE**", "2201.5.0");
        System.setProperty("user.dir", projectPath.toString());
        BuildCommand buildCommand = new BuildCommand(projectPath, printStream, printStream, false);

        new CommandLine(buildCommand).parseArgs();
        buildCommand.execute();
        String buildLog = readOutput(true);
        Assert.assertEquals(
                buildLog.replaceAll("\r", ""),
                getOutput("build-old-dist-precomp-proj-without-sticky.txt")
                        .replaceAll("INSERT_NEW_DIST_VERSION_HERE", getNewVersionForOldDistWarning())
                        .replaceAll("INSERT_OLD_DIST_VERSION_HERE", getOldVersionForOldDistWarning("2201.5.0")));

        
        
        
        Path actualDependenciesToml = projectPath.resolve("Dependencies.toml");
        Path expectedDependenciesToml = testResources.resolve("dep-dist-version-projects").resolve("expected-dep-tomls")
                .resolve("old-dist-precomp-pkg-with-no-sticky.toml");
        Assert.assertTrue(actualDependenciesToml.toFile().exists());
        assertTomlFilesEquals(actualDependenciesToml, expectedDependenciesToml);

        
        replaceDependenciesTomlContent(projectPath, RepoUtils.getBallerinaShortVersion(),
                "**INSERT_DISTRIBUTION_VERSION_HERE**");
        replaceDependenciesTomlContent(projectPath, "1.1.0", "1.0.0");
        deleteDirectory(projectPath.resolve("target"));
    }