From c8f9f42a258f1f2f961c7f8c5571cce843e97a0a Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 26 Aug 2020 23:04:27 -0400 Subject: Download and catch dependencies in Aedifex. --- stdlib/source/program/aedifex.lux | 94 ++++++--- stdlib/source/program/aedifex/artifact.lux | 68 +++++++ stdlib/source/program/aedifex/cli.lux | 4 +- stdlib/source/program/aedifex/dependency.lux | 276 ++++++++++++++++++++++++++- stdlib/source/program/aedifex/extension.lux | 11 ++ stdlib/source/program/aedifex/hash.lux | 16 +- stdlib/source/program/aedifex/local.lux | 120 +++++++++--- stdlib/source/program/aedifex/parser.lux | 15 +- stdlib/source/program/aedifex/pom.lux | 27 ++- stdlib/source/program/aedifex/project.lux | 35 +--- 10 files changed, 564 insertions(+), 102 deletions(-) create mode 100644 stdlib/source/program/aedifex/artifact.lux create mode 100644 stdlib/source/program/aedifex/extension.lux (limited to 'stdlib/source/program') diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux index 6909704dd..0ca614be1 100644 --- a/stdlib/source/program/aedifex.lux +++ b/stdlib/source/program/aedifex.lux @@ -12,7 +12,7 @@ [security ["!" capability]] [concurrency - ["." promise]]] + ["." promise (#+ Promise)]]] [data [binary (#+ Binary)] ["." text @@ -32,7 +32,8 @@ ["#." parser] ["#." pom] ["#." cli] - ["#." local]]) + ["#." local] + ["#." dependency]]) (def: (read-file! path) (-> Path (IO (Try Binary))) @@ -40,16 +41,6 @@ [project-file (!.use (:: file.system file) [path])] (!.use (:: project-file content) []))) -(def: (write-pom! path project) - (-> Path /.Project (IO (Try Any))) - (do (try.with io.monad) - [file (!.use (:: file.system file) [path])] - (|> project - /pom.project - (:: xml.codec encode) - encoding.to-utf8 - (!.use (:: file over-write))))) - (def: (read-code source-code) (-> Text (Try Code)) (let [parse (syntax.parse "" @@ -64,6 +55,61 @@ (#.Right [end lux-code]) (#try.Success lux-code)))) +(def: (write-pom!' path project) + (-> Path /.Project (IO (Try Any))) + (do (try.with io.monad) + [file (!.use (:: file.system file) [path])] + (|> project + /pom.project + (:: xml.codec encode) + encoding.to-utf8 + (!.use (:: file over-write))))) + +(def: (write-pom! project) + (-> /.Project (IO Any)) + (do io.monad + [outcome (write-pom!' /pom.file project)] + (case outcome + (#try.Success value) + (wrap (log! "Successfully wrote POM file!")) + + (#try.Failure error) + (wrap (log! (format "Could not write POM file:" text.new-line + error)))))) + +(def: (install! project) + (-> /.Project (Promise Any)) + (do promise.monad + [outcome (/local.install (file.async file.system) project)] + (wrap (case outcome + (#try.Success _) + (log! "Successfully installed locally!") + + (#try.Failure error) + (log! (format "Could not install locally:" text.new-line + error)))))) + +(def: (fetch-dependencies! project) + (-> /.Project (Promise Any)) + (do promise.monad + [outcome (do (try.with promise.monad) + [cache (/local.all-cached (file.async file.system) + (get@ #/.dependencies project) + /dependency.empty) + resolution (promise.future + (/dependency.resolve-all (get@ #/.repositories project) + (get@ #/.dependencies project) + cache))] + (/local.cache-all (file.async file.system) + resolution))] + (wrap (case outcome + (#try.Success _) + (log! "Successfully resolved dependencies!") + + (#try.Failure error) + (log! (format "Could not resolve dependencies:" text.new-line + error)))))) + (def: project (-> Binary (Try /.Project)) (|>> (do> try.monad @@ -80,26 +126,14 @@ (#try.Success project) (case command #/cli.POM - (do @ - [outcome (..write-pom! /pom.file project)] - (case outcome - (#try.Success value) - (wrap (log! "Successfully wrote POM file!")) - - (#try.Failure error) - (wrap (log! (format "Could not write POM file:" text.new-line - error))))) + (..write-pom! project) #/cli.Install - (exec (do promise.monad - [outcome (/local.install (file.async file.system) project)] - (wrap (case outcome - (#try.Success _) - (log! "Successfully installed locally!") - - (#try.Failure error) - (log! (format "Could not install locally:" text.new-line - error))))) + (exec (..install! project) + (wrap [])) + + #/cli.Dependencies + (exec (..fetch-dependencies! project) (wrap []))) (#try.Failure error) diff --git a/stdlib/source/program/aedifex/artifact.lux b/stdlib/source/program/aedifex/artifact.lux new file mode 100644 index 000000000..a6865f688 --- /dev/null +++ b/stdlib/source/program/aedifex/artifact.lux @@ -0,0 +1,68 @@ +(.module: + [lux (#- Name) + [abstract + ["." hash (#+ Hash)]] + [data + ["." text + ["%" format (#+ format)]] + [collection + ["." list ("#@." monoid)]]] + [world + [net + ["." uri]]]]) + +(type: #export Group + Text) + +(type: #export Name + Text) + +(type: #export Version + Text) + +(type: #export Artifact + {#group Group + #name Name + #version Version}) + +(def: #export hash + (Hash Artifact) + ($_ hash.product + text.hash + text.hash + text.hash + )) + +(def: group-separator + ".") + +(def: version-separator + "-") + +(def: #export (identity artifact) + (-> Artifact Text) + (format (get@ #name artifact) + ..version-separator + (get@ #version artifact))) + +(def: #export (path artifact) + (-> Artifact Text) + (let [directory (format (|> artifact + (get@ #group) + (text.split-all-with ..group-separator) + (text.join-with uri.separator)) + uri.separator + (get@ #name artifact) + uri.separator + (get@ #version artifact))] + (format directory + uri.separator + (..identity artifact)))) + +(def: #export (local artifact) + (-> Artifact (List Text)) + (list@compose (|> artifact + (get@ #group) + (text.split-all-with ..group-separator)) + (list (get@ #name artifact) + (get@ #version artifact)))) diff --git a/stdlib/source/program/aedifex/cli.lux b/stdlib/source/program/aedifex/cli.lux index 5f75cac9b..4ff56ac53 100644 --- a/stdlib/source/program/aedifex/cli.lux +++ b/stdlib/source/program/aedifex/cli.lux @@ -6,11 +6,13 @@ (type: #export Command #POM - #Install) + #Install + #Dependencies) (def: #export command (Parser Command) ($_ <>.or (cli.this "pom") (cli.this "install") + (cli.this "deps") )) diff --git a/stdlib/source/program/aedifex/dependency.lux b/stdlib/source/program/aedifex/dependency.lux index 473d5498e..7c40bf2ae 100644 --- a/stdlib/source/program/aedifex/dependency.lux +++ b/stdlib/source/program/aedifex/dependency.lux @@ -1,12 +1,55 @@ (.module: - [lux (#- Type)] + [lux (#- Name Type) + ["." host (#+ import:)] + [abstract + [monad (#+ do)] + ["." hash (#+ Hash)]] + [control + ["." io (#+ IO)] + ["." try (#+ Try)] + ["." exception (#+ Exception exception:)] + ["<>" parser + ["" xml (#+ Parser)]]] + [data + ["." binary (#+ Binary)] + ["." name] + ["." maybe] + ["." text + ["%" format (#+ format)] + ["." encoding]] + [number + ["." i64] + ["n" nat]] + [format + ["." xml (#+ Tag XML)]] + [collection + ["." dictionary (#+ Dictionary)]]] + [world + [net (#+ URL) + ["." uri]]]] ["." // #_ + ["#." extension] + ["#." artifact (#+ Artifact)] ["#." hash]]) +(type: #export Repository + URL) + ## https://maven.apache.org/ref/3.6.3/maven-core/artifact-handlers.html (type: #export Type Text) +(type: #export Dependency + {#artifact Artifact + #type ..Type}) + +(def: #export hash + (Hash Dependency) + ($_ hash.product + //artifact.hash + text.hash + )) + (template [ ] [(def: #export Type @@ -15,3 +58,234 @@ ["tar" lux-library] ["jar" jvm-library] ) + +(import: #long java/lang/String) + +(import: #long java/lang/AutoCloseable + (close [] #io #try void)) + +(import: #long java/io/InputStream) + +(import: #long java/net/URL + (new [java/lang/String]) + (openStream [] #io #try java/io/InputStream)) + +(import: #long java/io/BufferedInputStream + (new [java/io/InputStream]) + (read [[byte] int int] #io #try int)) + +(def: buffer-size + (n.* 512 1,024)) + +(def: (download url) + (-> URL (IO (Try Binary))) + (do {@ (try.with io.monad)} + [input (|> (java/net/URL::new url) + java/net/URL::openStream + (:: @ map (|>> java/io/BufferedInputStream::new))) + #let [buffer (binary.create ..buffer-size)]] + (loop [output (:: binary.monoid identity)] + (do @ + [bytes-read (java/io/BufferedInputStream::read buffer +0 (.int ..buffer-size) input)] + (case bytes-read + -1 (do @ + [_ (java/lang/AutoCloseable::close input)] + (wrap output)) + _ (if (n.= ..buffer-size bytes-read) + (recur (:: binary.monoid compose output buffer)) + (do @ + [chunk (:: io.monad wrap (binary.slice 0 (.nat bytes-read) buffer))] + (recur (:: binary.monoid compose output chunk))))))))) + +(def: hex-per-byte + 2) + +(def: hex-per-nat + (n.* hex-per-byte i64.bytes-per-i64)) + +(type: Hash-Reader + (-> Binary (Try //hash.Hash))) + +(def: (sha1 input) + Hash-Reader + (do try.monad + [input (encoding.from-utf8 input) + [left input] (try.from-maybe (text.split ..hex-per-nat input)) + [middle right] (try.from-maybe (text.split ..hex-per-nat input)) + #let [output (:: binary.monoid identity)] + left (:: n.hex decode left) + output (binary.write/64 0 left output) + middle (:: n.hex decode middle) + output (binary.write/64 i64.bytes-per-i64 middle output) + right (:: n.hex decode right)] + (binary.write/64 (n.* 2 i64.bytes-per-i64) right output))) + +(def: (md5 input) + Hash-Reader + (do try.monad + [input (encoding.from-utf8 input) + [left right] (try.from-maybe (text.split ..hex-per-nat input)) + #let [output (:: binary.monoid identity)] + left (:: n.hex decode left) + output (binary.write/64 0 left output) + right (:: n.hex decode right)] + (binary.write/64 i64.bytes-per-i64 right output))) + +(template [] + [(exception: #export ( {dependency Dependency} {hash Text}) + (let [artifact (get@ #artifact dependency) + type (get@ #type dependency)] + (exception.report + ["Artifact" (format (get@ #//artifact.group artifact) + " " (get@ #//artifact.name artifact) + " " (get@ #//artifact.version artifact))] + ["Type" (%.text type)] + ["Hash" (%.text hash)])))] + + [sha1-does-not-match] + [md5-does-not-match] + ) + +(type: #export Package + {#library Binary + #pom XML + #dependencies (List Dependency) + #sha1 Text + #md5 Text}) + +(def: (verified-hash dependency library url hash reader exception) + (-> Dependency Binary URL (-> Binary //hash.Hash) Hash-Reader (Exception [Dependency Text]) + (IO (Try Text))) + (do (try.with io.monad) + [#let [reference (hash library)] + actual (..download url)] + (:: io.monad wrap + (do try.monad + [output (encoding.from-utf8 actual) + actual (reader actual) + _ (exception.assert exception [dependency output] + (:: binary.equivalence = reference actual))] + (wrap output))))) + +(def: parse-property + (Parser [Tag Text]) + (do <>.monad + [property .tag + _ (.node property) + value (.children .text)] + (wrap [property value]))) + +(def: parse-dependency + (Parser Dependency) + (do {@ <>.monad} + [properties (:: @ map (dictionary.from-list name.hash) + (.children (<>.some ..parse-property)))] + (<| <>.lift + try.from-maybe + (do maybe.monad + [group (dictionary.get ["" "groupId"] properties) + artifact (dictionary.get ["" "artifactId"] properties) + version (dictionary.get ["" "version"] properties)] + (wrap {#artifact {#//artifact.group group + #//artifact.name artifact + #//artifact.version version} + #type (|> properties + (dictionary.get ["" "type"]) + (maybe.default ..lux-library))}))))) + +(def: parse-dependencies + (Parser (List Dependency)) + (do {@ <>.monad} + [_ (.node ["" "dependencies"])] + (.children (<>.some ..parse-dependency)))) + +(def: #export from-pom + (-> XML (Try (List Dependency))) + (.run (do {@ <>.monad} + [_ (.node ["" "project"])] + (.children (loop [_ []] + (do @ + [?dependencies (<>.or ..parse-dependencies + (<>.maybe .ignore))] + (case ?dependencies + (#.Left dependencies) + (wrap dependencies) + + (#.Right #.None) + (wrap (: (List Dependency) + (list))) + + (#.Right (#.Some _)) + (recur [])))))))) + +(def: #export (resolve repository dependency) + (-> Repository Dependency (IO (Try Package))) + (let [[artifact type] dependency + prefix (format repository uri.separator (//artifact.path artifact))] + (do (try.with io.monad) + [library (..download (format prefix "." type)) + sha1 (..verified-hash dependency library (format prefix //extension.sha1) //hash.sha1 ..sha1 ..sha1-does-not-match) + md5 (..verified-hash dependency library (format prefix //extension.md5) //hash.md5 ..md5 ..md5-does-not-match) + pom (..download (format prefix //extension.pom))] + (:: io.monad wrap + (do try.monad + [pom (encoding.from-utf8 pom) + pom (:: xml.codec decode pom) + dependencies (..from-pom pom)] + (wrap {#library library + #pom pom + #dependencies dependencies + #sha1 sha1 + #md5 md5})))))) + +(type: #export Resolution + (Dictionary Dependency Package)) + +(def: #export empty + Resolution + (dictionary.new ..hash)) + +(exception: #export (cannot-resolve {dependency Dependency}) + (let [artifact (get@ #artifact dependency) + type (get@ #type dependency)] + (exception.report + ["Artifact" (format (get@ #//artifact.group artifact) + " " (get@ #//artifact.name artifact) + " " (get@ #//artifact.version artifact))] + ["Type" (%.text type)]))) + +(def: (resolve-any repositories dependency) + (-> (List Repository) Dependency (IO (Try Package))) + (case repositories + #.Nil + (|> dependency + (exception.throw ..cannot-resolve) + (:: io.monad wrap)) + + (#.Cons repository alternatives) + (do io.monad + [outcome (..resolve repository dependency)] + (case outcome + (#try.Success package) + (wrap outcome) + + (#try.Failure error) + (resolve-any alternatives dependency))))) + +(def: #export (resolve-all repositories dependencies resolution) + (-> (List Repository) (List Dependency) Resolution (IO (Try Resolution))) + (case dependencies + #.Nil + (:: (try.with io.monad) wrap resolution) + + (#.Cons head tail) + (do (try.with io.monad) + [package (case (dictionary.get head resolution) + (#.Some package) + (wrap package) + + #.None + (..resolve-any repositories head)) + #let [resolution (dictionary.put head package resolution)] + resolution (resolve-all repositories (get@ #dependencies package) resolution)] + (resolve-all repositories tail resolution)))) diff --git a/stdlib/source/program/aedifex/extension.lux b/stdlib/source/program/aedifex/extension.lux new file mode 100644 index 000000000..6caa343aa --- /dev/null +++ b/stdlib/source/program/aedifex/extension.lux @@ -0,0 +1,11 @@ +(.module: + [lux #*]) + +(def: #export sha1 + ".sha1") + +(def: #export md5 + ".md5") + +(def: #export pom + ".pom") diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index bd4396006..63511a74d 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -2,7 +2,11 @@ [lux #* ["." host (#+ import:)] [data - ["." binary (#+ Binary)]]]) + ["." binary (#+ Binary)] + ["." text + ["%" format (#+ format)]] + [number + ["." nat]]]]) ## TODO: Replace with pure-Lux implementations of these algorithms ## https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode @@ -25,3 +29,13 @@ [sha1 "SHA-1"] [md5 "MD5"] ) + +(def: #export representation + (-> Hash Text) + (binary.fold (function (_ byte representation) + (let [hex (:: nat.hex encode byte) + hex (case (text.size hex) + 1 (format "0" hex) + _ hex)] + (format representation hex))) + "")) diff --git a/stdlib/source/program/aedifex/local.lux b/stdlib/source/program/aedifex/local.lux index 15d9a9323..8761b573a 100644 --- a/stdlib/source/program/aedifex/local.lux +++ b/stdlib/source/program/aedifex/local.lux @@ -15,7 +15,8 @@ ["%" format (#+ format)] ["." encoding]] [collection - ["." list ("#@." monoid)]] + ["." list ("#@." monoid)] + ["." dictionary]] [format ["." binary] ["." tar] @@ -26,12 +27,12 @@ [compositor ["." export]]] ["." // #_ - ["#." project (#+ Project)] + ["/" project (#+ Project)] + ["#." extension] ["#." pom] - ["#." dependency]]) - -(def: group-separator - ".") + ["#." artifact (#+ Artifact)] + ["#." dependency (#+ Package Resolution Dependency)] + ["#." hash]]) (def: (local system) (All [a] (-> (file.System a) Path)) @@ -41,13 +42,12 @@ (All [a] (-> (file.System a) Path)) (format (..local system) (:: system separator) "repository")) -(def: (guarantee-repository! system project) - (-> (file.System Promise) Project (Promise (Try Path))) +(def: (guarantee-repository! system artifact) + (-> (file.System Promise) Artifact (Promise (Try Path))) (do {@ (try.with promise.monad)} [_ (: (Promise (Try (Directory Promise))) (file.get-directory promise.monad system (..local system))) - #let [root (..repository system) - identity (get@ #//project.identity project)] + #let [root (..repository system)] _ (: (Promise (Try (Directory Promise))) (file.get-directory promise.monad system root))] (monad.fold @ @@ -58,11 +58,7 @@ (file.get-directory promise.monad system path))] (wrap path))) root - (list@compose (|> identity - (get@ #//project.group) - (text.split-all-with ..group-separator)) - (list (get@ #//project.name identity) - (get@ #//project.version identity)))))) + (//artifact.local artifact)))) (def: (save! system content file) (-> (file.System Promise) Binary Path (Promise (Try Any))) @@ -74,13 +70,93 @@ (def: #export (install system project) (-> (file.System Promise) Project (Promise (Try Any))) (do (try.with promise.monad) - [repository (..guarantee-repository! system project) - #let [identity (get@ #//project.identity project) - artifact-name (format repository - (:: system separator) (get@ #//project.name identity) - "-" (get@ #//project.version identity))] - package (export.library system (get@ #//project.sources project)) + [repository (..guarantee-repository! system (get@ #/.identity project)) + #let [identity (get@ #/.identity project) + artifact-name (format repository (:: system separator) (//artifact.identity identity))] + package (export.library system (get@ #/.sources project)) _ (..save! system (binary.run tar.writer package) (format artifact-name "." //dependency.lux-library))] (..save! system (|> project //pom.project (:: xml.codec encode) encoding.to-utf8) - (format artifact-name //pom.extension)))) + (format artifact-name //extension.pom)))) + +(def: #export (cache system [artifact type] package) + (-> (file.System Promise) Dependency Package (Promise (Try Any))) + (do (try.with promise.monad) + [directory (..guarantee-repository! system artifact) + #let [prefix (format directory (:: system separator) (//artifact.identity artifact))] + directory (: (Promise (Try (Directory Promise))) + (file.get-directory promise.monad system directory)) + _ (..save! system + (get@ #//dependency.library package) + (format prefix "." type)) + _ (..save! system + (encoding.to-utf8 (get@ #//dependency.sha1 package)) + (format prefix //extension.sha1)) + _ (..save! system + (encoding.to-utf8 (get@ #//dependency.md5 package)) + (format prefix //extension.md5)) + _ (..save! system + (|> package (get@ #//dependency.pom) (:: xml.codec encode) encoding.to-utf8) + (format prefix //extension.pom))] + (wrap []))) + +(def: #export (cache-all system resolution) + (-> (file.System Promise) Resolution (Promise (Try Any))) + (do {@ (try.with promise.monad)} + [_ (monad.map @ (function (_ [dependency package]) + (..cache system dependency package)) + (dictionary.entries resolution))] + (wrap []))) + +(def: (read! system path) + (-> (file.System Promise) Path (Promise (Try Binary))) + (do (try.with promise.monad) + [file (: (Promise (Try (File Promise))) + (!.use (:: system file) path))] + (!.use (:: file content) []))) + +(def: #export (cached system [artifact type]) + (-> (file.System Promise) Dependency (Promise (Try Package))) + (do (try.with promise.monad) + [directory (..guarantee-repository! system artifact) + #let [prefix (format directory (:: system separator) (//artifact.identity artifact))] + pom (..read! system (format prefix //extension.pom)) + [pom dependencies] (:: promise.monad wrap + (do try.monad + [pom (encoding.from-utf8 pom) + pom (:: xml.codec decode pom) + dependencies (//dependency.from-pom pom)] + (wrap [pom dependencies]))) + library (..read! system (format prefix "." type)) + sha1 (..read! system (format prefix //extension.sha1)) + md5 (..read! system (format prefix //extension.md5))] + (wrap {#//dependency.library library + #//dependency.pom pom + #//dependency.dependencies dependencies + #//dependency.sha1 (//hash.representation sha1) + #//dependency.md5 (//hash.representation md5)}))) + +(def: #export (all-cached system dependencies resolution) + (-> (file.System Promise) (List Dependency) Resolution (Promise (Try Resolution))) + (case dependencies + #.Nil + (:: (try.with promise.monad) wrap resolution) + + (#.Cons head tail) + (do promise.monad + [package (case (dictionary.get head resolution) + (#.Some package) + (wrap (#try.Success package)) + + #.None + (..cached system head))] + (with-expansions [ (as-is (all-cached system tail resolution))] + (case package + (#try.Success package) + (let [resolution (dictionary.put head package resolution)] + (do (try.with promise.monad) + [resolution (all-cached system (get@ #//dependency.dependencies package) resolution)] + )) + + (#try.Failure error) + ))))) diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux index 1a4b2f638..78f6dbb60 100644 --- a/stdlib/source/program/aedifex/parser.lux +++ b/stdlib/source/program/aedifex/parser.lux @@ -11,26 +11,27 @@ [net (#+ URL)]]] [// ["/" project] + ["//." artifact (#+ Artifact)] ["//." dependency]]) (def: group - (Parser /.Group) + (Parser //artifact.Group) .text) (def: name - (Parser /.Name) + (Parser //artifact.Name) .text) (def: version - (Parser /.Version) + (Parser //artifact.Version) .text) (def: artifact' - (Parser /.Artifact) + (Parser //artifact.Artifact) ($_ <>.and ..group ..name ..version)) (def: artifact - (Parser /.Artifact) + (Parser //artifact.Artifact) (.tuple ..artifact')) (def: url @@ -106,7 +107,7 @@ )) (def: repository - (Parser /.Repository) + (Parser //dependency.Repository) ..url) (def: type @@ -114,7 +115,7 @@ .text) (def: dependency - (Parser /.Dependency) + (Parser //dependency.Dependency) (.tuple ($_ <>.and ..artifact' diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux index 102728e1e..794ed7e12 100644 --- a/stdlib/source/program/aedifex/pom.lux +++ b/stdlib/source/program/aedifex/pom.lux @@ -8,17 +8,16 @@ ["_" xml (#+ XML)]] [collection ["." list ("#@." monoid functor)]]]] - [// - ["/" project]]) + ["." // #_ + ["/" project] + ["#." artifact (#+ Artifact)] + ["#." dependency (#+ Repository Dependency)]]) ## https://maven.apache.org/pom.html (def: #export file "pom.xml") -(def: #export extension - ".pom") - (def: version XML (#_.Node ["" "modelVersion"] _.attrs @@ -31,10 +30,10 @@ (list (#_.Text value)))) (def: (artifact value) - (-> /.Artifact (List XML)) - (list (..property "groupId" (get@ #/.group value)) - (..property "artifactId" (get@ #/.name value)) - (..property "version" (get@ #/.version value)))) + (-> Artifact (List XML)) + (list (..property "groupId" (get@ #//artifact.group value)) + (..property "artifactId" (get@ #//artifact.name value)) + (..property "version" (get@ #//artifact.version value)))) (def: distribution (-> /.Distribution XML) @@ -50,17 +49,17 @@ (#_.Node ["" "license"] _.attrs))) (def: repository - (-> /.Repository XML) + (-> Repository XML) (|>> (..property "url") list (#_.Node ["" "repository"] _.attrs))) -(def: (dependency [artifact type]) - (-> /.Dependency XML) +(def: (dependency value) + (-> Dependency XML) (#_.Node ["" "dependency"] _.attrs - (list@compose (..artifact artifact) - (list (..property "type" type))))) + (list@compose (..artifact (get@ #//dependency.artifact value)) + (list (..property "type" (get@ #//dependency.type value)))))) (def: scm (-> /.SCM XML) diff --git a/stdlib/source/program/aedifex/project.lux b/stdlib/source/program/aedifex/project.lux index 9f98ebc51..385ef8919 100644 --- a/stdlib/source/program/aedifex/project.lux +++ b/stdlib/source/program/aedifex/project.lux @@ -1,34 +1,23 @@ (.module: - [lux (#- Name Info Source) + [lux (#- Info Source) + [data + ["." text]] [world [net (#+ URL)] [file (#+ Path)]]] [// + [artifact (#+ Artifact)] ["." dependency]]) (def: #export file "project.lux") -(type: #export Group - Text) - -(type: #export Name - Text) - -(type: #export Version - Text) - -(type: #export Artifact - {#group Group - #name Name - #version Version}) - (type: #export Distribution #Repo #Manual) (type: #export License - [Name + [Text URL Distribution]) @@ -36,14 +25,14 @@ URL) (type: #export Organization - [Name + [Text URL]) (type: #export Email Text) (type: #export Developer - [Name + [Text Email (Maybe Organization)]) @@ -59,18 +48,12 @@ #developers (List Developer) #contributors (List Contributor)}) -(type: #export Repository - URL) - -(type: #export Dependency - [Artifact dependency.Type]) - (type: #export Source Path) (type: #export Project {#identity Artifact #info Info - #repositories (List Repository) - #dependencies (List Dependency) + #repositories (List dependency.Repository) + #dependencies (List dependency.Dependency) #sources (List Source)}) -- cgit v1.2.3