[Nice-commit] Nice/src/nice/tools/repository/publish send.nice,NONE,1.1 main.nice,NONE,1.1
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2004-08-07 14:57:41
|
Update of /cvsroot/nice/Nice/src/nice/tools/repository/publish In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv758/src/nice/tools/repository/publish Added Files: send.nice main.nice Log Message: Implementation of remote package repositories. --- NEW FILE: main.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package nice.tools.repository.publish; /** Publish a library on a public repository. @author Daniel Bonniot (bo...@us...) */ import nice.tools.repository; import nice.tools.compiler.console; import nice.tools.unit.console; let java.text.DateFormat fmt = getVerDateFormat(); java.text.DateFormat getVerDateFormat() { let res = new java.text.SimpleDateFormat("yyyyMMddhhmm"); res.setTimeZone(TimeZone.getTimeZone("UTC")); return res; } void main(String[] args) { let dest = args[0]; let pkg = args[1]; let ver = "0.0"; let datedVer = ver + "." fmt.format(new Date()); let jar = pkg + "-" datedVer ".jar"; if (compile(args.slice(2) + [ "-a", jar, pkg ]) != OK) System.exit(1); let listener = new TestListener(); runTests(pkg, listener, jar); if (listener.failed) System.exit(1); send(datedVer, jar, dest + '/' + packagePath(pkg)); } class TestListener extends nice.tools.unit.console.Listener { boolean failed = false; failure(test, cause) { super; failed = true; } } --- NEW FILE: send.nice --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2004 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package nice.tools.repository.publish; import java.io.*; boolean send(String datedVer, String jar, String dest) { let ident = dest.substring(0, dest.indexOf(':')); let dir = dest.substring(dest.indexOf(':') + 1); println("ssh " ident " mkdir -p " dir); Process p = Runtime.getRuntime().exec(["ssh", ident, "mkdir", "-p", dir]); if (waitFor(p, new OutputStreamWriter(System.out)) != 0) { println("\nPublication failed."); return false; } println("scp " jar " " dest); p = Runtime.getRuntime().exec(["scp", jar, dest]); if (waitFor(p, new OutputStreamWriter(System.out)) != 0) { println("\nPublication failed."); return false; } let temp = File.createTempFile("latest", "tmp"); using (let out = new PrintWriter(new FileWriter(temp))) { out.println(datedVer); } p = Runtime.getRuntime().exec(["scp", temp.getPath(), dest + "/latest"]); if (waitFor(p, new OutputStreamWriter(System.out)) != 0) { println("\nPublication failed."); return false; } return true; } |