/// <summary> /// Performs the compilation and copying. /// </summary> /// /// <returns> /// <see langword="true"/> if the processing succeeded; <see langword="false"/> otherwise. /// </returns> public override bool Execute() { // TODO: We may eventually want to check first if the output JAR is up-to-date against the inputs // TODO: We might need to delete the contents of the obj folder first int exitCode; var outputFolder = Path.GetDirectoryName(OutputAssembly); using (var process = new CapturedProcess( Java.GenerateFullPathToCompiler(), null, (line) => Log.LogMessage(MessageImportance.Normal, line), (line) => Log.LogMessage(MessageImportance.High, line))) { process.ArgumentString = GenerateCompilerCommandLine(outputFolder, References, Sources, EmitDebugInformation, DisabledWarnings); Log.LogCommandLine(MessageImportance.Normal, process.ArgumentString); exitCode = process.Run(); } if (exitCode != 0) { Log.LogError("Process exited with code {0}", exitCode); } else { #region Copy resource files to outputFolder if (Resources != null) { foreach (ITaskItem item in Resources) { var inputFile = item.ItemSpec; var outputFile = Path.Combine(outputFolder, item.ItemSpec); Log.LogMessage(MessageImportance.Low, "Copying {0} to {1}...", inputFile, outputFile); var outputDir = Path.GetDirectoryName(outputFile); Directory.CreateDirectory(outputDir); File.Copy(inputFile, outputFile, true); } } #endregion } return(!Log.HasLoggedErrors); }