From 9a1abb430cf8a18e92bfcbc20f278bb985d2a18d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 11 Dec 2024 09:42:38 +0100 Subject: [PATCH] Touch the compile path when writing .app file for the first time Closes #14049. --- lib/mix/lib/mix/tasks/compile.app.ex | 7 +++++++ lib/mix/test/mix/tasks/compile.app_test.exs | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/mix/lib/mix/tasks/compile.app.ex b/lib/mix/lib/mix/tasks/compile.app.ex index 61fcb907783..78c51706fcf 100644 --- a/lib/mix/lib/mix/tasks/compile.app.ex +++ b/lib/mix/lib/mix/tasks/compile.app.ex @@ -189,6 +189,13 @@ defmodule Mix.Tasks.Compile.App do Mix.Project.ensure_structure() File.write!(target, IO.chardata_to_string(contents)) File.touch!(target, new_mtime) + + # If we just created the .app file, it will have touched + # the directory mtime, so we need to reset it. + if current_properties == [] do + File.touch!(compile_path, new_mtime) + end + Mix.shell().info("Generated #{app} app") {:ok, []} else diff --git a/lib/mix/test/mix/tasks/compile.app_test.exs b/lib/mix/test/mix/tasks/compile.app_test.exs index 943a1876dd6..3674bfcfb25 100644 --- a/lib/mix/test/mix/tasks/compile.app_test.exs +++ b/lib/mix/test/mix/tasks/compile.app_test.exs @@ -66,8 +66,6 @@ defmodule Mix.Tasks.Compile.AppTest do test "generates .app file when changes happen" do in_fixture("no_mixfile", fn -> Mix.Project.push(MixTest.Case.Sample) - # Pre-create the compilation path to avoid mtime races - File.mkdir_p(Mix.Project.compile_path()) Mix.Tasks.Compile.Elixir.run([]) assert Mix.Tasks.Compile.App.run([]) == {:ok, []} @@ -256,8 +254,6 @@ defmodule Mix.Tasks.Compile.AppTest do test ".app contains description and registered (as required by systools)" do in_fixture("no_mixfile", fn -> Mix.Project.push(MixTest.Case.Sample) - # Pre-create the compilation path to avoid mtime races - File.mkdir_p(Mix.Project.compile_path()) Mix.Tasks.Compile.Elixir.run([]) assert Mix.Tasks.Compile.App.run([]) == {:ok, []}