public override bool Execute() { if (!Enum.TryParse(ToolMode, true, out m_LocationStrategy)) { Log.LogError("Invalid ToolMode {0}", ToolMode); return(false); } m_responseFile = Path.GetTempFileName(); List <string> argv = new List <string>(); if (BootClassPath != null && BootClassPath.Length > 0) { argv.Add("-bootclasspath"); argv.Add(string.Join(Path.PathSeparator.ToString(), BootClassPath.Select(x => x.GetMetadata("FullPath")))); } if (ClassPath != null && ClassPath.Length > 0) { argv.Add("-classpath"); argv.Add(string.Join(Path.PathSeparator.ToString(), ClassPath.Select(x => x.GetMetadata("FullPath")))); } if (OutputDirectory != null) { argv.Add("-d"); argv.Add(OutputDirectory.GetMetadata("FullPath")); } argv.AddRange(ExtraArguments); argv.AddRange(ClassNames); File.WriteAllLines(m_responseFile, argv); bool taskSuccess = base.Execute(); if (taskSuccess) { DeleteTempFile(m_responseFile); } else { Log.LogMessage(MessageImportance.High, "Rmic arguments can be found here: {0}", m_responseFile); } return(taskSuccess); }
string CreateResponseFile() { var responseFile = Path.GetTempFileName(); using var response = new StreamWriter(responseFile, append: false, encoding: Files.UTF8withoutBOM); Log.LogDebugMessage("[java-source-utils] response file contents: {0}", responseFile); if (BootClassPath != null && BootClassPath.Any()) { var classpath = string.Join(Path.PathSeparator.ToString(), BootClassPath.Select(p => Path.GetFullPath(p.ItemSpec))); AppendArg(response, "--bootclasspath"); AppendArg(response, classpath); } if (References != null && References.Any()) { foreach (var r in References) { if (Directory.Exists(r.ItemSpec)) { AppendArg(response, "--source"); AppendArg(response, Path.GetFullPath(r.ItemSpec)); continue; } if (!File.Exists(r.ItemSpec)) { Log.LogCodedError("XA1022", Properties.Resources.XA1022, r.ItemSpec); continue; } if (r.ItemSpec.EndsWith(".jar", StringComparison.OrdinalIgnoreCase)) { AppendArg(response, "--jar"); AppendArg(response, Path.GetFullPath(r.ItemSpec)); continue; } if (r.ItemSpec.EndsWith(".aar", StringComparison.OrdinalIgnoreCase)) { AppendArg(response, "--aar"); AppendArg(response, Path.GetFullPath(r.ItemSpec)); continue; } Log.LogError($"Unsupported @(Reference) item: {r.ItemSpec}"); } } AppendArg(response, "--output-javadoc"); AppendArg(response, OutputJavadocXml.ItemSpec); if (!string.IsNullOrEmpty(JavadocCopyrightFile?.ItemSpec)) { AppendArg(response, "--doc-copyright"); AppendArg(response, Path.GetFullPath(JavadocCopyrightFile.ItemSpec)); } if (!string.IsNullOrEmpty(JavadocUrlPrefix)) { AppendArg(response, "--doc-url-prefix"); AppendArg(response, Path.GetFullPath(JavadocUrlPrefix)); } if (!string.IsNullOrEmpty(JavadocUrlStyle)) { AppendArg(response, "--doc-link-style"); AppendArg(response, Path.GetFullPath(JavadocUrlStyle)); } foreach (var path in InputFiles) { AppendArg(response, Path.GetFullPath(path.ItemSpec)); } return(responseFile); void AppendArg(TextWriter writer, string line) { writer.WriteLine(line); Log.LogDebugMessage(line); } }