Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/CompileToDalvik.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected override string GenerateCommandLineCommands ()
cmd.AppendFileNamesIfNotNull (AlternativeJarFiles, " ");
} else {
Log.LogDebugMessage (" processing ClassesOutputDirectory...");
var zip = Path.GetFullPath (Path.Combine (ClassesOutputDirectory, "classes.zip"));
var zip = Path.GetFullPath (Path.Combine (ClassesOutputDirectory, "..", "classes.zip"));
if (!File.Exists (zip)) {
throw new FileNotFoundException ($"'{zip}' does not exist. Please rebuild the project.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected override string GenerateCommandLineCommands ()
void GenerateProguardCommands (CommandLineBuilder cmd)
{
var enclosingChar = OS.IsWindows ? "\"" : string.Empty;
var jars = JavaLibraries.Select (i => i.ItemSpec).Concat (new string [] { Path.Combine (ClassesOutputDirectory, "classes.zip") });
var jars = JavaLibraries.Select (i => i.ItemSpec).Concat (new string [] { Path.Combine (ClassesOutputDirectory, "..", "classes.zip") });
cmd.AppendSwitchIfNotNull ("-jar ", ProguardJarPath);
cmd.AppendSwitchUnquotedIfNotNull ("-injars ", "\"'" + string.Join ($"'{ProguardInputJarFilter}{Path.PathSeparator}'", jars) + $"'{ProguardInputJarFilter}\"");
cmd.AppendSwitch ("-dontwarn");
Expand All @@ -93,7 +93,7 @@ void GenerateMainDexListBuilderCommands(CommandLineBuilder cmd)
{
var enclosingDoubleQuote = OS.IsWindows ? "\"" : string.Empty;
var enclosingQuote = OS.IsWindows ? string.Empty : "'";
var jars = JavaLibraries.Select (i => i.ItemSpec).Concat (new string [] { Path.Combine (ClassesOutputDirectory, "classes.zip") });
var jars = JavaLibraries.Select (i => i.ItemSpec).Concat (new string [] { Path.Combine (ClassesOutputDirectory, "..", "classes.zip") });
cmd.AppendSwitchIfNotNull ("-Djava.ext.dirs=", Path.Combine (AndroidSdkBuildToolsPath, "lib"));
cmd.AppendSwitch ("com.android.multidex.MainDexListBuilder");
cmd.AppendSwitch ($"{enclosingDoubleQuote}{tempJar}{enclosingDoubleQuote}");
Expand Down
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/Javac.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override bool Execute ()
if (!result)
return result;
// compress all the class files
using (var zip = new ZipArchiveEx (Path.Combine (ClassesOutputDirectory, "classes.zip"), FileMode.OpenOrCreate))
using (var zip = new ZipArchiveEx (Path.Combine (ClassesOutputDirectory, "..", "classes.zip"), FileMode.OpenOrCreate))
zip.AddDirectory (ClassesOutputDirectory, "");
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/Proguard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected override string GenerateCommandLineCommands ()
if (!ClassesOutputDirectory.EndsWith (Path.DirectorySeparatorChar.ToString (), StringComparison.OrdinalIgnoreCase))
ClassesOutputDirectory += Path.DirectorySeparatorChar;

var classesZip = Path.Combine (ClassesOutputDirectory, "classes.zip");
var classesZip = Path.Combine (ClassesOutputDirectory, "..", "classes.zip");
var acwLines = File.ReadAllLines (AcwMapFile);
using (var appcfg = File.CreateText (ProguardGeneratedApplicationConfiguration))
for (int i = 0; i + 3 < acwLines.Length; i += 4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,54 @@ public void BuildIncrementingAssemblyVersion ()
}
}

[Test]
public void BuildIncrementingClassName ()
{
int count = 0;
var source = new BuildItem ("Compile", "World.cs") {
TextContent = () => {
int current = ++count;
return $"namespace Hello{current} {{ public class World{current} : Java.Lang.Object {{ }} }}";
}
};
var proj = new XamarinAndroidApplicationProject ();
proj.Sources.Add (source);

using (var b = CreateApkBuilder ("temp/BuildIncrementingClassName")) {
Assert.IsTrue (b.Build (proj), "Build should have succeeded.");

var classesZipPath = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "bin", "classes.zip");
FileAssert.Exists (classesZipPath);
var expectedBuilder = new StringBuilder ();
using (var zip = ZipHelper.OpenZip (classesZipPath)) {
foreach (var file in zip) {
expectedBuilder.AppendLine (file.FullName);
}
}
var expectedZip = expectedBuilder.ToString ();

source.Timestamp = null; //Force the file to re-save w/ new Timestamp
Assert.IsTrue (b.Build (proj), "Second build should have succeeded.");

var actualBuilder = new StringBuilder ();
using (var zip = ZipHelper.OpenZip (classesZipPath)) {
foreach (var file in zip) {
actualBuilder.AppendLine (file.FullName);
}
}
var actualZip = actualBuilder.ToString ();
Assert.AreNotEqual (expectedZip, actualZip);

//Build with no changes
Assert.IsTrue (b.Build (proj), "Third build should have succeeded.");
FileAssert.Exists (classesZipPath);

//Clean
Assert.IsTrue (b.Clean (proj), "Clean should have succeeded.");
FileAssert.DoesNotExist (classesZipPath);
}
}

[Test]
public void BuildMkBundleApplicationRelease ()
{
Expand Down