public override bool Execute() { Log.LogDebugMessage("CreateMultiDexMainDexClassList"); Log.LogDebugMessage(" ClassesOutputDirectory: {0}", ClassesOutputDirectory); Log.LogDebugTaskItems(" JavaLibraries:", JavaLibraries); Log.LogDebugMessage(" MultiDexMainDexListFile: {0}", MultiDexMainDexListFile); Log.LogDebugTaskItems(" CustomMainDexListFiles:", CustomMainDexListFiles); Log.LogDebugMessage(" ToolExe: {0}", ToolExe); Log.LogDebugMessage(" ToolPath: {0}", ToolPath); Log.LogDebugMessage(" ProguardJarPath: {0}", ProguardJarPath); Log.LogDebugMessage(" ProguardInputJarFilter: {0}", ProguardInputJarFilter); if (CustomMainDexListFiles != null && CustomMainDexListFiles.Any()) { var content = string.Concat(CustomMainDexListFiles.Select(i => File.ReadAllText(i.ItemSpec))); File.WriteAllText(MultiDexMainDexListFile, content); return(true); } tempJar = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".jar"); commandlineAction = GenerateProguardCommands; // run proguard first var retval = base.Execute(); if (!retval || Log.HasLoggedErrors) { return(false); } commandlineAction = GenerateMainDexListBuilderCommands; // run java second return(base.Execute() && !Log.HasLoggedErrors); }
protected override string GenerateCommandLineCommands() { if (CustomMainDexListFiles != null && CustomMainDexListFiles.Any()) { // FIXME: add error code. Log.LogWarning("Jack compiler does not accept custom main dex list file. You would have to either disable Jack or remove MultiDexMainDexList items."); } // Running command: C:\Program Files (x86)\Java\jdk1.6.0_20\bin\java.exe // "-jar" "C:\Program Files (x86)\Android\android-sdk-windows\platform-tools\jack.jar" // "--output-dex" "bin" // "-classpath" "C:\Users\Jonathan\Documents\Visual Studio 2010\Projects\AndroidMSBuildTest\AndroidMSBuildTest\obj\Debug\android\bin\mono.android.jar" // "@C:\Users\Jonathan\AppData\Local\Temp\tmp79c4ac38.tmp" //var android_dir = MonoDroid.MonoDroidSdk.GetAndroidProfileDirectory (TargetFrameworkDirectory); var cmd = new CommandLineBuilder(); cmd.AppendSwitchIfNotNull("-jar ", JackJarPath); //cmd.AppendSwitchIfNotNull ("-J-Dfile.encoding=", "UTF8"); cmd.AppendSwitchIfNotNull("--output-dex ", OutputDexDirectory); cmd.AppendSwitchIfNotNull("-cp ", JavaPlatformJackPath); foreach (var jack in InputJackFiles) { cmd.AppendSwitchIfNotNull("--import ", jack); } //cmd.AppendSwitchIfNotNull ("-bootclasspath ", JavaPlatformJarPath); //cmd.AppendSwitchIfNotNull ("-encoding ", "UTF-8"); cmd.AppendFileNameIfNotNull(string.Format("@{0}", TemporarySourceListFile)); if (EnableMultiDex) { cmd.AppendSwitchIfNotNull("--multi-dex ", "NATIVE"); } // Proguard settings if (EnableProguard) { var acwLines = File.ReadAllLines(AcwMapFile); using (var appcfg = File.CreateText(ProguardGeneratedApplicationConfiguration)) for (int i = 0; i + 3 < acwLines.Length; i += 4) { try { var java = acwLines [i + 3].Substring(acwLines [i + 3].IndexOf(';') + 1); appcfg.WriteLine("-keep class " + java + " { *; }"); } catch { // skip invalid lines } } var configs = ProguardConfigurationFiles .Replace("{sdk.dir}", Path.GetDirectoryName(Path.GetDirectoryName(ProguardJarPath)) + Path.DirectorySeparatorChar) .Replace("{intermediate.common.xamarin}", ProguardCommonXamarinConfiguration) .Replace("{intermediate.references}", ProguardGeneratedReferenceConfiguration) .Replace("{intermediate.application}", ProguardGeneratedApplicationConfiguration) .Replace("{project}", string.Empty) // current directory anyways. .Split(';') .Select(s => s.Trim()) .Where(s => !string.IsNullOrWhiteSpace(s)); foreach (var file in configs) { if (File.Exists(file)) { cmd.AppendSwitchIfNotNull("--config-proguard ", file); } else { Log.LogWarning("Proguard configuration file '{0}' was not found.", file); } } } return(cmd.ToString()); }