(.module: [lux #* [abstract [monad (#+ do)]] [control ["." try (#+ Try)] ["." exception] [concurrency ["." promise (#+ Promise)]] [security ["!" capability]]] [data [binary (#+ Binary)] [text ["%" format (#+ format)] ["." encoding]] [collection ["." set]] [format ["." binary] ["." tar] ["." xml]]] [world [program (#+ Program)] ["." file (#+ Path File)] ["." console (#+ Console)]]] [program [compositor ["." export]]] ["." // #_ ["#." clean] ["/#" // #_ ["/" profile (#+ Profile)] ["#." action (#+ Action)] ["#." command (#+ Command)] ["#." local] ["#." pom] ["#." artifact (#+ Artifact) ["#/." extension]]]]) (def: (save! system content file) (-> (file.System Promise) Binary Path (Promise (Try Any))) (do (try.with promise.monad) [file (: (Promise (Try (File Promise))) (file.get_file promise.monad system file))] (!.use (\ file over_write) [content]))) (def: #export failure "Failure: No 'identity' defined for the project.") (def: #export (do! program console system profile) (-> (Program Promise) (Console Promise) (file.System Promise) (Command Any)) (case (get@ #/.identity profile) (#.Some identity) (do promise.monad [home (\ program home [])] (do ///action.monad [package (export.library system (set.to_list (get@ #/.sources profile))) repository (: (Promise (Try Path)) (file.make_directories promise.monad system (///local.path system home identity))) #let [artifact_name (format repository (\ system separator) (///artifact.identity identity))] _ (..save! system (binary.run tar.writer package) (format artifact_name ///artifact/extension.lux_library)) pom (\ promise.monad wrap (///pom.write profile)) _ (..save! system (|> pom (\ xml.codec encode) (\ encoding.utf8 encode)) (format artifact_name ///artifact/extension.pom))] (console.write_line //clean.success console))) _ (console.write_line ..failure console)))