Skip to content

Commit cdadc8a

Browse files
[Xamarin.Android.Build.Tasks] only update typemap timestamps if changes occur
Context: dotnet#1930 Since 3d999d3, `Fast Deployment` has been rebuilding the APK when it shouldn't. Apparently the `typemap.mj` and `typemap.jm` files' timestamps are used when deciding to repack/deploy the APK or not. After looking at my `CheckTimestamps` test, I don't think it was quite right. It should modify `MainActivity`'s type name so that these files will be updated. Just modifying code won't invalidate these files. Then the `GenerateJavaStubs` task should only update the timestamps if the file was actually changed, which should fix `Fast Deployment`.
1 parent 8b7411b commit cdadc8a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,9 @@ void UpdateWhenChanged (string path, Action<Stream> generator)
306306
var np = path + ".new";
307307
using (var o = File.OpenWrite (np))
308308
generator (o);
309-
MonoAndroidHelper.CopyIfChanged (np, path);
310-
MonoAndroidHelper.SetLastAccessAndWriteTimeUtc (path, DateTime.UtcNow, Log);
309+
if (MonoAndroidHelper.CopyIfChanged (np, path)) {
310+
MonoAndroidHelper.SetLastAccessAndWriteTimeUtc (path, DateTime.UtcNow, Log);
311+
}
311312
File.Delete (np);
312313
}
313314
}

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ public void CheckTimestamps ()
227227
Assert.IsTrue (info.LastWriteTimeUtc > start, $"`{file}` is older than `{start}`, with a timestamp of `{info.LastWriteTimeUtc}`!");
228228
}
229229

230-
//Build again after a code change, checking a few files
231-
proj.MainActivity = proj.DefaultMainActivity.Replace ("clicks", "CLICKS");
230+
//Build again after a code change (renamed Java.Lang.Object subclass), checking a few files
231+
proj.MainActivity = proj.DefaultMainActivity.Replace ("MainActivity", "MainActivity2");
232232
proj.Touch ("MainActivity.cs");
233233
start = DateTime.UtcNow;
234234
Assert.IsTrue (b.Build (proj), "second build should have succeeded.");

0 commit comments

Comments
 (0)