ç¶ç¶çã¤ã³ãã°ã¬ã¼ã·ã§ã³ ãã®ï¼
NAntã使ã£ã¦ãSubversionããã½ã¼ã¹ããã§ãã¯ã¢ã¦ãããã
ã§ããNAntã«ã¯Subversionç¨ã®ã¿ã¹ã¯ãç¨æããã¦ããªãã®ã§ãã¨ããããexecã¿ã¹ã¯ã使ã£ã¦ãã£ã¦ã¿ãã
<?xml version="1.0" encoding="shift-jis"?> <project default="svn"> <target name="svn"> <exec program="C:\Program Files\Subversion\bin\svn.exe" commandline="checkout http://localhost/svn/default/hoge/trunk c:\temp" /> </target> </project>
ããã§NAntãå®è¡ãã¦ã¿ãã¨ãç°¡åã«ã½ã¼ã¹ããã§ãã¯ã¢ã¦ãã§ããã
ã§ãããã ãã ã¨é¢ç½ããªãã®ã§ãNAntç¨ã®ã¿ã¹ã¯ãèªåã§ä½ã£ã¦ã¿ããã¨ã«ããã
NAntã®ã«ã¹ã¿ã ã¿ã¹ã¯
ã¾ããããã¸ã§ã¯ããã¯ã©ã¹ã©ã¤ãã©ãªã§ä½æããã
ããã¸ã§ã¯ãåããNAnt.SvnTasksãã«è¨å®ãNAntã¯ã«ã¹ã¿ã ã¿ã¹ã¯ã®å®ç¾©ãããã¢ã»ã³ããªã*.Tasks.dllã¨ãããã¿ã¼ã³ã§æ¤ç´¢ãã¦ãã¼ããããããããã¸ã§ã¯ãåãããã«åããã¦ããã
NAnt.Core.dllã¢ã»ã³ããªãåç
§è¨å®ããã
次ã«ã¯ã©ã¹ãã¡ã¤ã«ã追å ããã
Subversionãããã§ãã¯ã¢ã¦ãããã¯ã©ã¹ãªã®ã§ããSvnCheckoutTaskãã¨ããã
ã«ã¹ã¿ã ã¿ã¹ã¯ã¯ãNAnt.Core.Taskãã¯ã©ã¹ããæ´¾çããã¦ããExecuteTaskãã¡ã½ããããªã¼ãã¼ã©ã¤ãããå¿
è¦ãããã®ã§ããã®ããã«ããã
以ä¸ãå
¨ã½ã¼ã¹
using System; using System.Diagnostics; using NAnt.Core; using NAnt.Core.Attributes; namespace NAnt.SvnTasks { [Serializable] [TaskName("svn-checkout")] public class SvnCheckoutTask : Task { private string executable = "svn.exe"; private string repository; private string workingDirectory; private string userName; private string password; [TaskAttribute("executable", Required=false)] public string Executable { get { return executable; } set { executable = value; } } [TaskAttribute("repository", Required=true)] public string Repository { get { return repository; } set { repository = value; } } [TaskAttribute("workingDir", Required=true)] public string WorkingDirectorya { get { return workingDirectory; } set { workingDirectory = value; } } [TaskAttribute("username", Required=false)] public string UserName { get { return userName; } set { userName = value; } } [TaskAttribute("password", Required=false)] public string Password { get { return password; } set { password = value; } } public SvnCheckoutTask() { } protected override void ExecuteTask() { ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = executable; startInfo.UseShellExecute = false; startInfo.RedirectStandardOutput = true; // 0 : ãªãã¸ã㪠// 1 : ä½æ¥ãã©ã«ã // 2 : ã¦ã¼ã¶å // 3 : ãã¹ã¯ã¼ã startInfo.Arguments = string.Format( "checkout \"{0}\" \"{1}\" {2} {3}", repository, workingDirectory, IsNotNullOrEmpty(userName) ? "--username " + userName : string.Empty, IsNotNullOrEmpty(password) ? "--password " + password : string.Empty); if(Verbose) Log(Level.Info, startInfo.Arguments); Process proc = Process.Start(startInfo); string stdout = proc.StandardOutput.ReadToEnd(); proc.WaitForExit(); if(Verbose) Log(Level.Info, stdout); } private bool IsNotNullOrEmpty(string value) { return value != null && value.Length != 0; } } }
ãTaskNameãå±æ§ã®å¼æ°ã«æå®ããååããã®ã¾ã¾NAntã®ã¿ã¹ã¯åã«ãªãã
ã«ã¹ã¿ã ã¿ã¹ã¯ã®å±æ§ã¨ãã¦èªèãããã«ã¯ãããããã£ããTaskAttributeãå±æ§ã§ãã¼ã¯ããã
å¼æ°ã«æå®ããååããã®ã¾ã¾å±æ§åã«ãªãããªãã·ã§ã³ã§å¿ é å±æ§ãã©ãããæå®ã§ãããï¼Required=true or falseï¼
ããããã«ããã¦ãNAnt.SvnTasks.dllãNAnt.exeã®ãããã©ã«ãã«ã³ãã¼ããã
ãããªæãã§ä½¿ãã
<?xml version="1.0" encoding="shift-jis"?> <project default="svn"> <target name="svn"> <svn-checkout repository="http://localhost/svn/default/hoge/trunk" workingDir="c:\temp" verbose="true" /> </target> </project>
ãã«ãå®è¡ï¼ï¼ï¼ï¼ï¼ï¼ãã£åããï¼
çµæ§ãç°¡åã«ä½ãããã§ãexecã®ã¨ãã¨ããã¾ãå¤ãã£ã¦ãªãæ°ãããã
ã¾ããåå¼·ã«ãªã£ããããããã
次ã¯ãã®ã¿ã¹ã¯ãCruiseControl.NETããåããã¦ã¿ãã